安装仓库 epel-release 和清华源
yum install -y epel-release
yum install -y https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm安装php74的版本
有wordpress必须要php7.4版本以上,因此需要安装remi源。
下面是安装php ,其中 ,php74-php-fpm是php的服务器,侦听端口是 9000.
yum -y install php74.x86_64 php74-php-cli.x86_64 php74-php-common.x86_64 php74-php-gd.x86_64 php74-php-ldap.x86_64 php74-php-mbstring.x86_64 php74-php-mcrypt.x86_64 php74-php-mysql.x86_64 php74-php-pdo.x86_64 php74-php-mysqli
yum -y install php74-php-fpm
安装完毕需要通过以下命令启动服务器,并且要查看9000端口是否启动
systemctl start php74-php-fpm
netstat -antp |grep 9000初始化数据库
wordpress需要mysql 5.7以上的版本,创建wordpress数据库和与数据库相对应的数据库用户名称, 目前因为php 和 数据库在一个服务器上,那么wordpress应该全称 wordpress@localhost
8.0可以使用下面的語句
mysql -uroot -proot -h192.168.10.7 -P 3301
[root@master ~]# mysql -uroot -p'1qaz!QAZ'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.7.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database wordpress charset utf8;
Query OK, 1 row affected (0.00 sec)
mysql> create user wordpress@localhost identified by '1qaz!QAZ';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on wordpress.* to wordpress@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
下载word的源代码,并且过会需要解压到 该虚拟主机的指定root目录下
wget https://cn.wordpress.org/latest-zh_CN.tar.gz
tar zxf latest-zh_CN.tar.gz
建立虚拟主机
把上述文件文件复制到虚拟主机的发布目录里面去
假设你的域名是 www.wordpress.info,那么配置如下
wordpress.info的域名要注意在
linux/windows都需要增加域名解析。
/etc/hosts
c:\windows\system32\drivers\etc\hosts
同时虚拟主机里增加
cat <<EOF >/etc/nginx/conf.d/www.wordpress.info.conf
listen 80;
server_name www.wordpress.info;
root /var/www/html/www.wordpress.info;
index index.php index.html;
location ~ \.php$ {
root /var/www/html/www.wordpress.info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
EOF注意: root 要和 server的root要一致解压源代码
把上述latest…*gz 文件解压到 /var/www/html/www.wordpress.info;
注意,必须把包的所有文件放到上述目录下,不能放到子目录里面
执行属主和组别
chown -R apache.apache /var/www/html/www.wordpress.info;
启动nginx并测试
启动nginx
nginx -t
nginx -s reload
在客户端增加dns解析
在c:\windows\system32\drivers\etc\hosts 最后增加
192.168.10.xxx www.wordpress.info
在浏览器中访问
遇到问题
页面显示安装数据库不成功
页面显示配置文件不能保存
最后编辑:严锋 更新时间:2025-11-04 14:01