[root@wordpress ~]# hostnamectl set-hostname wordpress
[root@wordpress ~]# bash
[root@wordpress ~]# systemctl disable firewalld --now && setenforce 0
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@wordpress ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@wordpress ~]# curl -o /etc/yum.repos.d/centos.repo http://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2523 100 2523 0 0 10334 0 --:--:-- --:--:-- --:--:-- 10382
[root@wordpress ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 664 100 664 0 0 4213 0 --:--:-- --:--:-- --:--:-- 4229
[root@wordpress ~]# yum list installed | grep nginx
nginx.x86_64 1:1.24.0-1.el7.ngx @nginx-stable
[root@wordpress ~]# cat /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[root@wordpress ~]# yum list installed | grep nginx
nginx.x86_64 1:1.24.0-1.el7.ngx @nginx-stable
[root@wordpress ~]# systemctl enable nginx --now
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@wordpress ~]# netstat -ntpl | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1567/nginx: master
[root@wordpress ~]# nginx -V
nginx version: nginx/1.24.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
vi /etc/nginx/conf.d/default.conf
server {
listen 80;
# 设置服务器的根目录为/usr/share/nginx/html
root /usr/share/nginx/html;
# 设置服务器名称为localhost
server_name localhost;
# 处理以index.php、index.html和index.htm结尾的请求路径
location / {
index index.php index.html index.htm;
}
# 处理500、502、503和504错误码的请求路径
error_page 500 502 503 504 /50x.html;
# 当发生500、502、503或504错误时,将请求重定向到/50x.html页面
location = /50x.html {
root /usr/share/nginx/html;
}
# 处理以.php结尾的请求路径,将其转发到FastCGI服务器上运行
location ~ \.php$ {
# FastCGI服务器监听在127.0.0.1:9000
fastcgi_pass 127.0.0.1:9000;
# 指定FastCGI脚本文件名为index.php
fastcgi_index index.php;
# 设置FastCGI参数SCRIPT_FILENAME的值,包括文档根目录和FastCGI脚本文件名
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 包含FastCGI参数配置文件
include fastcgi_params;
}
}
[root@wordpress ~]# yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64
[root@wordpress ~]# systemctl enable php-fpm --now
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
[root@wordpress ~]# netstat -ntpl | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2467/php-fpm: maste
[root@wordpress ~]# php -v
PHP 7.2.34 (cli) (built: Oct 1 2020 13:37:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans
注意用户PHP配置文件
[root@http nginx]# vim /usr/local/php/etc/php-fpm.d/www.conf.default
; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[www]
; Per pool prefix
; It only applies on the following directives:
; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr/local/php) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www ### 用户
group = www ### 用户组
##### 如果www.conf配置文件的user与group参数不修改为nginx的话,在WordPress发布文章的时候因为权限问题可能导致无法上传图片,出现“无法将上传的文件移动至wp-content/uploads”的错误提示。
[root@http nginx]# head -n 5 /usr/local/nginx/conf/nginx.conf
user www www;
worker_processes auto;
worker_cpu_affinity auto;
[root@wordpress ~]# yum list installed | grep mariadb
mariadb-libs.x86_64 1:5.5.68-1.el7 @anaconda
[root@wordpress ~]# yum remove -y mariadb-libs
[root@wordpress ~]# cat /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = https://rpm.mariadb.org/10.6/rhel/$releasever/$basearch
gpgkey= https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
[root@wordpress ~]# yum install -y mariadb-server mariadb-client
[root@wordpress ~]# systemctl enable mariadb --now
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@wordpress ~]# netstat -ntpl | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1994/mariadbd
tcp6 0 0 :::3306 :::* LISTEN 1994/mariadbd
[root@wordpress ~]# mariadb -V
mariadb from 11.2.2-MariaDB, client 15.2 for Linux (x86_64) using readline 5.1
[root@wordpress ~]# mysql
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 11.2.2-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.001 sec)
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
| wordpress |
+--------------------+
6 rows in set (0.001 sec)
MariaDB [(none)]> grant all privileges on *.* to 'wordpress'@'localhost' identified by '000000';
MariaDB [(none)]> grant all privileges on *.* to 'wordpress'@'%' identified by '000000'; flush privileges;
Query OK, 0 rows affected (0.001 sec)
Query OK, 0 rows affected (0.001 sec)
[root@wordpress ~]# wget https://cn.wordpress.org/wordpress-4.7.3-zh_CN.zip
[root@wordpress ~]# unzip wordpress.zip
[root@wordpress ~]# mv /usr/share/nginx/html/index.html ./
[root@wordpress ~]# cd /root/wordpress
[root@wordpress ~]# cp -rvf * /usr/share/nginx/html/
[root@wordpress ~]# chmod -R 777 * "修改所有文件目录权限"
[root@wordpress ~]# cp wp-config-sample.php wp-config.php
[root@wordpress ~]# vi wp-config.php
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');
/** MySQL数据库用户名 */
define('DB_USER', 'wordpress');
/** MySQL数据库密码 */
define('DB_PASSWORD', '000000');
/** MySQL主机 */
define('DB_HOST', 'localhost');
/** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8');
/** 数据库整理类型。如不确定请勿更改 */
define('DB_COLLATE', '');