文章内容都是经过本人亲测过的步骤,如有不明白的地方,欢迎进群探讨
QQ技术交流群:126095418
1. 安装nginx
2. 安装并配置php
查看文章 在CentOS7.6上部署nginx+php全过程
这里需要注意的一点是,我们都知道thinkphp5是要跑在php5.5以上的版本才行的,所以我们在安装PHP的时候要注意自己的版本,如果yum源中的php版本过低,就要考虑换yum源了
3. 在站点根目录下部署thinkphp5程序代码
使用WinSCP将thinkphp5的程序代码上传到站点根目录
4. 访问站点查看http://你的站点/public/index.php查看
5. 进一步配置站点,去除public及index.php
将index.php文件从public目录中移动到根目录
mv /usr/share/nginx/html/public/index.php /usr/share/nginx/html/index.php
修改文件该文件内容
vi /usr/share/nginx/html/index.php
define('APP_PATH', __DIR__ . '/../application/');
改为
define('APP_PATH', __DIR__ . '/application/');
把
require __DIR__ . '/../thinkphp/start.php';
改为
require __DIR__ . '/thinkphp/start.php';
修改nginx的配置
vi /etc/nginx/nginx.conf
在server{}中增加一段配置,替换原先的location / {}的配置
location / {
index index.php index.html;
autoindex off;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
}
}
6. 重启nginx服务
systemctl restart nginx.service
6. 测试配置好的站点
http://你的站点/index/index/index
如果可以正常访问,则配置成功