Centos 7 安装wordpress

首先安装LAMP
Centos 7 安装LAMP并配置event MPM和FastCGI

以下假设wordpress安装在/opt/wordpress下
创建安装文件夹

sudo mkdir /opt/wordpress
sudo chown -R `whoami`:`whoami` /opt/wordpress
准备数据库
mysql -u root -p

输入MySQL的ROOT密码

CREATE DATABASE 数据库名;
CREATE USER 用户名@localhost IDENTIFIED BY '用户密码';
GRANT ALL PRIVILEGES ON 数据库名.* TO 用户名@localhost IDENTIFIED BY '用户密码';
FLUSH PRIVILEGES;
exit
安装wordpress
cd $home
wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
mv wordpress/* /opt/wordpress/
cd /opt/wordpress/
mkdir wp-content/uploads
> .htaccess
cp wp-config-sample.php wp-config.php
nano wp-config.php

替换database_name_here为数据库名,替换username_here为用户名,替换password_here为用户密码
在末尾添加define('FS_METHOD','direct');
更改文件夹所有者为apache

sudo chown -R apache:apache ./

配置selinux

sudo yum install -y policycoreutils-python -y
sudo semanage fcontext -a -t httpd_sys_content_t "/opt/wordpress(/.*)?"
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/opt/wordpress/wp-content(/.*)?"
sudo semanage fcontext -a -t httpd_sys_rw_content_t /opt/wordpress/.htaccess
sudo semanage fcontext -a -t httpd_sys_rw_content_t /opt/wordpress/wp-config.php
sudo restorecon -R -v /opt/wordpress
添加virtualhost
sudo nano /etc/httpd/conf.d/wordpress.conf

内容为

<VirtualHost *>
    DocumentRoot /opt/wordpress
    ServerName 你的服务器域名
    <Directory "/opt/wordpress">
        AllowOverride none
        Require all granted
        Allow from all
        DirectoryIndex index.php
        IncludeOptional /opt/wordpress/.htaccess
    </Directory>
</VirtualHost>

重启Apache

sudo systemctl restart httpd
安装php插件
sudo yum install php-gd opcache -y

重启php-fpm

sudo systemctl restart php-fpm
wordpress初始化

访问http://域名 开始wordpress初始化

其他
允许发送邮件
sudo setsebool -P httpd_can_sendmail 1