nginx1.8.0 configuration (with centos6.5+nginx+php5.6 renewal).

Source: Internet
Author: User
Tags phpinfo nginx server

Because in the "collocation centos6.5+nginx+php5.6" article did not mention some of Nginx's common configuration, write a continuation of Nginx support PHP configuration from the Iteye article, http://ears.iteye.com/blog/ 1896542 thanks in this 1. Make Nginx support PHP 1). Under Server nginx.conf, add the following, Script_filename is your Nginx directory 2). Then restart PHP-FPM and Nginx (the support principle is to let the file end to PHP request, sent to 9000 port, and 9000 port is php-fpm default port PS: Can change) 3). Then in the Nginx HTML directory to write the file as index.php, in which write Phpinfo () to see if it can parse the specific directory to see your configuration, nginx default access to the directory under HTML 7. Change the configuration of the PHP-FPM the general installation of PHP will change p HP configuration, because some will be error, such as Date.timezone, and PHP-FPM after the installation of its php.ini files need to move their own, the following we will start to do 1). Print Phpinfo to see where the php.ini needs to be stored 2). Back to PHP compiled files directory (PS: note is the directory of the PHP-FPM you compiled!) Copy this file (PS: If you do not have this file you may be in the wrong directory) 4). Then let's change something to verify that it works. Open it and modify the Date.timezone 5). Restart PHP-FPM (PS: Restart Ngi      NX is useless, for the reasons explained above) 6). Look Phpinfo (), search Date.timezone, is not already good? And the loaded configuration file is also loaded in 2. Add Nginx Virtual Host (PS: Originally wanted to write a reference link, but that article I test many times can not pass .....) ) 1). Enter the Nginx conf directorycd/usr/local/nginx/conf2). Since the nginx default is no Vhost file, you need to create, of course, the name of the creation you can choose, but generally will be created as Vhostmkdir vhost3). Open the Nginx.conf configuration file and write the following command (PS: note is under HTTP) 4). Under the Vhost file configuration file (create a file name that is similar in format to www.xxx.com.conf, which is generally named) said a very funny thing ... Create a file is touch, the author here to create Vhost mkdir www.xx.com.conf .... Then save the configuration on the is a directory error ..., once this error occurs, your configuration needs to be written in the file, not the directory ... If you type the following code
1 server {2Listen 80;3 server_name www.xxx.com;4   #CharSet koi8-r;5 6   #access_log Logs/host.access.log main;7root/home/www-data/www.xxx.com;#requested directory PS: In general, nginx,mysql,php will be assigned to separate users, root privileges are too high8 9Error_page 404/404. html;Ten  One   #Redirect Server error pages to the static page/50x.html A   # -Error_page 500 502 503 504/50x.html; -Location =/50x.html { the  -   } -  - #Default Request +Location/ { -   if(!-E$request _filename) { +Rewrite ^/(. *) $/index.php/ $Last ; A    Break; at   } - index index.php index.html; - } - #The request contains a. PHP -Location ~. +\.php ($|/) { -Fastcgi_pass 127.0.0.1:9000; in Fastcgi_index index.php; - include Fastcgi_params; toSet$real _script_name $fastcgi _script_name; +   if($fastcgi _script_name~"^ (. +?\.php) (/.+) $") { -Set$real _script_name  $; theSet$path _info  $; *   } $Fastcgi_param Script_filename$document _root$real_script_name;Panax NotoginsengFastcgi_param Script_name$real _script_name; -Fastcgi_param Path_info$path _info; the } +  A   #Let the client (browser) cache the picture for 30 days the   #Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $ +   #{ -   #expires 30d; $   #} $  -   #Let the client (browser) cache JS and CSS files for 1 hours -   #Location ~. *\. (JS|CSS)? $ the   #{ -   #expires 1h;Wuyi   #} the}
View Code

5). On this computer, the hosts will point the domain name to the IP of the Nginx server (or curl your domain directly)

  

  

PS: This domain name is nginx server virtual domain name (please disregard this sentence) in the virtual domain name of the settings directory to write a index.php file, and then write Phpinfo (); If access to the domain name can appear phpinfo, it proves successful.

nginx1.8.0 configuration (with centos6.5+nginx+php5.6 renewal).

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.