git clone https://github.com/top-think/think tp5
cd tp5 && checkout master
git clone https://github.com/top-think/framework thinkphp
cd thinkphp && checkout master
此時正常情況下可訪問。
若訪問不了,先檢查權限
1.開啓config.php debug爲true;
2.在入口文件index.php 中,
error_reporting(E_ALL);
ini_set('display_errors', '1');
3.查看/home/wwwlogs目錄下的nginx_error.log錯誤信息;
4.首頁可訪問,pathinfo 的url(IP/index.php/model/controller/action)訪問報錯,
pathinfo兼容問題,而IP/index.php?s=/model/controller/action 可訪問
解決:https://blog.csdn.net/xysoul/article/details/79491597
apache環境 .htaccess
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>
nginx環境 conf/nginx.conf
location ~ \.php { #去掉$
root H:/PHPServer/WWW; 筆者這裏默認是 html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$; #增加
fastcgi_param PATH_INFO $fastcgi_path_info; #增加
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
https://blog.csdn.net/woshihaiyong168/article/details/54973353
若是一鍵安裝包lnmp
原因:無法加載pathinfo
解決辦法:
在nginx.conf(/usr/local/nginx/conf)中,
將原先的‘include enable-php.conf’註釋掉,
更改爲‘include enable-php-pathinfo.conf;’後重啓nginx即可。
5.若出現open_basedir權限問題,php授權目錄設置
vim /usr/local/nginx/conf/fastcgi.conf
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
修改爲
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/../:/tmp/:/proc/";
若再不行,嘗試以下方法:
在php.ini中配置
;open_basedir =
如果發現配置項前是有分號,表明php.ini中沒有該設置。那就很可能是在 php-fpm 中的 fastcgi.conf中配置了。php-fpm中的配置會覆蓋php.ini的配置。
在項目根目錄中通過 .user.ini 進行配置。
.user.ini配置
首先,要使.user.ini生效,要設置php.ini 中的
user_ini.filename = ".user.ini"
user_ini.cache_ttl = 300
註釋掉 fastcgi.conf 中的 open_basedir 的配置。
在項目根目錄 創建 .user.ini文件,寫入如下內容
open_basedir=/tmp/:/proc/:/you_web_path
/you_web_path 是你要添加的讓php可以訪問的路徑。多個路徑直接分號隔開
重啓一下php-fpm 服務即可。
注意,三個地方配置的優先級如下
“php.ini” > “nginx fastcgi fastcgi_param” > “php-fpm.conf”
來自:https://www.cnblogs.com/guohong-hu/p/9350076.html
隱藏index.php
apache :
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
nginx :
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
}
}
具體參考:
https://www.cnblogs.com/blibli/p/11134157.html