Ubuntu9.04 already contains nginx, so it is super easy to install it! On VPS, modify the/etc/apt/sources. list file to debhttp: // sources.
Ubuntu 9.04 already contains nginx, so do not compile it at all. The installation is very simple!
Modify the/etc/apt/sources. list file on VPS as follows:
Deb http://ubuntu.cn99.com/ubuntu hard main restricted universe multiverse
Deb http://ubuntu.cn99.com/ubuntu hard-security main restricted universe multiverse
Deb http://ubuntu.cn99.com/ubuntu hard-updates main restricted universe multiverse
Then run:
Apt-get update
Apt-get install nginx
You can complete the installation.
Start nginx:
/Etc/init. d/nginx start
Then you can access http: // 192.168.1.1/. Everything is normal! If it cannot be accessed, do not continue. Check the cause and then continue.
Configure php and mysql below.
Install php and MySQL:
Apt-get install php5-cli php5-cgi mysql-server-5.0 php5-mysql
We need the/usr/bin/spawn-fcgi file, which belongs to the lighttpd package. Therefore, we need to install lighttpd and set it to disabled upon startup:
Apt-get install lighttpd # We only need/usr/bin/spawn-fcgi
Rcconf # Remove lighttpd from startup
Modify the nginx configuration file:/etc/nginx/sites-available/default
Modify server_name 58.30.17.154;
Modify the row of index:
Index. php index.html index.htm;
Remove the following comments:
Location ~ \. Php $ {
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/var/www/nginx-default $ fastcgi_script_name;
Include/etc/nginx/fastcgi_params;
}
Restart nginx:
/Etc/init. d/nginx stop
/Etc/init. d/nginx start
Start fastcgi php:
Spawn-fcgi-a 127.0.0.1-p 9000-C 10-u www-data-f/usr/bin/php-cgi
To enable php-cgi to boot automatically:
Cd/etc/init. d
Cp nginx php-cgi
Vim php-cgi
Replace nginx with php-cgi
And modify the corresponding part:
DAEMON =/usr/bin/spawn-fcgi
DAEMON_OPTS = "-a 127.0.0.1-p 9000-C 10-u www-data-f/usr/bin/php-cgi"
...
Stop)
Echo-n "Stopping $ DESC :"
Pkill-9 php-cgi
Echo "$ NAME ."
Run rcconf to set php-cgi to start automatically
Create an object in the/var/www/nginx-default/directory:
Echo '<? Phpinfo ();?> '>/Var/www/nginx-default/index. php
Then, access nginx in the browser and you will see everything is normal.