1, update
Www.jb51.net
Copy Code code as follows:
2. Installation Nginx
Copy Code code as follows:
sudo apt-get intsall nginx
After Ubuntu installation, the file structure is roughly:
* All configuration files are under/etc/nginx, and each virtual host is scheduled under/etc/nginx/sites-available www.jb51.net
* 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):
Copy Code code as follows:
Sudo/etc/init.d/nginx start
#或者简单的
Copy Code code as follows:
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
Copy Code code as follows:
Kill the Apache Process
3. Install PHP
Copy Code code as follows:
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:
Copy Code code as follows:
sudo apt-get install spawn-fcgi
5, configuration
The next is the most annoying configuration.
Configure Nginx and spawn-fcgi to run together
(1). At the end of the/etc/nginx/fastcgi_params file, add a line that you can use
Join this row:
Fastcgi_param script_filename $document _root$fastcgi_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:
This allows the php-cgi to normally use the script_filename variable.
(3). Open/etc/nginx/sites-available/default file in
server {
listen;
server_name localhost;
Add the absolute address of the Web root directory below, using the default address of Nginx
Root/var/www/nginx-default
That is, the root and server_name siblings, which is equivalent to Apache's default directory
If this is not the case, it is easy to execute the PHP file, will prompt "no input file specified."
I've been around a lot of circles to find out. And then modify
#location ~ php$ {
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
#fastcgi_param Script_filename/scripts$fastcgi_script_name;
#includefastcgi_params;
#}
Modified into
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; #包含fastcgi的参数文件地址
6. Start fast_cgi Process
Sudo/usr/bin/spawn-fcgi-a 127.0.0.1-p 9000-c 5-u www-data-g www-data-f/usr/bin/php5-cgi-p/var/run/fastcgi-php.pi D
7, set up the boot fastcgi process and start
Add next line
/usr/bin/spawn-fcgi-a 127.0.0.1-p 9000-c 5-u www-data-g www-data-f/usr/bin/php5-cgi-p/var/run/fastcgi-php.pid
If open php file appears: No input file specified please check php.ini configuration
Cgi.fix_pathinfo=1
doc_root=
Also, each virtual machine according to their own different virtual machines set up a different directory, to ensure that this path is correct.
Check the configuration file under/etc/nginx/sites-available, Server contains root and address instead of root in location
Start
Fast-cgisudo/usr/bin/spawn-fcgi-a 127.0.0.1-p 9000-c 5-u www-data-g www-data-f/usr/bin/php5-cgi-p/VAR/RUN/FASTCG I-php.pid
The parameter meaning is as follows
*-f Specifies the location of the executing program that invokes the FASTCGI process, depending on what PHP is installed on the system
*-a binding to address addr
*-P is bound to ports port
*-S path to a UNIX socket
*-c Specifies the number of fastcgi processes generated, default is 5 (PHP only)
*-p Specifies the PID file path of the resulting process
*-U and-g fastcgi to use what identity (-u user-G user group) to run, Ubuntu can use Www-data, other according to the situation configuration, such as nobody, Apache, etc. can now be placed in the Web root of a probe or PHP file test
8, install MySQL
sudo apt-get install mysql-server mysql-client
You will be prompted to enter the root password and enter it in turn.
Start MySQL
Sudo/etc/init.d/mysql start
Test the MySQL service is normal:
Run
Mysql-uroot-p
Enter MySQL password
show databases;
If you see what's underneath
| Database |
| Information_schema |
| MySQL |
MySQL is installed correctly.
At this point, the Nginx+php+mysql under Ubuntu is complete.