全部文章
2019-05-06,更新于 2026-09-05约 2 分钟 · 434 字linux

安装新版 wordpress

不知不觉,wordpress 已经更新到 5.X 了,第一次接触 wordpress 还在新浪云上,那时候实名认证后每个月有免费的云豆,wordpress 版本是 3.6,那时作为初中生的我有了一个 wordpress 博客激动了好久,如今 wordpress 已经更新到 5.X 了,新版 word…

不知不觉,wordpress 已经更新到 5.X 了,第一次接触 wordpress 还在新浪云上,那时候实名认证后每个月有免费的云豆,wordpress 版本是 3.6,那时作为初中生的我有了一个 wordpress 博客激动了好久,如今 wordpress 已经更新到 5.X 了,新版 wordpress 对安装环境有了新的要求。5.X 的 wordpress 不再支持 php5 了,需要安装 php7 才行。

添加 yum 源

添加 epel,ius,mariadb,nginx 的 yum 源

原一键脚本 bash <(curl -s -L https://git.io/fjlc4) 已随 git.io 短链服务(2022 年关停)失效,下面是等价的手动配置:

yum install -y epel-release
yum install -y https://repo.ius.io/ius-release-el7.rpm

注:IUS 源已于 2025 年初停止服务,CentOS 7 也已于 2024 年 6 月停止维护,本节仅作历史记录;在新系统部署请参考各软件官方文档。

安装所需软件

yum -y install nginx mariadb-server php72u-common php72u-mysqlnd php72u-fpm-nginx php72u-gd php72u-pecl-memcached php72u-opcache

环境初始化

nginx 配置

nginx 配置文件 /etc/nginx/conf.d/default.conf

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html/wordpress;
        index  index.php index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        root           /usr/share/nginx/html/wordpress;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

mariadb 初始化

systemctl start mariadb
mysql_secure_installation      #设置root密码
mysql -uroot -p密码 -e "create database wordpress;"

启动服务

systemctl restart nginx mariadb php-fpm

下载 WordPress 并解压

wget https://wordpress.org/latest.tar.gz
tar Cxf /usr/share/nginx/html/ latest.tar.gz

权限处理

chown -R php-fpm:php-fpm /usr/share/nginx/html/wordpress

浏览器输入域名或 ip 地址开始安装向导

CC BY-NC-SA 4.0

本文作者 yzbtdiy,转载请注明出处与原文链接。

许可详情