Get spawn-fcgi to work with nginx on ubuntu

This is what I used to setup a startup script for fastCGI to work with nginx. That allows me to run multiple wordpress blogs off my slicehost.

Once it is setup I can start/restart my FastCGI processes easily.

/etc/init.d/fastcgi start
/etc/init.d/fastcgi restart
/etc/init.d/fastcgi stop

Reference: PHP5 FastCGI config for nginx on Ubuntu and clean URLs

I was trying to figure out how to get a wordpress blog up and running on my slicehost slice real fast but I don’t know anything about nginx or FastCGI.

Serving PHP5 with Nginx on Ubuntu 7.10 turned out to be a good step-by-step that provided all the info I needed. Thanks Mr. Blogger!

For SEO purposes I also needed some clean URLs. nginx does not do .htaccess files so you have to setup the nginx config yourself. nginx rewrite rules for wordpress worked for me. Thank you too Mr. Blogger!

I added this to my location block {}.

if (-e $request_filename) {
rewrite ^/blog/(.+)$ /blog/index.php?q=$1 last;

Execute command line and shell commands from PHP

PHP’s system() command will let you run command line and shell stuff. It probably requires proper permissions on your ISP configuration.

$last_line = system(‘PATHTO_COMMAND’, $retval);

Why do I need this? For the life of me I can’t figure out how to run a simple shell script through cron.

I saw somewhere that the cron would be something like this but it does not work:

10 * * * `/bin/sh PATHTOSCRIPT`

Inspired by Drupal’s cron.php stuff that runs search indexing, I wrote a PHP script that will run my shell commands. Since the scripts can echo to standard out, the PHP command will print the debugging results to the web page. Now I can check the status of my script without logging in through SSH every time.

There is definitely a better way to do this. Let me know if you can think of something. If anyone knows how to run a shell script (/bin/sh) through cron via cPanel’s cron admin please let me know.

Syndicate content