CentOS7.4 安装wordpress

步骤一:安装Apache服务器

1、yum -y install httpd

最后显示complete即完成

2、启动httpd并且设置为开机启动

systemctl start httpd.service
systemctl enable httpd.service

3、安装firewall

yum -y install firewalld firewall-config

systemctl start firewalld.service
systemctl enable firewalld.service

4、配置firewall

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

步骤二:安装MariaDB

1、利用yum命令进行安装,并配置开机启动

3. 添加mariadb10.2的国内yum源

之前我添加的是国外的源,安装很耗时,所以我找到国内yum源,通过这个源安装较快。

vim  /etc/yum.repos.d/Mariadb.repo

添加以下内容:

[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

按esc,然后:wq退出

清除yum源缓存数据

yum clean all

生成新的yum源数据缓存

yum makecache all

官方yum源(国内安装较慢)

1 2 3 4 5 6 7# MariaDB 10.2 CentOS repository list - created 2018-06-06 03:42 UTC # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.2/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

官方不同系统yum源网址:https://downloads.mariadb.org/mariadb/repositories/#mirror=tuna

4. 安装mariadb10.2

yum install MariaDB-server MariaDB-client -y

启动并添加开机自启:

systemctl start mariadb.service
systemctl enable mariadb.service

5. mariadb的初始化

mysql_secure_installation

一般建议按以下进行配置:

Enter current password for root (enter for none): Just press the Enter button
Set root password? [Y/n]: Y
New password: your-MariaDB-root-password
Re-enter new password: your-MariaDB-root-password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: n
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

yum -y install mariadb-server mariadb
systemctl start mariadb.service
systemctl enable mariadb.service

6、配置root密码

mysql_secure_installation

  • 具体有以下几个选项,可以根据各自情况进行配置(建议全部选Y)

Enter current password for root (enter for none):(输入原始root密码,若无则按enter)
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] (按Y设置root密码)whd-521123
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] (按Y移除匿名用户)
 ... Success!

Disallow root login remotely? [Y/n] (按Y禁止远程root登陆,一般root都设定为只允许本地登陆)
 ... skipping.

Remove test database and access to it? [Y/n] (按Y删除测试数据库)

Reload privilege tables now? [Y/n] (按Y重新载入)
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

步骤三:安装PHP

1. 更新yum安装包

CentOS 7.x

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS 6.x

rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm

CentOS 5.x

rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm

2. 通过云进行php和其他组件的安装

yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64 php70w-fpm

yum install其他需要的组件在自行安装。

3.测试php安装情况

vim /var/www/html/config.php 

按字母i或insert键进入编辑模式,编辑为以下内容php

<?php
phpinfo();
?>

编辑完成后键入“Esc:wq”,保存文件并退回到命令行模式

5、重启httpd服务

systemctl restart httpd.service

6、在浏览器打开网址 http://x.x.x.x/config.php 进行查看(x.x.x.x为你的服务器公网IP)

类似图中即为正常

步骤四:配置数据库

1、登陆MariaDB为WordPress建立数据库及用户

mysql -u root -p

2、新建数据库wordpressdb,用户为wordpressuser,密码为123456

CREATE DATABASE wp_danielw7;
CREATE USER daniel@localhost IDENTIFIED BY 'Abcd@123';

3、更改用户权限,保存并退出

GRANT ALL PRIVILEGES ON wp_danielw7.* TO daniel@localhost;
FLUSH PRIVILEGES;
exit

4、重启相关服务

systemctl restart httpd.service
systemctl restart  mariadb.service

步骤五:安装WordPress

1、新建一个文件夹,此处取名wp

mkdir wp
cd wp
yum -y install wget unzip net-tools
wget http://wordpress.org/latest.zip

2、解压文件,并且将其复制到/var/www/html目录下

unzip -q latest.zip
cp -rf wordpress/* /var/www/html/

3、修改文件夹权限

chown -R apache:apache /var/www/html/
chmod -R 755 /var/www/html/
mkdir -p /var/www/html/wp-content/uploads
chown -R :apache /var/www/html/wp-content/uploads

4、编辑配置文件

cd /var/www/html
cp wp-config-sample.php wp-config.php
vim wp-config.php

打开文件后,按i键或insert键进入编辑模式,将其修改为以下格式(其中wordpressdb为数据库名称,wordpressuser为数据库用户名,123456为数据库密码)

// * MySQL settings - You can get this info from your web host * //
/* The name of the database for WordPress /
define(‘DB_NAME’, ‘wordpressdb’);

/* mysql database username /
define(‘DB_USER’, ‘wordpressuser’);

/* MySQL database password /
define(‘DB_PASSWORD’, ‘123456’);

键入“Esc:wq”,存盘并退出

5、重启相关服务

systemctl restart httpd.service
systemctl restart mariadb.service

步骤六:WordPress的个人设置

登录 http://x.x.x.x/访问你的博客(x.x.x.x为你的服务器公网IP),按照自己的喜好进行相关的设置。

参考素材:http://blog.csdn.net/keneuro/article/details/48543613 

http://blog.csdn.net/keneuro/article/details/48575533 

https://www.qcloud.com/community/article/883465

<https://blog.csdn.net/liyaxin2010/article/details/83184423>

Comments Closed.