I Made Krisna's Times My Way to Write the Times

18Mar/110

Building PHP Webserver on Nginx with PHP CGI

Doesn't like the Apache webserver, nginx didn't have the auto-configuration feature from PHP and library loading. The way to make nginx be a PHP webserver is passing the request to PHP CGI. How?

The first step must be installing the nginx and php5 package. For this post i'm using Ubuntu 10.04 LTS.

apt-get update nginx
apt-get update php5

Check your nginx installation with start the service:

service nginx restart
/etc/init.d/nginx restart

Now, if the nginx working, let's connect it to the PHP CGI. First, run the PHP CGI so that the PHP listen at 127.0.0.1 with port 9000.

/usr/bin/php-cgi -b 127.0.0.1:9000 &

After the CGI is running, go to nginx configuration and make a script pass to PHP CGI.

server
{
	listen 80 default;
	server_name	_;

	root		/var/www/nginx-default;
	index		index.html index.php;

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

Related posts:

  1. Removing ‘index.php’ from CodeIgniter URL
  2. phpMyAdmin + PHP 5.3.x Blank Page Login
  3. Fixing Network Problems Ubuntu 10.04 on Dell Inspiron 14R N4010
  4. Set Up HTTPS/SSL with Apache2.2 for Windows
  5. WordPress 3.0 “Thelonious” Released
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.