学习了强制修改数据库root用户密码与LNMP架构部署网站
1、强制修改数据库root用户密码
- 在配置项中新增一条数据
vim /etc/my.cnf
skip-grant-tables #注意:不能与validate-password=off一同存在
- 修改完后直接进入数据库 不需密码,进入后直接修改数据库中root用户密码
update mysql.user set authentication_string=password('密码') where User='root' and Host='localhost';
- 重新加载配置项
flush privileges;
- 修改完后记得删除/etc/my.cnf中的配置项
2、使用LNMP架构部署网站
1、部署nginx
下载并启动nginx
yum -y install nginx
nginx
判断是否启动成功
ss -nplt | grep 80
ps aux | grep nginx
2、部署php
下载php官网yum源
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
安装php74及其依赖配置项
yum -y install php74-php-xsl php74-php php74-php-cli php74-php-devel php74-php-gd php74-php-pdo php74-php-mysql php74-php-fpm
检查是否启动成功
ss -nplt | grep 9000
ps aux | grep php
3、nginx关联php
备份nginx配置文件
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
在nginx配置文件中新增php配置
vim +42 /etc/nginx/nginx.conf #在42行下新增配置
index index.php index.html index.htm;
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
}
检查nginx配置文件的语法,避免重新加载时出现错误
nginx -t
重新加载配置文件
nginx -s reload
4、新建测试文件测试php与nginx是否已关联上
将nginx下指定发布目录清空
cd /usr/share/nginx/html/
rm -rf *
新建测试文件
vim /usr/share/nginx/html/index.php
写入代码
<?php
phpinfo();
?>
5、上传项目
将wordpress代码包下载到html路径后,解压缩
tar -xf wordpress-5.9.1-zh_CN.tar.gz
cp -r wordpress/* /usr/share/nginx/html/
附:
nginx默认端口:80
php默认端口:9000
mysql默认端口:3306