hb php端口配置,lnmp1.4环境下thinkphp3.2配置pathinfo模式

1、打开php.ini

通常该文件在 /usr/local/php/etc/php.ini

vi /usr/local/php/etc/php.ini

找到 cgi.fix_pathinfo,默认为0,修改为1,保存退出;

5829118697c7949d30140454d706d9e3.png

2、打开nginx.conf配置文件

通常该文件在 /usr/local/nginx/conf/nginx.conf

vi /usr/local/nginx/conf/nginx.conf

(1)找到 include enable-php.conf;注释掉,在下面一行添加include enable-php-pathinfo.conf;

0dd6c5ad63526c5ef0b8933000afcb28.png

(2)添加以下代码,并保存退出

#Rewrite模式

location / {

index index.htm index.html index.php;

if (!-e $request_filename) {

rewrite ^/(.*)$ /index.php/$1 last;

break;

}

}

#pathinfo模式

location ~ \.php/?.*$ {

root /home/wwwroot/default;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;

#设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量

set $fastcgi_script_name2 $fastcgi_script_name;

if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {

set $fastcgi_script_name2 $1;

set $path_info $2;

}

fastcgi_param PATH_INFO $path_info;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;

fastcgi_param SCRIPT_NAME $fastcgi_script_name2;

}

(3)重启nginx

service nginx restart

这样就可以用pathinfo模式访问了

提示:项目中必须设置’URL_MODEL’ => 1才能用pathinfo模式访问

当设置’URL_MODEL’ => 2时,也可以用Rewrite模式访问

Nginx设置虚拟主机,添加多站点

nginx.conf中添加include vhost/*.conf;

8b186b0a0a4520040ef0b5b25d97fc4a.png

添加一个站点信息:

在vhost中添加一个 xxx.conf的文件  大致内容如下:

server {

listen 80;

server_name my.nginx1.com;

root /home/wwwroot/default/nginx1;

index index.html index.php index.htm;

error_page 400 /errpage/400.html;

error_page 403 /errpage/403.html;

error_page 404 /errpage/404.html;

include enable-php-pathinfo.conf;

location ~ \.php$ {

try_files $uri =404;

fastcgi_pass unix:/tmp/php-cgi.sock;

fastcgi_index index.php;

include fastcgi.conf;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值