CentOS7 安装 WordPress

环境准备

软件 版本 安装方式
MySQL 5.6.42 Yum
HTTPD 2.4.6 Yum
PHP 5.4.16 Yum
WordPress 5.0 源码安装

安装MySQL数据库

下载MySQL的Yum源
1
2
3
[root@dk vagrant]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[root@dk vagrant]# ls
mysql-community-release-el7-5.noarch.rpm
安装Yum源
1
2
3
4
[root@dk vagrant]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-release-el7-5 ################################# [100%]
查看yum文件
1
2
[root@dk vagrant]# ls /etc/yum.repos.d/mysql*
/etc/yum.repos.d/mysql-community.repo /etc/yum.repos.d/mysql-community-source.repo
清理yum缓存
1
[root@dk vagrant]# yum clean all
重新生成缓存
1
2
3
[root@dk vagrant]# yum makecache
...
元数据缓存已建立
安装MySQL
1
[root@dk vagrant]# yum install mysql-server
启动MySQL
1
2
3
[root@dk vagrant]# systemctl start mysqld
[root@dk vagrant]# systemctl status mysqld
出现Active: active (running) 绿色则说明启动成功
登录MySQL
1
[root@dk vagrant]# mysql -u root
设置密码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=password('root') where user = 'root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
重启MySQL
1
[root@dk vagrant]# systemctl restart mysqld
再次登录MySQL
1
[root@dk vagrant]# mysql -u root -proot

安装Apache Http

yum查看
1
2
3
[root@dk vagrant]# yum list httpd
可安装的软件包
httpd.x86_64 2.4.6-88.el7.centos base
安装httpd
1
[root@dk vagrant]# yum install httpd
启动httpd
1
2
3
[root@dk vagrant]# systemctl start httpd
[root@dk vagrant]# systemctl status httpd
出现Active: active (running) 绿色则说明启动成功

此处如果出现问题很大原因可能是由于80端口被占用导致的,处理掉就好了

验证结果

访问主机IP如果出现This page is used to test the proper operation of the Apache HTTP server after it has been installed. If you can read this page it means that this site is working properly. This server is powered by CentOS. 则说明成功了。

安装PHP

Yum安装
1
[root@dk vagrant]# yum install php
验证结果
1
2
3
4
[root@dk vagrant]# php -v
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
其他组件
1
[root@dk vagrant]# yum install php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mysql

安装WordPress

下载wp
1
[root@dk vagrant]# wget https://wordpress.org/latest.zip
解压wp
1
2
3
4
5
6
7
8
[root@dk vagrant]# unzip -d /var/www/html latest.zip
[root@dk vagrant]# cd /var/www/html/
[root@dk html]# ls
wordpress
[root@dk html]# mv wordpress/* .
[root@dk html]# ls
index.php readme.html wp-activate.php wp-blog-header.php wp-config-sample.php wp-cron.php wp-links-opml.php wp-login.php wp-settings.php wp-trackback.php
license.txt wordpress wp-admin wp-comments-post.php wp-content wp-includes wp-load.php wp-mail.php wp-signup.php xmlrpc.php
访问安装

接下来访问主机Ip 进行安装WordPress即可。

Docker部署WordPress

MySQL

1
[root@dk]# docker run -d --name mysql  -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wordpress mysql:5.7.24

WordPress

1
[root@dk]# docker run -d --name wordpress -e WORDPRESS_DB_HOST=mysql:3306 -e WORDPRESS_DB_PASSWORD=root  --link mysql -p 80:80 wordpress

访问主机Ip

打开主机Ip地址访问安装,Done.