我的服务器是使用nginx做反向代理,nginx监听了443和80端口,同时使用了XAMPP部署了可道云,XAMPP使用的是Apache做服务器,这时已经不能监听443和80端口了,只能监听其他端口,然后访问的时候带端口号访问,或者设置隐式链接,这样不太方便,而且经常会有奇奇怪怪的错误,所以只好把XAMPP的Apache换成nginx.
先把nginx服务器放到XAMPP目录下,然后打开php文件夹,复制一份php.ini文件到同目录命名文php-cli.ini,然后修改php-cli.ini的以下配置
1 2 3 4 5
| enable_dl = On cgi.force_redirect = 0 cgi.fix_pathinfo=1 fastcgi.impersonate = 1 cgi.rfc2616_headers = 1
|
然后运行php-cgi
1
| php-cgi.exe -b 127.0.0.1:9000 -c D:\xampp\php\php-cli.ini
|
回到nginx目录,打开conf文件夹,修改nginx.conf的server配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| eoserver { listen 80; server_name root location / { index index.php; autoindex on; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } }
error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }
|
现在打开nginx服务器,网页已经可以正常访问,但是现在运行了两个nginx服务器,虽然不是不行,但是总会有点别扭,而且有时候会和另外一个nginx服务器冲突,我们可以把两个nginx服务器的合并起来
将新的nginx下的htdocs目录复制到旧的nginx下,然后修改旧的nginx的nginx.conf配置文件,添加这个server配置,我给它配置了ssl,如果没有需求可以不用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| server { listen 443 ssl; server_name
ssl_certificate ssl_certificate_key
ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on;
root location / { index index.php; autoindex on; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }
|
修改之后
打开C:\Windows\System32\drivers\etc文件夹下的hosts文件,在最下面添加
修改完成后,关闭新的nginx服务器,在旧的nginx服务器下
重新加载后就可以正常访问了
由于php-cgi现在是自己手动运行的,如果可道云出现了错误,php-cgi可能会关闭程序,我们还需要手动运行php-cgi