wordpress部署笔记

一、软件下载:

wordpress :

https://cn.wordpress.org/download/

二、环境介绍

Linux+Nginx+Mysql+php

php-fpm : 7.4  (编译)

mariadb:(yum安装)

os : centos 7.6 (ps:重要!!!!关闭内核防火墙,否则可能出现各种权限异常问题)

nginx : 1.19.1 (编译安装)

三、安装数据库(略)

创建数据库:wordpress

创建数据库账户:wordpressuser

密码: (建议设复杂点)

mysql> use mysql;

mysql> create database wordpress character set utf8;

mysql> create user ‘wordpressuser’@’%’ identified with mysql_native_password by ‘123456’;

mysql> Grant all privileges on wordpress.* to ‘wordpressuser’@’%’;

mysql> flush privileges;

注:当前PHP版本中所带的mysql无法支持这种密码验证(caching_sha2_password),而PHP默认的是mysql_native_password

MySQL中创建一个支持mysql_native_password验证的用户,并用该用户登录管理wordpress数据库

create user ‘wordpressuser’@’%’ identified with mysql_native_password by ‘123456’;

四、安装php-fpm环境(略)

参考文档:《linux下的php环境编译安装》

启动php (默认运行在tcp 9000端口)

/usr/local/php/sbin/php-fpm

五、安装nginx及配置部分

nginx安装(略)

注意:nginx.conf内需要编译php相关配置

修改nginx.conf主配置,修改启动进程用户为phpuser

vi nginx.conf

user  phpuser;

删除默认的.default.conf,新增配置,

vi /etc/nginx/conf.d/wordpress.conf

server{

listen 80;

server_name  localhost;

root         /usr/local/wordpress;

index index.php;

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   /usr/share/nginx/html;

}

}

六、上传wordpress并解压至wordpress目录下/usr/local/wordpress

可以在目标文件夹下创建一个php测试能否打开

vi /usr/local/wordpress/test2.php

<?php echo “hello world”; ?>

七、配置wp-config.php,

cp wp-config-sample.php  wp-config.php

vi wp-config.php

###编辑wp-config.php

define( ‘DB_NAME’, ‘wordpress’ );

/** MySQL database username */

define( ‘DB_USER’, ‘wordpressuser’ );

/** MySQL database password */

define( ‘DB_PASSWORD’, ‘123456’ );

/** MySQL hostname */

define( ‘DB_HOST’, ‘localhost’ );

/** Database Charset to use in creating database tables. */

define( ‘DB_CHARSET’, ‘utf8’ );

/** The Database Collate type. Don’t change this if in doubt. */

define( ‘DB_COLLATE’, ” );

###在文件的最后添加这么一句话:页面上操作加载插件的时候就不需要再输入FTP账户密码

define(‘FS_METHOD’, “direct”);

八、开始部署

确认开启这三个服务

nginx

php-fpm

mysql

访问:

http://ip/index.php

PS: 数据库迁移注意替换sql内的地址或域名

wordpress部署笔记

发表回复

滚动到顶部