統:Windows 7 64位元系統
安裝前,先下載軟體:
Nginx: http://nginx.org/en/download.html
PHP Stable PHP 5.6.26: http://php.net /downloads.php
mysql:http://dev.mysql.com/downloads/utilities/
第一步:在D磁碟建立資料夾Nginx+php+Mysql,路徑為:D:Nginx+php +Mysql
第二步:安裝Nginx,安裝目錄為:D:Nginx+php+Mysqlnginx
1.開啟D:Nginx+php+Mysqlnginx『 .測試是否啟動nginx。打開瀏覽器訪問http://localhost 或 http://127.0.0.1,看看是否出現“Welcome to nginx!”,出現的證明已經啟動成功了。
若啟動不成功,查看是否連接埠被佔用。
安裝PHP,安裝目錄為:D:Nginx+php+Mysqlphp
安裝mySQL,安裝目錄為: D:Ncginx+php+Mymysql
: 我修改目錄Nginx+php+Mysqlnginxconf檔案名稱為:nginx.conf 1. 去掉worker_processes前的#號,開啟一個行程2. 新增events3. 設定一個行程2. 新增測試nginx是否安裝成功
第四步:修改php下php.ini-development文件,將檔案名稱修改為php.ini,找開php.ini: 搜尋「extension_dir」,找到「extension_irextdirext. = "ext" 先到前面的分號再改為 extension_dir = "./ext"
搜尋“php_mysql”,找到:”extension=php_mysql.dll和extension=php_mysqli.dll my 去掉前面的「php_mysionsion= .dll與extension=php_mysqli.dll (支援MYSQL資料庫)
查看php是否安裝成功:
第四步:在php目錄下是否為php-cgi.vbs,用php-cgi.vbsvbs php-cgi:開啟php-cgi.vbs,寫入啟動編碼:#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root d:/Nginx+php+Mysql/nginx/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } }
在啟動項目runServer.bat中輸入:
set wscriptObj = CreateObject("Wscript.Shell") wscriptObj.run "php-cgi -b 127.0.0.1:9000",0
在停止項目中輸入:
@echo off echo Starting nginx... cd %~dp0nginx start "" "./nginx.exe" echo Starting mysql... net start mysql echo Starting PHP FastCGI... cd %~dp0PHP start "" "php-cgi.vbs" pause Exit
最後,查看是否啟動成功:
在nginx的html目錄下新建D:Nginx+php+Mynginx
寫入:@echo off echo Stopping nginx... taskkill /F /IM nginx.exe > nul echo Stopping PHP FastCGI... taskkill /F /IM php-cgi.exe > nul echo Stopping mysql... net stop mysql pause exit在瀏覽器中輸入phpinfo.php的路徑,查看是否配置成功: