In general, we are using Apache as a PHP parsing server, this time is the use of Nginx this powerful reverse proxy server to build PHP server. The following is a Linux distribution version of Ubuntu as an example to build a nginx PHP server.
First Download Install Nginx
sudo apt-get install nginx
When the installation is complete, start the Nginx
sudo /etc/init.d/nginx start
This time open the browser input http://localhost/can see Welcome to nginx! page, indicating that our Nginx server installation success
Next Install PHP5
sudo apt-get install php5-fpm
After the installation is successful, we will modify the Nginx virtual machine configuration so that the PHP file requested by the browser can be parsed by PHP CGI. Edit Nginx Virtual machine configuration file/etc/nginx/sites-available/default
sudo vim /etc/nginx/sites-available/default
Then change the configuration to the following configuration content:
# you could add here your# server {# ... #}# statements for each of the your virtual hosts to this file### your should look at The following URL ' s in order to grasp a solid understanding# of Nginx configuration files in order to fully unleash the PO Wer of nginx.# http://wiki.nginx.org/Pitfalls# http://wiki.nginx.org/QuickStart# http://wiki.nginx.org/ configuration## generally, you'll want to move this file somewhere, and start with a clean# file but keep this around fo R reference. Or just disable in sites-enabled.##-see/usr/share/doc/nginx-doc/examples/for more detailed examples.# #server { Listen 80; # # Listen for IPv4; This is the default and implied #listen [::]:80 default Ipv6only=on; # # Listen for IPv6 root/usr/share/nginx/www; Index index.html index.htm index.php; # make site accessible from http://localhost/server_name localhost; Location/{# First attempt-serve request as file, then # as directory, then fall back to index.html Try_files $uri $uri//index.html; # Uncomment to enable Naxsi in this location # Include/etc/nginx/naxsi.rules} location/doc/{Alias /usr/share/doc/; AutoIndex on; Allow 127.0.0.1; Deny all; # Nginx-naxsi:process denied requests #location/requestdenied {# For example, return an error Code #return 418; #} Error_page 404/404.html; # REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.html; Location =/50x.html {root/usr/share/nginx/www; # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ {Fastcgi_split _path_info ^ (. +\.php) (/.+) $; # note:you should has "cgi.fix_pathinfo = 0;" In php.ini # with php5-cgi alone:fastcgi_pass 127.0.0.1:900 0; # with PHP5-FPM: #fastcgi_pass Unix:/var/run/php5-fpm.sock; Fastcgi_index index.php; Include Fastcgi_params; } # Deny access to. htaccess files, if Apache's document root # concurs with Nginx ' s one # location ~/\.ht { Deny all; }}# Another virtual host using mix of ip-, name-, and port-based configuration# #server {# listen 8000;# listen Somenam e:8080;# server_name somename alias another.alias;# root html;# index index.html index.htm;## location/{# Try_files $uri $uri//index.html;#}#}# HTTPS server# #server {# listen 443;# server_name localhost;## root html;# Index index.html index.htm;## SSL on;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;## ssl_session_ti Meout 5m;## ssl_protocols SSLv3 tlsv1;# ssl_ciphers all:! Adh:! export56:rc4+rsa:+high:+medium:+low:+sslv3:+exp;# ssl_prefer_server_ciphers on;## location/{# Try_files $uri $ uri//index.html;#}#}
Reload the Nginx configuration we just changed
sudo /etc/init.d/nginx reload
Then we create a new phpinfo.php file in the/usr/share/nginx/www/directory to view the configuration and environment information of PHP
sudo vim /usr/share/nginx/www/phpinfo.php
Enter the following in the phpinfo.php:
We enter http://localhost/in the browser Phpinfo.php can see the PHP information page, there is a version and other information.
PHP5 there are a lot of supported modules, you can choose to install if necessary, Generally these modules are php5-beginning, such as Php5-mysql, install him in Ubuntu just
sudo apt-get install Php5-mysql
PHP module after installation do not forget to restart PHP5 Oh, Perform the following command to restart the
sudo/etc/init.d/php5-fpm restart
The above describes the use of Nginx to build a PHP server, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.