windows下搭建nginx+php+mysql環境


一、下載需要的東西

1.nginx:http://nginx.org/en/download.html 

2.php:http://php.net/downloads.php

3.mysql:(暫時先不管)

 

二、安裝以及配置

1.配置php:

  將php.ini-development 重命名為 php.ini,對其中的配置進行修改。

  enable_dl = on

  cgi.force_redirect = 0 

  cgi.fix_pathinfo=1

  fastcgi.impersonate = 1

  cgi.rfc2616_headers = 1

  extension_dir = "./ext"(寫絕對路徑也行) 

  啟動php:php-cgi.exe -b 127.0.0.1:9000

2.配置nginx(主要是配置它支持php)

location ~ \.php$ {
            root           F:/wnmp/nginx-1.10.2/html; #這是目錄路徑(默認是寫nginx的html目錄,訪問時出現"Welcome to nginx")
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;#
            include        fastcgi_params;
        }

(1).注意這里的$document_root是root參數值也就是上面的路徑,如果沒有定義,或者注釋了,訪問php時,頁面回提示No input file specified

location / {
            root   F:/wnmp/nginx-1.10.2/html;
            index  index.html index.htm index.php;#這里加入index.php是為了nginx能識別php腳本
        }

啟動nginx:雙擊nginx.exe就行

當php和nginx都啟動的了,你可以使用任務管理器進行查看:

  

有以上的信息,說明nginx和php都啟動成功了,這時候你可以試着打印phpinfo()的php信息,如果顯示了,代表成功了;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM