重裝多遍。記錄。
一、自己純裝
Nginx 搭配php 要搭配 有php-fpm的。
配置Nginx,樣例:
二、 騰訊云全能鏡像
解決thinkphp5 + Nginx 訪問出現(xiàn)Access denied的方法:
- 配置權(quán)限
chmod -R 777 目錄名 - 改php.ini文件
將cgi.fix_pathinfo的值改成1
vim 進(jìn)入對應(yīng)文件 /cgi.fix到這個(gè)地方,修改成cgi.fix_pathinfo=1-
到nginx.conf中,添加
fastcgi_split_path_info ^(.+\.php)(/.+)$
圖示 到配置域名解析的文件下(一般是以域名命名的配置文件)。加上這三句:
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

圖示
- 最后重啟nginx和php-fpm
systemctl restart nginx.service
systemctl restart php
nginx.conf 樣例:
######################## default ############################
server {
listen 80;
server_name _;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/wwwroot/default;
index index.html index.htm index.php;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip:9000;
# LC add
fastcgi_split_path_info ^(.+\.php)(/.+)$;
##
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
# LC add
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
##
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location ~ /\.ht {
deny all;
}
}
########################## vhost #############################
include vhost/*.conf;
}
測試
我的nginx的root路徑是 /data/wwwroot/default,因此擺一個(gè)名字為phpinfo.php,內(nèi)容為:
<?php
phpinfo()
?>
的php文件。
然后訪問[公網(wǎng)ip]/phpinfo.php
可以看見下面的信息:

php信息
這個(gè)信息表很重要!
配置mongodb時(shí)可以在這里看到是否配置好 mongodb的php擴(kuò)展了。
