centos7搭建wordpress博客

安装apache

yum install -y httpd 

启动apache

systemctl start httpd 

设置apache开机自启

systemctl enable httpd 

访问公网地址检测apache是否正常
在这里插入图片描述

安装MySQL数据库

wget -i http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm yum -y install mysql57-community-release-el7-10.noarch.rpm yum -y install mysql-community-server 

启动MySQL数据库

systemctl start mysqld.service 

查看MySQL运行情况

systemctl status mysqld.service 

在这里插入图片描述

查看MySQL初始密码

grep "password" /var/log/mysqld.log 

登录数据库

mysql -uroot -p 

修改MySQL默认密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassWord1.'; 

创建wordpress数据库

create database wordpress; 

查看数据库是否创建成功

show databases; 

在这里插入图片描述
退出MySQL数据库

exit 

安装php7

如果安装版本较低就会出现Your server is running PHP version 5.4.16 but WordPress 5.4.1 requires at least 5.6.20.报错

 rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 
yum install -y 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 

安装php拓展

 yum -y install php-mysql php-gd php-imap php-ldap php-odbc php-mbstring php-devel php-soap php-cli php-pdo yum -y install php-mcrypt php-tidy php-xml php-xmlrpc php-pear yum -y install php-pecl-memcache php-eaccelerator 

重启httpd

 #重启httpd服务 systemctl restart httpd.service #设置开机启动,不设置的话如果服务器重启会导致网站上不去。 systemctl enable httpd.service 

创建php测试页面

echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php 

访问公网地址/phpinfo()测试php服务器是否正常
在这里插入图片描述

安装wordpress

下载最新wordpress

wget https://cn.wordpress.org/latest-zh_CN.tar.gz 

解压

tar xzvf latest.tar.gz 

拷贝到/var/www/html/wordpress目录

 cp -a wordpress/* /var/www/html/wordpress 

编辑wp-config.php

# 切换到wordpress目录 cd /var/www/html/wordpress # 复制wp-config.php文件 cp wp-config-sample.php wp-config.php # 编辑wp-config.php文件 sudo vim wp-config.php 
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** // /** WordPress数据库的名称 */ define( 'DB_NAME', 'wordpress' ); /** MySQL数据库用户名 */ define( 'DB_USER', 'root' ); /** MySQL数据库密码 */ define( 'DB_PASSWORD', 'NewPassWord1.' ); /** MySQL主机 */ define( 'DB_HOST', 'localhost' ); /** 创建数据表时默认的文字编码 */ define( 'DB_CHARSET', 'utf8' ); /** 数据库整理类型。如不确定请勿更改 */ define( 'DB_COLLATE', '' ); /** 设置中文 */ define( 'WPLANG' , 'zh_CN' ); 

创建wordpress账户

登录公网地址/wordpress/wp-admin/install.php按照提示创建账户
创建好后,后台就为这样啦
在这里插入图片描述

原文链接:https://www.cnblogs.com/LRainner/p/12869035.html