CentOS+nginx手动搭建WordPress

文章目录

  • 前提条件
  • php安装
    • 安装 EPEL 源及源管理工具:
    • 安装 REMI 源:
    • 安装 PHP7.4 及扩展:
    • 设置开机自动启动
    • 其他php命令
  • wordpress 安装
    • 下载WordPress
    • 将下载的WordPress移动至网站根目录
    • 修改WordPress配置文件
    • 配置nginx
  • 创建完成后根据域名访问

前提条件

  • 已有一台服务器并安装了CentOS操作系统
  • 已有Nginx
  • 已有mysql

php安装

安装 EPEL 源及源管理工具:

yum install epel-release yum-utils
CentOS+nginx手动搭建WordPress_第1张图片

安装 REMI 源:

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
CentOS+nginx手动搭建WordPress_第2张图片

安装 PHP7.4 及扩展:

yum install -y php74-php-fpm php74-php-cli php74-php-bcmath php74-php-gd php74-php-json php74-php-mbstring php74-php-mcrypt php74-php-mysqlnd php74-php-opcache php74-php-pdo php74-php-pecl-crypto php74-php-pecl-mcrypt php74-php-pecl-geoip php74-php-pecl-swoole php74-php-recode php74-php-snmp php74-php-soap php74-php-xmll php74-php-zip
CentOS+nginx手动搭建WordPress_第3张图片

设置开机自动启动

systemctl enable php74-php-fpm #开启开机自启

其他php命令

php74 -v #查看版本

systemctl restart php74-php-fpm #重启

systemctl start php74-php-fpm #启动

systemctl stop php74-php-fpm #关闭

systemctl status php74-php-fpm #检查状态

#如果你运行的是 nginx 而不是 apache,修改

vi /etc/opt/remi/php74/php-fpm.d/www.conf

user = apache

group = apache

# Replace the values with

user = nginx

group = nginx

#查找 php 和扩展的安装包:

rpm -qa | grep 'php'

#查看 php74-php-pecl-swoole4-4.4.15-1.el7.remi.x86_64 的安装路径:

rpm -ql php74-php-pecl-swoole4-4.4.15-1.el7.remi.x86_64

yum update #更新可更新的所有软件,包括PHP

wordpress 安装

下载WordPress

yum -y install wordpress

将下载的WordPress移动至网站根目录

mv /usr/share/wordpress /usr/share/nginx/html/wordpress

修改WordPress配置文件

进入移动后的WordPress路径下,软连接配置文件wp-config.php

cd /usr/share/nginx/html/wordpress
ln -snf /etc/wordpress/wp-config.php wp-config.php

编辑wp-config.php文件

// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');

/** MySQL数据库用户名 */
define('DB_USER', 'user');

/** MySQL数据库密码 */
define('DB_PASSWORD', 'PASSword123.');

/** MySQL主机 */
define('DB_HOST', 'localhost');

配置nginx

server {
    listen       80;
    server_name  你的域名;
     location / {

        root /usr/share/nginx/html/wordpress;
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php?q=$uri&$args;  # 没有他,无法访问文章页会出现404
        client_max_body_size    100m; # # 默认才1m,很多插件都装不了,所以调大一点
   }

   location ~ \.php$ {
        root    /usr/share/nginx/html/wordpress;
        client_max_body_size    100m; # 默认才1m,很多插件都装不了,所以调大一点
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   }
}

重启nginx
nginx -s reload

创建完成后根据域名访问

CentOS+nginx手动搭建WordPress_第4张图片

你可能感兴趣的:(#,wordpress,nginx,centos,php)