Install Nginx

Install nginx :

# apt-get install nginx

Enable php in nginx.conf :

# nano /etc/nginx/sites-available/default

add these lines :

location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass  127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default$fastcgi_script_name;
}

Install spawn-fcgi :

# wget http://www.lighttpd.net/download/spawn-fcgi-1.6.1.tar.gz

# tar xvzf spawn-fcgi-1.6.1.tar.gz

# cd spawn-fcgi-1.6.1

# ./configure

# make

# make install

# ln -s /usr/local/bin/spawn-fcgi /usr/bin/spawn-fcgi

Configure nginx to recognize php using spawn-fcgi :

# touch /usr/bin/php-fastcgi

# nano /usr/bin/php-fastcgi

Type this :

#!/bin/sh
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -f /usr/bin/php5-cgi

save.

# touch /etc/init.d/init-fastcgi

# nano /etc/init.d/init-fastcgi

Type this :

#!/bin/bash
PHP_SCRIPT=/usr/bin/php-fastcgi
RETVAL=0
case “$1″ in
start)
$PHP_SCRIPT
RETVAL=$?
;;
stop)
killall -9 php
RETVAL=$?
;;
restart)
killall -9 php
$PHP_SCRIPT
RETVAL=$?
;;
*)
echo “Usage: php-fastcgi {start|stop|restart}”
exit 1
;;
esac
exit $RETVAL

Make it work :

# chmod 755 /usr/bin/php-fastcgi

# chmod 755 /etc/init.d/init-fastcgi

Make test file :

# nano /var/www/nginx-default/info.php

Type this :

<?php
phpinfo();
?>

Make it run at start up :

# update-rc.d init-fastcgi defaults

Start nginx and fastcgi :

# /etc/init.d/nginx start

# /etc/init.d/init-fastcgi start

Open from browser :

http://192.168.12.103/info.php

If it work, you’ll see page like this :

nginx-ubuntu

  • Pages

  • Download Ubuntu

  • Download Fedora

  • Tags

    atmail open on ubuntu server change ip address check connection clamav continue install dns dovecot fuzzyocr install jaunty maia mailguard mysql New Virtual Disk Wizard nginx pear php postfix postfixadmin preparation roundcube mail Setting Virtual Machine spamassassin squirrelmail
  • Categories

    • Translate to: