1 , update
2. Installing nginx
1 |
sudo apt-get intsall nginx |
the file structure of Ubuntu after installation is roughly :
* all configuration files are under /etc/nginx , and each virtual host is already scheduled for /etc/nginx/ Sites-available under
* Program Files in /usr/sbin/nginx * log in /var/log/nginx
* and already created a startup script under/etc/init.d/. nginx
* The Default virtual host directory is set to /var/www/nginx-default
Below you can start the nginx Look at the effect ( Please make sure that the port is not used by other services ):
1 |
Sudo/etc/init.d/nginx start |
# or a simple
Then open the browser and see http://localhost/ See If you see "Welcome to nginx! " If you see the , indicates successful installation .
Of course , There's no problem with this piece of cake . If the run is unsuccessful , can first
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 the php-cgi process , to prevent a process from collapsing or the efficiency of a single process is too low .
Many people on the internet have said that to use spawn-fcgi must be installed lighttpd, In fact, not necessary , can be directly installed spawn-fcgi
Run :
1 |
sudo apt-get install spawn-fcgi |
5. Configuration
The next is the most frustrating configuration .
Configuring Nginx and spawn-fcgi to run together
(1). in the /etc/nginx/fastcgi_params file Last , Join a row , can be used
1 |
sudo vi/etc/nginx/fastcgi_params |
Join this line :
1 |
Fastcgi_param script_filename $document _root$fastcgi_script_name; |
(2). In addition, you need to php-cgi the configuration file ( This profile is located in /etc/php5/cgi/php.ini on Ubuntu) in , Find Cgi.fix_pathinfo Options , modified to :
This allows the php-cgi to use the script_filename variable normally .
(3). Open /etc/nginx/sites-available/default file in
123 |
server {listen 80;server_name localhost; |
The absolute address of the Web root is added below , here is the default address of Nginx
1 |
Root/var/www/nginx-default |
That is, the root and server_name peers, which is equivalent to the Apache default directory
If this is not the case , it is easy to execute the php file , it will prompt "no input File specified".
I've been around a great circle before I found out the problem . and then modify
123456 |
#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
1234 |
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; # contains the fastcgi parameter file address
6. Start fast_cgi Process
1, 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. Pid
7. Set boot fastcgi process and start
Add next line
1 |
/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 the Open php file appears : No input files specified Please check The configuration of php.ini
Also , each virtual machine according to their own different virtual machines set up a different directory , to ensure that the path is correct .
Check the configuration file under /etc/nginx/sites-available , the server contains root and address rather than Location within the Root
Start
1 |
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 means the following
*-f Specifies the execution location of the process that called FastCGI , According to the system installed on the PHP case Specific Settings
*-a bind to address addr
*-P bind to port Port
*-S bound to the path of the UNIX socket path
*-C Specifies the resulting FastCGI Number of processes , default to 5 ( for PHP only)
*-P Specifies the resulting process's PID file path
*-u and -G FastCGI What identity is used (-u user -G user Group ) run , under Ubuntu , you can use www-data, other configurations as appropriate , such as Nobody , Apache , etc. you can now have a probe or in the Web root directory PHP file test it
8 , install mysql
1 |
sudo apt-get install mysql-server mysql-client |
The middle will prompt for the Root user password , and then enter it .
Start MySQL
1 |
Sudo/etc/init.d/mysql start |
Test that the MySQL service is working :
Run
Enter mysql password
If you see the following content
| Database |
| Information_schema |
| MySQL |
Then MySQL is installed correctly .
At this point , the nginx+php+mysql under ubuntu is installed .
http://www.bkjia.com/PHPjc/326928.html www.bkjia.com true http://www.bkjia.com/PHPjc/326928.html techarticle 1, Update 1 sudoapt-getupdate 2, install Nginx 1 sudoapt-getintsallnginx after installation of Ubuntu file structure is roughly: * All the configuration files are under/etc/nginx, and each Virtual ...