phpstudy在nginx中配置thinkPHP伪静态步骤方法
的有关信息介绍如下:
phpstudy集成环境下在nginx中配置thinkPHP伪静态步骤方法
安装好PHPstudy后,切换环境为PHP+nginx,版本根据自己需要
在PHPstudy【其他选项菜单】中->打开配置文件->选择vhosts-ini(有的是vhosts-conf),用文本编辑器notepad打开
这里我们可以看到我们自己创建的网站配置(当然,没有创建网站的话者这里是没有配置内容的)
因为vhosts里面没有写入伪静态内容,所以我们访问本地thinkPHP的网站的话是访问不了的
这里我们加入thinkPHP的伪静态内容
内容如下:
# 伪静态配置
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
############
注意加入的位置不能错!!!!
如果未创建网站,可以直接复制下面内容到vhosts-ini中:
server {
listen 80;
server_name www.b1.com b1.com;#填你第8步dns解析,配置的虚拟域名
root "D:\phpStudy\PHPTutorial\WWW\b1";#填你网站所在目录
location / {
index index.html index.htm index.php;
#autoindex on;
######伪静态配置########
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
######伪静态配置########
}
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;
}
}
DNS解析:在C:\Windows\System32\drivers\etc下打开hosts,加入你配置的域名解析到本地的代码 例如:
重启PHPstudy环境,再刷新页面,这时,我们就能看到本地的thinkPHP项目能访问了



