lnmp一键安装包 nginx 配置thinkphp5或thinkcmf5
2022-05-31Linux
新增虚拟主机后,需要修改网站站点配置文件,例如 vim /usr/local/nginx/conf/vhost/web.thinkcmf.com.conf。下面以nginx 配置安装 thinkcmf5 为例,站点域名为:web.thinkcmf.com
新增虚拟主机后,需要修改网站站点配置文件,例如 vim /usr/local/nginx/conf/vhost/web.thinkcmf.com.conf
下面以nginx 配置安装 thinkcmf5 为例,站点域名为:web.thinkcmf.com
一、配置文件修改成如下
server
{
listen 80;
#listen [::]:80;
server_name web.thinkcmf.com;
index index.html index.htm index.php default.html default.htm default.php;
# 网站目录,需要写在public目录下
root /home/wwwroot/web.thinkcmf.com/public;
include none.conf;
# error_page 404 /404.html;
# Deny access to PHP files in specific directory
# location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
# include enable-php.conf;
include enable-php-pathinfo.conf;
# 将url中server_name之后的部分与 /thinkcmf/public/* 匹配 如果匹配则改写URl为/thinkcmf/public/index.php/*
# lnmp一键安装包可直接 include thinkphp.conf
location / {
index index.html index.htm index.php;
# autoindex on; # nginx默认是不允许列出整个目录的。如需此功能,将注释打开
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~ \.php(.*)$ {
# 请填写自己的路径,如果不知道 php-cgi.sock的目录,请输入 find / -name php-cgi.sock 这条命令查找
fastcgi_pass unix:/tmp/php-cgi.sock;
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;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/web.thinkcmf.com.log;
}
修改配置文件修改后,需要加载nginx配置文件
/usr/local/nginx/sbin/nginx -s reload
二、若网页出现 Access denied.

在文件有读写权限的前提下 修改 php.ini
# 将 cgi.fix_pathinfo=0 改成 cgi.fix_pathinfo = 1 cgi.fix_pathinfo = 1
三、然后重启 php 和nginx , 熟悉的界面就出现了!

很赞哦! ()
