安装PHP
安装程序
yum install -y php php-mysql php-fpm
验证安装
php --version
启动php-fpm
systemctl start php-fpm
安装、配置数据库
安装数据库
yum install -y mariadb mariadb-server
创建数据库
systemctl start mariadb
mysql
create database wp_test default character set utf8mb4 collate utf8mb4_unicode_ci;
创建数据库用户
create user 'wp_user'@'%' identified by 'pw1!23456';
grant all privileges on wp_test.* to 'wp_user'@'localhost' identified by 'pw1!23456' with grant option;
flush privileges;
exit;
下载、配置WordPress
下载、解压
mkdir /data/webs
cd /data/webs
wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
tar -zxvf wordpress-4.9.4-zh_CN.tar.gz
配置WP
cp wordpress/wp-config-sample.php wordpress/wp-config.php
vi wordpress/wp-config.php
/** WordPress数据库的名称 */
define('DB_NAME', 'wp_test');
/** MySQL数据库用户名 */
define('DB_USER', 'wp_user');
/** MySQL数据库密码 */
define('DB_PASSWORD', 'pw1!23456');
/** MySQL主机 */
define('DB_HOST', 'localhost:3306');
/** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8mb4');
安装、配置Nginx
安装nginx
yum install -y nginx
添加站点
vi /etc/nginx/conf.d/wp_test.conf
server {
listen 80; # 监听端口
server_name www.siteA.com siteA.com; # 站点域名
root /data/webs/wordpress; # 站点根目录
index index.html index.htm index.php; # 默认导航页
location / {
# WordPress固定链接URL重写
if (!-e $request_filename) {
rewrite (.*) /index.php;
}
}
# PHP配置
location ~ \.php$ {
root /data/webs/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
启动nginx
systemctl start nginx
打开站点
浏览器打开
www.siteA.com