windows 下XAMPP 使用Nginx替代apache作为服务器
說實(shí)話, 在windows下使用Nginx 著實(shí)有點(diǎn)不太方便, 但因項(xiàng)目需求, 又不想換系統(tǒng)(雖然可以搞個(gè)虛擬機(jī)玩), 只能用Nginx了
好了, 不多說了. 開始...
首先我用的是xampp包(Apache+Mysql+php+perl) 用的是3.2.2版, 這里各自喜歡...不多說
一般我是把xampp安裝在D:\xampp下的...
首先去下載一個(gè)Nginx的包.. 戳這->http://nginx.org/en/download.html? 有三個(gè)版的(Mainline version / Stable version / Legacy versions?) ?我是下了個(gè)穩(wěn)定版的 即Stable version ,不要問為什么, 因?yàn)榉€(wěn)定!
下完后就可以解壓至D:\xampp\nginx 了... 如圖:
這里得去php文件夾那里, 把那個(gè)php.ini Copy一份, 命名為php-cli.ini 這個(gè)就是為了給Nginx玩的. 而不會(huì)影響Apache 的使用....
好了. 到這里, 就打開php-cli.ini(建議文本器打開)
配置一下下面幾個(gè) 直接查找就行了::
enable_dl = On;
cgi.force_redirect = 0;
cgi.fix_pathinfo=1;
fastcgi.impersonate = 1;
cgi.rfc2616_headers = 1;
?
OK 現(xiàn)在就可以打開nginx.exe了?
(這里的-b 應(yīng)該是 -a 和 -p 的集合...吧)
然后再開一個(gè)cmd 下輸 D:\xampp\nginx\nginx
?
這里有點(diǎn)麻煩就是, 如果掛了. 就得重新打開一個(gè)cmd...?D:\xampp\nginx\nginx -s reload
也可以這樣處理, 關(guān)閉Nginx?
taskkill /F /IM nginx.exe > nul
taskkill /F /IM php-cgi.exe > nul
建議如果是改了配置的話, 得先使用 nginx -t 測(cè)試看有沒有報(bào)錯(cuò). 再reload 或者其它操作
還有我看了下網(wǎng)上說的, 可以借助RunHiddenConsole?來管理Nginx (這里我沒試過, 有空得搞搞)
注意: nginx不能和apache 同時(shí)使用, 因?yàn)樗麄兡J(rèn)都使用同一個(gè)端口 所以你開nginx得把a(bǔ)pache干掉
Nginx 配置:
打開nginx\conf\nginx.conf
這里我是直接引入了文件夾去找其它的配置
像這樣(-^-)
include web/*.conf;?
location / {
root D:/xampp/htdocs/;
index index.html index.htm index.php;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
}
location ~* \.php$ {
root D:/xampp/htdocs/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
配置根站點(diǎn)...
還有配置一下那個(gè)phpmyadmin
location = /phpmyadmin/ {
root D:/xampp/;
index index.php index.html index.htm;
}
location ~* /phpmyadmin/.*\.php {
root D:/xampp/;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME D:/xampp/$fastcgi_script_name;
}
?重新加載配置>>>D:\xampp\nginx\nginx -t >>>?D:\xampp\nginx\nginx -s reload
配域名的話這里就不寫了. 不會(huì)的話, ?www.baidu.com?是個(gè)好東西.
?
轉(zhuǎn)載于:https://www.cnblogs.com/wherein/p/6225705.html
總結(jié)
以上是生活随笔為你收集整理的windows 下XAMPP 使用Nginx替代apache作为服务器的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 每天计划
- 下一篇: 常用的meta标签总结