lnmp 部署tp5项目文件
1,把thinkphp5解压
2,添加配置项,项目路径和域名
nginx.config 或者自定义的main.config下加如下配置代码
重启服务器
server { listen 80; server_name hwl.tptest.com; #root /home/wwwroot/; set $root /home/wwwroot/tptest; #如果你想在url地址中隐去public 这里的root可以定义为 set $root /home/wwwroot/tptest/public;
#url地址就可以这样访问 http://hwl.tptest.com/index.php/index/Index/index
或者直接输入 hwl.tptest.com 访问主页
location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ { expires 30d; access_log off; } location / { root $root; index index.html index.htm index.php; if ( -f $request_filename) { break; } if ( !-e $request_filename) { rewrite ^(.*)$ /index.php/$1 last; break; } } location ~ \.php/?.* { set $script $uri; set $path_info ""; if ($uri ~ "^(.+\.php)(/.+)") { set $script $1; set $path_info $2; } fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php?IF_REWRITE=1; # include fastcgi.conf; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $script; include fastcgi_params; } }
3,出错了
http://hwl.tptest.com/public/index.php/index/Index/index
找到php.ini文件 usr/local/php/etc
删掉scandir函数
保存并重启PHP 重启nginx
service nginx restart
service php-fpm restart
4,输入url路由地址
http://hwl.tptest.com/public/index.php/index/Index/index