Ubuntu has nginx in a very refreshing source, so you only need to run sudoapt-getinstallnginx to start nginx:/etc/init. d/nginxstart and configure php and mysql. Installing php and MySQL: apt-getinstallphp5-cliphp5-cgimysql-server-5.0php5-mysql me
Ubuntu comes with nginx, which requires simple operation.
Sudo apt-get install nginx
You can complete the installation.
Start nginx:
/Etc/init. d/nginx start
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 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;
}
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
Create an object in the/var/www/nginx-default/directory:
Echo "">/var/www/nginx-default/index. php
Then the browser accesses nginx and you can see that everything is normal.