Just to the company configuration Ununtu PHP Environment, the first use of Php+apache, installation is very simple, do not need any configuration. On the internet to see Nginx good, found a lot of sites are used Nginx. So, the Apache removed, installed Nginx. That's a dress, my heart is broken.
Installation Nginx, very simple: sudo apt-get install Nginx
Then install Php+mysql, also very simple: Apt-get install php5-cli php5-cgi mysql-server-5.0 php5-mysql
Because it takes fast-cgi to connect Php+nginx, we need to install it. We just need to install the LIGHTTPD, and then extract the fast-cgi from the inside separately:
sudo apt-get install lighttpd
RCONF//Here is the boot configuration, remove the LIGHTTPD boot automatically
Then configure the Nginx configuration file, the new version under/etc/nginx/conf, open nginx.conf:
server_name xxx.xxx.xx.xxx;//your host address, if you need to change the port on the above change listen
Location/{
root/var/www;//root directory
Index index.php index.html index.htm//support PHP file
}
Location ~ \.php$ {
root/var/www;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/var/www$fastcgi_script_name;
Include Fastcgi_params;
}
Then restart Nginx, generally sudo/etc/init.d/nginx restart I installed a new version of Ms No, use sudo/etc/nginx/sbin/nginx-s reload
Start fast-cgi
Spawn-fcgi-a 127.0.0.1-p 9000-c 10-u www-data-f/usr/bin/php-cgi
How to let PHP fast-cgi restart, then we need to/etc/init.d/under the Nginx under the php-cgi copy, the new version does not seem to modify INIT.D under the php-cgi:
Path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
daemon=/usr/bin/spawn-fcgi
Daemon_opts= "-A 127.0.0.1-p 9000-c 10-u www-data-f/usr/bin/php-cgi"
name=php-cgi
Stop
Echo-n "Stopping $DESC:"
Pkill-9 php-cgi//mainly kill the php-cgi process
echo "$NAME."
;;
desc=php-cgi
Then run rconf, set php-cgi boot up
And then basically it's almost there. PHP configuration file in/etc/php5/cgi under the Php.inil, modified to restart the php-cgi:
sudo/etc/init.d/php-cgi start
sudo/etc/init.d/php-cgi stop
Last input in browser see success