centos7.6下安装LNMP环境(linux+nginx+mysql5.7+PHP)
忙活了好久好久。。不断解决错误提示。。终于把网站部署上centos了。。留下博客做纪念。
一、安装
安装nginx、php: https://blog.csdn.net/qq_41451303/article/details/104180607
安装mysql: https://blog.csdn.net/qq_38591756/article/details/82958333
按照教程来弄,没啥问题,其中mysql使用的是mysql5.7,其他下载的太慢,修改密码时最好跟着修改一下密码策略,不然需要修改成复杂密码
选择PHP版本:https://blog.csdn.net/qq_39702364/article/details/79939284
编译安装(不推荐、非常耗时、难度较大): https://www.cnblogs.com/xiaoqiujin1012-JR/p/11328963.html
二、部署thinkphp5.1项目失败
1.session_start(): open(...) failed: Permission denied (13)
给报错的文件夹添加权限
例如:
报错:file_put_contents(/var/www/tpblog/runtime/temp/136471ff2580ecd9df29c5772f849835.php): failed to open stream: Permission denied
cd /var/www/tpblog/
chmod 777 temp
出现报错的文件夹都赋予该权限
2.thinkphp5.1只能显示根网页,所有链接404
vim /etc/nginx/conf.d/default.conf
location中添加:
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } }
3.A session is active. You cannot change the session module's ini settings at this time
/etc/php.ini中
session.auto_start = 0
配置完成后 nginx -s reload
4.解决 swap file “*.swp”already exists!(编辑文本过程中异常退出)
将该文件目录下隐藏的 *.swp 文件删除即可,原先的文件便可再次编辑。
三、mysql
mysql修改密码策略:
如果不需要密码策略,在/etc/my.cnf文件中添加如下配置禁用即可:
validate_password = off
mysql修改密码:
set password for 'root'@'localhost'=password('1234');
mysql执行sql文件:
source .sql路径及文件名