实验环境: Red Hat Enterprise Linux release 8.0 (Ootpa) 需要主机连接至网络
安装yum网络源
# cd /etc/yum.repos.d/ # mkdir bak # mv redhat.repo bak/redhat.repo # curl -O http://mirrors.aliyun.com/repo/Centos-8.repo # yum clean all # yum makecache
关闭防火墙
# systemctl disable firewalld --now
安装,启动服务
# yum -y install mariadb-server mariad # yum -y install php-fpm # yum -y install unzip # systemctl enable mariadb --now
安装php相关模块
# yum install -y php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring php-json # systemctl enable php-fpm --now
nginx安装
推荐使用nginx官方使用手册进行安装 # cd /etc/yum.repos.d/ # mv Centos-7.repo /bak/Centos-7.repo # vi nginx.repo [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key [nginx-mainline] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key :wq # yum -y install nginx # systemctl enable nginx --now
配置数据库
初始化数据库
# mysql_secure_installation
设置密码为000000
Enter current password for root (enter for none):<–初次运行直接回车 Set root password? [Y/n] y //设置密码 New password: Re-enter new password: //输入两次000000 Remove anonymous users? [Y/n] n //是否移除匿名用户 Disallow root login remotely? [Y/n] n //是否不允许root远程登录 Remove test database and access to it? [Y/n] y //是否删除test数据库 Reload privilege tables now? [Y/n] y //是否重新加载权限表
登录数据库,创建wordpress数据库,为本地用户和远程用户授权并使授权生效
# mysql -uroot -p000000 > create database wordpress; > grant all privileges on *.* to root@localhost identified by '000000' with grant option; > grant all privileges on *.* to root@"%" identified by '000000' with grant option; > flush privileges; > quit;
命令格式为: grant all privileges on 库名.表名 to ‘用户名’@’IP地址’ identified by ‘密码’ with grant option;
配置php-fpm配置文件
# cd /etc/php-fpm.d/ # vi www.conf 24行 user = nginx 26行 group = nginx 38行 listen = 127.0.0.1:9000 :wq # systemctl reload php-fpm
安装wordpress网站
下载最新版wordpress压缩包 下载地址: https://cn.wordpress.org/download/ 通过ftp上传至本机 解压压缩包
# unzip wordpress-5.6.2-zh_CN.zip
配置nginx
删除掉nginx网站根目录下的所有文件
# cd /usr/share/nginx/html/ # rm -rf *
将wordpress下的文件全部复制到/usr/share/nginx/html/目录,并修改所属和权限
# cd wordpress # cp -rvf * /usr/share/nginx/html/ # cd /usr/share/nginx/ # chown -R nginx:nginx html/ # chmod -R 755 html/
修改wp-config-sample.php文件
# cd /usr/share/nginx/html/ # cp wp-config-sample.php wp-config.php # vi wp-config.php 22 /** WordPress数据库的名称 */ 23 define( 'DB_NAME', 'wordpress' ); 24 25 /** MySQL数据库用户名 */ 26 define( 'DB_USER', 'root' ); 27 28 /** MySQL数据库密码 */ 29 define( 'DB_PASSWORD', '000000' ); :wq
修改nginx配置文件
# cd /etc/nginx/conf.d/ # vi default.conf
编辑配置文件,添加index.php 将一下内容的注释去掉,并修改如下,root处改为自己的目录 ,/scripts改为$document_root
:wq 保存退出
重启服务
# systemctl restart php-fpm # systemctl restart mariadb # systemctl restart nginx
wordpress部署
打开浏览器访问自己的ip 输入相关信息,本次选择弱密码注册,实际使用中极度不推荐弱密码
完成安装
登录
可以进行建站的相关操作了