CentOS 7 基于LNMP快速简单搭建wordpress

配置阿里云YUM源

官方镜像源下载速度实在太慢,使用阿里云源下载速度更快

[root@localhost yum.repos.d]#  mv ./* /tmp/
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost yum.repos.d]# ls
CentOS-Base.repo
[root@loca lhost yum.repos.d]# yum clean all		#清理YUM缓存
[root@localhost yum.repos.d]# yum makecache		#更新YUM仓库

搭建环境前准备

SELinux服务关闭

防火墙设置

nginx默认使用80端口,可在nginx.conf中配置

永久开放80端口:
firewall-cmd --zone=public --add-port=80/tcp --permanent

重启防火墙:
firewall-cmd --reload

查看防火墙开启状态:
systemctl status firewalld

查看80端口是否开放成功:
firewall-cmd --zone=public --query-port=80/tcp

或者将防火墙和SELinux服务关闭

yum install wget -y

安装mysql

wget https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
yum -y install mysql57-community-release-el7-11.noarch.rpm
yum -y install mysql-community-server mysql

修改初始密码

获取默认密码
systemctl start mysqld.service
grep 'password' /var/log/mysqld.log
2021-08-21T04:22:05.085559Z 1 [Note] A temporary password is generated for
root@localhost: T5jpstN6#3rR
登录修改默认密码(数据库的root密码,不是系统用户root密码)
mysql -uroot -p'T5jpstN6#3rR'
mysql> alter user 'root'@'localhost' identified by 'Yy123.com';
Query OK, 0 rows affected (0.00 sec)
退出后就可以用自己的密码登录

创建WordPress数据库并授权(密码为WordPress用户的登录密码)
mysql> create database wordpress;
mysql> create user 'wordpress'@'localhost' identified by 'Yy123.com';
mysql> grant all privileges on wordpress.* to 'wordpress'@'localhost';
mysql> flush privileges;

安装nginx

yum install nginx -y

添加配置文件
vim /etc/nginx/conf.d/wordpress.conf 
server{
listen 80;
server_name www.test.com;
root /wordpress;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php index.php;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
#######################################################
cd /etc/nginx/

备份配置文件
cp nginx.conf /tmp/nginx.conf.bak

修改nginx.conf配置文件
vim /etc/nginx/nginx.conf
38行到#开始前,把中间的内容删除

保存退出,启动nginx
systemctl start nginx

安装php环境

yum install php-fpm php-mysql -y
修改配置文件
vim /etc/php-fpm.d/www.conf

在这里插入图片描述

启动服务
systemctl start php-fpm.service

搭建wordpress

wget https://cn.wordpress.org/wordpress-4.7.2-zh_CN.tar.gz
tar zxf wordpress-4.7.2-zh_CN.tar.gz 
mv wordpress /
cd /
chmod -R 777 wordpress/

[root@lnmp /]# systemctl restart nginx
[root@lnmp /]# systemctl restart mysqld
[root@lnmp /]# systemctl restart php-fpm
[root@lnmp /]# systemctl stop firewalld
[root@lnmp /]# setenforce 0
setenforce: SELinux is disabled

进入WordPress网站
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值