Configuration of nginx+php+fastcgi under Win7

Source: Internet
Author: User

load PHP First1, from the www.php.net download PHP corresponding version 2, after decompression put to the C disk (in fact, it does not matter, Apache will have a configuration point, but Nginx not) 3, Because of the 5.3.17 version, already have php-cgi.exe this, do not have to do other things so start to change the configuration of PHP, first php.ini-development this file renamed to PHP.ini, and some version of the INI followed by other, are changed to. ini4 , open php.ini file, modify: config: extension_dir = "Write your ext folder path here"; This path is the path to the extension library Upload_tmp_dir = "Write your upload cache directory here"; Upload a picture of the cache here Sessio N.save_path = "Write your session cache directory here"; This is stored as a file sission, if the database storage session requires additional configuration open the following extensions: extension=php_curl.dllextension= Php_gd2.dllextension=php_mbstring.dllextension=php_mysql.dllextension=php_mysqli.dllextension=php_pdo_ Mysql.dllextension=php_pdo_odbc.dllextension=php_pdo_sqlite.dllextension=php_xmlrpc.dll Define the time zone (I define the Shanghai time zone): Date.timezone = Asia/shanghai because nginx requires CGI mode PHP, but also to modify the following configuration Enable_dl = Oncgi.force_redirect = 0cgi.fix_pathinfo=1fastcgi.impersonate = 1cgi.rfc2616_headers = 1 Configure Nginx:1, from the http://nginx.org download Nginx, in short from the official online next, whether the official website is changed address, it seems 1.3.7 is not divided into 32-bit or 64-bit. 2, after decompression put C disk under (put elsewhere should also become, accustomed to ...) 3. Open conf, change nginx.conf open log directory: Error_log logs/error.log; change other configuration Server {         listen       8080; #因为装了Apache已经占用了80接口          server_name  localhost;        charset Utf-8; #默认文件编码          #charset koi8-r;           #access_log  logs/host.access.log  main;          location/{            root   d:/ Nginxweb; #这里改成你自己的虚拟目录, pay attention! Nginx1.3.7 and the following versions do not support the file path has spaces in the middle and does not support Chinese!!! This above version does not know will support, but the following is not supported ... Although Apache supports ah ...             index  index.html Index.htm index.php; #注意这里添加了index. php, if not added this has the potential to report 403 error, this is win under, Linux or other system will have this problem unknown. AutoIndex on; #如果文件不存在, List directory tree structure         }          #error_page  404               /404.html;         # Redirect Server error pages to the static page /50x.html        #         Error_page   500 502 503 504  /50x.html;        location =/ 50x.html {            root   html;         }         # Proxy The PHP Scripts to Apache listening on 127.0.0.1:80        #          #location ~ \.php$ {        #    proxy_pass   http://127.0.0.1;         #}         # Pass the PHP scripts to FastCGI Server listening on 127.0.0.1:9000        #         location ~ \.php$ {             Fastcgi_pass   127.0.0.1:9000; #fastcgi监听的端口, with PHP specified at the time of CGI startup to be consistent              fastcgi_index  index.php; #默认首页              fastcgi_param  script_filename  d:/nginxweb$fastcgi_script_name;# To start the path, just change the "d:/nginxweb" section to your installation path              include        fastcgi_params;         }         # deny access to. htaccess files, if Apache ' s document root         # concurs with Nginx ' s one         #         #location ~/\.ht {         #    deny  all;        #}     }  operation: 1, the first to run PHP CGI, because I use the win7 system, so CMD advanced C-disk (before all throw C disk this simple ~), access to the PHP path, input php-cgi.exe-b 127.0.0.1:9000 note here that the-B 127.0.0.1:9000 is the specified CGI listener port, consistent with the Nginx configuration above, if there are other configurations do not remember before php-cgi is that port, you can use Php-cgi.exe- H command to view the configuration (see <address:port> after-B). Want to see all the ports being monitored input netstat-na 2, run Nginx to open a terminal, access to the Nginx folder, input nginx.exe  keep two terminals do not shut down, access to the virtual directory files accessed by the browser.   how to automatically close cmd after running:1, download RunHiddenConsole.exe (http://redmine.lighttpd.net/attachments/660/RunHiddenConsole.zip) 2, create Start_ Php.bat, to start PHP, the file contents are as follows: @echo off
echo Starting PHP FastCGI ...
RunHiddenConsole.exe d:\php\php-cgi.exe-b 127.0.0.1:9000-c D:\php\php.ini3, creating Stop_ Nginx.bat, to close the PHP and Nginx process, the file contents are as follows: @echo off
echo Stopping Nginx ...
taskkill/f/im nginx.exe > nul
echo Stopping PHP FastCGI ...
taskkill/f/im php-cgi.exe > nul
Exit Related issues:1, 403 Error: The index configuration in nginx.conf is not joined Index.php is one of the causes of 403 errors 2, cmd run Nginx.exe error may be nginx path has Chinese, special symbols, spaces-- Although Windows allows this to be named, but Nginx will error (such as the previous spit slot, Apache can, why Apache to focus on allowing space and Chinese as a path rather than improve the other Ah ... ), it is possible that the Nginx virtual path of the file stored in the Chinese name may also cause Nginx to not run. 3, Nginx can run and parse HTML but unable to parse PHP, this time to see whether php-cgi.exe up, but also to see the nginx.conf in the listening port and php-cgi listening port is consistent, as described in the above configuration, there are many ways to view.

Configuration of nginx+php+fastcgi under Win7

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.