秀米云香港服务器

在apache下用thinkphp做了一个项目倒腾的差不多了,就上传到服务器中测试,结果发现服务器是用的nginx,TP中的模板替换/Public在其他页面中会解析出错,网上了解到是因为nginx的pathinfo是默认没有设置的

为了调试,下午在win下装了一个nginx

序列号 CPU RAM HDD 带宽 售价(美元) 免费试用
香港服务器1 E5-2620 32G 1T HDD 50M/无限流量 $196.00 立即申请
香港服务器2 E5-2650 32G 1T HDD 50M/无限流量 $256.00 立即申请
香港服务器3 E5-2680 32G 1T HDD 50M/无限流量 $316.00 立即申请
香港服务器4 E5-2690 32G 1T HDD 50M/无限流量 $336.00 立即申请
香港服务器5 E5-2697 32G 1T HDD 50M/无限流量 $376.00 立即申请
香港服务器6 E5-2620*2 32G 1T HDD 50M/无限流量 $376.00 立即申请
香港服务器7 E5-2650*2 32G 1T HDD 50M/无限流量 $436.00 立即申请
香港服务器8 E5-2680*2 32G 1T HDD 50M/无限流量 $476.00 立即申请
香港服务器9 E5-2690*2 32G 1T HDD 50M/无限流量 $556.00 立即申请
香港服务器10 E5-2697*2 32G 1T HDD 50M/无限流量 $596.00 立即申请
香港服务器11 E5-2680v4*2 32G 1T HDD 50M/无限流量 $696.00 立即申请
香港服务器12 E5-2698v4*2 32G 1T HDD 50M/无限流量 $796.00 立即申请

如果电脑上已安装过apache,请把它的端口改一下,不要让它与nginx冲突,打开AppServ/Apache2.2/conf/httpd.conf修改67行Listen 80 我改为8080 可以改成任意空闲的端口

然后打开windows下的php.ini文件把476行enable_dl = On前面的分号去掉

然后检查下AppServphp5ext下有没有一个叫php_redis.dll的文件,没有的话下载一个相同版本的扩展文件,并且在php.ini中打开注释601行

这些条件都弄好之后 ,我们可以进行一下的操作 ,首先下载一个nginx放到一个文件夹下取名为nginx

打开我们nginx的配置文件

#location~.php${#roothtml;#fastcgi_pass127.0.0.1:9000;#fastcgi_indexindex.php;#fastcgi_paramSCRIPT_FILENAMEC:/AppServ/www/$fastcgi_script_name;#includefastcgi_params;#}

找到这一段 替换成

location~*.(php[3-9]?|phtm[l]?)(/.*)*${fastcgi_indexindex.php;fastcgi_pass127.0.0.1:9000;includefastcgi_params;set$path_info"";set$real_script_name$fastcgi_script_name;if($fastcgi_script_name~"^(.+?.php)(/.+)$"){set$real_script_name$1;set$path_info$2;}fastcgi_paramSCRIPT_FILENAMEC:/AppServ/www/$fastcgi_script_name;fastcgi_paramSCRIPT_NAME$real_script_name;fastcgi_paramPATH_INFO$path_info;}

http://www.server110.com/我的所有配置都在这里 不妨给大家做个参考nginx全部配置

#user nobody;worker_processes 1;

#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;

#pidlogs/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 127.0.0.1;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {root C:/AppServ/www;index index.html index.htm index.php;}

#error_page404/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;#}#location ~ .php$ {# proxy_passhttp://192.168.1.208:8001;#}# pass the PHP scripts to FastCGI server listening on127.0.0.1:9000#

#location~.php${#roothtml;#fastcgi_pass127.0.0.1:9000;#fastcgi_indexindex.php;#fastcgi_paramSCRIPT_FILENAMEC:/AppServ/www/$fastcgi_script_name;#includefastcgi_params;#}

location~*.(php[3-9]?|phtm[l]?)(/.*)*${fastcgi_indexindex.php;fastcgi_pass127.0.0.1:9000;includefastcgi_params;set$path_info"";set$real_script_name$fastcgi_script_name;if($fastcgi_script_name~"^(.+?.php)(/.+)$"){set$real_script_name$1;set$path_info$2;}fastcgi_paramSCRIPT_FILENAMEC:/AppServ/www/$fastcgi_script_name;fastcgi_paramSCRIPT_NAME$real_script_name;fastcgi_paramPATH_INFO$path_info;}

# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /.ht {# deny all;#}}

# another virtual host using mix of IP-, name-, and port-basedconfiguration##server {# listen8000;# listensomename:8080;# server_name somename aliasanother.alias;

# location / {# roothtml;# index index.htmlindex.htm;# }#}

# HTTPS server##server {# listen443;# server_name localhost;

#sslon;# ssl_certificatecert.pem;# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;

# location / {# roothtml;# index index.htmlindex.htm;# }#}

}

此时差不多配置好了那么我们运行PHP要借助一个AppServphp5下叫php-cgi.exe文件

那么我们怎么用它呢?有一段命令

cd到你appserv在的盘符

cd AppServ/php5/start php-cgi.exe -b 127.0.0.1:9000 -C c:windowsphp.ini

执行上面这段话,成功的话,会跳出一个黑色的窗口,我们不要去动它,如果想省事的话,写一个.bat文件

C:

cdAppServ/php5/startphp-cgi.exe-b127.0.0.1:9000-Cc:windowsphp.ini

然后开启我们的nginx

cd 到nginx目录下

start nginx

nginx -s reload //然后重载一下配置文件

我们写两个.bat文件 一个是开启 一个是停止

stop_nginx.bat

@echooff

echoStoppingnginx...

taskkill/F/IMnginx.exe>nul

echoStoppingPHPFastCGI...

taskkill/F/IMphp-cgi.exe>nul

exit

start_nginx.bat

@echooff

echoStartingPHPFastCGI...

RunHiddenConsolee:/DedeCMS/PHP5/php-cgi.exe-b127.0.0.1:9000-ce:/DedeCMS/PHP5/php.ini

echoStartingnginx...

RunHiddenConsolee:/DedeCMS/nginx.exe

Exit

以上配置完成之后 ,thinkphp就不会出现路径问题了

标题:Windows系统使用Nginx服务器运行thinkPHP程序的路径配

地址: https://www.yunhk.xyz/26386.html