1, update
sudo apt-get update
2. Installation Nginx
sudo apt-get intsall nginx
After Ubuntu installation, the file structure is roughly:
* All configuration files are under/etc/nginx, and each virtual host has been placed under/etc/nginx/sites-available
* Program Files in the/usr/sbin/nginx * log in the/var/log/nginx
* and a startup script has been created under/etc/init.d/nginx
* The default virtual host directory is set to/var/www/nginx-default
The following can start Nginx to see the effect (please make sure that 80 ports are not using any other service):
Sudo/etc/init.d/nginx start
#或者简单的
Service Nginx Start
Then open the browser and check http://localhost/to see if the "Welcome to nginx!" is seen, indicating that the installation was successful.
Of course, basically, this piece of the child will not be a problem. If the operation is unsuccessful, you can first
sudo killall apache2
Kill the Apache Process
3. Install PHP
sudo apt-get install php5 php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5 -memcache php5-mhash php5-ming Php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-sqlite php5-xsl
4. Installation spawn-fcgi
Why install spawn-fcgi, which is used to control php-cgi processes to prevent process crashes or inefficient single processes.
Many people on the internet have said that to use spawn-fcgi must have to install LIGHTTPD, actually not necessary, can be directly installed spawn-fcgi
Run:
sudo apt-get install spawn-fcgi
5, configuration
The next is the most annoying configuration.
Configure Nginx and spawn-fcgi to run together
(). At the end of the/etc/nginx/fastcgi_params file, add a line that you can use
sudo vi/etc/nginx/fastcgi_params
Join this row:
Fastcgi_param Script_filename Documentrootfastcgi_script_name;
(2). In addition, you need to find the Cgi.fix_pathinfo option in the php-cgi configuration file (this profile is located in/etc/php5/cgi/php.ini on Ubuntu), and modify it to:
cgi.fix_pathinfo=;
This allows the php-cgi to normally use the script_filename variable.