Install Nginx + PHP + MySQL on Ubuntu
sudo apt-get install nginx
After Ubuntu is installed, the file structure is roughly as follows:
All configuration files are under/etc/nginx, and each virtual host is already under/etc/nginx/sites-available.
Program file in/usr/sbin/nginx
Logs are stored in/var/log/nginx.
The startup script nginx has been created under/etc/init. d /.
The default virtual host directory is/var/www/nginx-default.
[Edit] start nginx
sudo /etc/init.d/nginx start
Then you can access http: // localhost/. everything is normal! If it cannot be accessed, do not continue. check the cause and then continue.
[Edit] configure php and mysql
[Edit] install Php and mysql
Install php and MySQL:
sudo apt-get install php5-cli php5-cgi mysql-server php5-mysql
[Edit] FastCgi installation
The/usr/bin/spawn-fcgi file is used to manage FastCgi. it originally belongs to the lighttpd package, but after 9.10, spawn-fcgi is separated into a separate package:
sudo apt-get install spawn-fcgi
[Edit] Configure nginx
Modify the nginx configuration file:/etc/nginx/sites-available/default modify the host name:
server_name localhost;
Modify the row of index:
index index.php index.html index.htm;
Remove the following comments to support php scripts:
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 create and test phpinfo at startup:
sudo vi /var/www/nginx-default/info.php
Open http: // localhost/info. php.