lnmp+wordpress

nginx 节点修改配置文件

[root@nginx ~]# vi /usr/local/nginx/conf/nginx.conf

…省略…

location / {

            root   /www;                              #更改网页目录

            index  index.php index.html index.htm;         #添加index.php

        }

…省略…

location ~ \.php$ {                                   #去掉location{}前的注释符

            root           /www;                   #更改目录为/www

            fastcgi_pass   192.168. 0.40:9000;       #注意:在这里添加PHP主机IP地址

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            include        fastcgi_params;

        }

…省略…

保存退出后,修改 fastcgi_params 配置文件

[root@nginx ~]# vi /usr/local/nginx/conf/fastcgi_params

fastcgi_param  QUERY_STRING       $query_string;

fastcgi_param  REQUEST_METHOD     $request_method;

fastcgi_param  CONTENT_TYPE       $content_type;

fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name; #添加这行代码

fastcgi_param  REQUEST_URI        $request_uri;

fastcgi_param  DOCUMENT_URI       $document_uri;

......

在 nginx 和 php 节点创建 /www 目录,并修改用户和用户组

[root@nginx ~]# mkdir /www

[root@nginx ~]# chown nginx:nginx /www/

[root@php ~]# mkdir /www

[root@php ~]# chown nginx:nginx /www/

将 wordpress-5.4.1-zh_CN.zip 上传至 nginx 节点和 php 节点的 /root 目录下

注意目录是否正确,然后把压缩包拽过去
使用unzip命令解压

[root@nginx ~]# unzip wordpress-5.4.1-zh_CN.zip

-bash: unzip: command not found

出现这个错误提示,是说未找到命令,也就是我们没有安装 unzip,那我们就安一个,挂载光驱然后安装
解压压缩包,然后将解压后的文件移动到 /www 目录下

[root@nginx ~]# yum install -y unzip zip

[root@nginx ~]# unzip wordpress-5.4.1-zh_CN.zip

[root@nginx ~]# mv wordpress/* /www

php 节点同理
修改 nginx 节点与 php 节点的 wordpress 应用配置文件。wordpress 提供了配置模板,我们把模板复制过去,然后修改,命令如下

[root@nginx ~]# cp /www/wp-config-sample.php /www/wp-config.php

[root@nginx ~]# vi /www/wp-config.php   

// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //

/** WordPress数据库的名称 */

define( 'DB_NAME', 'wordpress' );

/** MySQL数据库用户名 */

define( 'DB_USER', 'root' );

/** MySQL数据库密码 */

define( 'DB_PASSWORD', '123' );  (root的数据库密码)

/** MySQL主机 */

define( 'DB_HOST', '192.168.0.10' ); (主数据库的Ip)

/** 创建数据表时默认的文字编码 */

define( 'DB_CHARSET', 'utf8' );

/** 数据库整理类型。如不确定请勿更改 */

define( 'DB_COLLATE', '' );

php 节点配置同理操作,或者将该配置文件scp至php节点的/www目录下,命令如下:

[root@nginx ~]# scp /www/wp-config.php root@192.168. 0.40:/www/ 

转到 mysql1 节点,登录 mysql 数据库,并创建 wordpress 数据库,命令如下

[root@mysql1 ~]# mysql -uroot -p123

MariaDB [(none)]> create database wordpress;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> Ctrl+C或exit(退出数据库,命令二选一即可)

Aborted

在 nginx 节点重启 nginx 服务,命令如下。

[root@nginx ~]# nginx -s reload

若出现如下错误,是说 nginx.pid 文件不存在
解决方法:使用 nginx -c 的参数指定 nginx.conf 文件的位置,命令如下

nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)

[root@nginx ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

再次重启 nginx 服务

[root@nginx ~]# nginx -s reload

在浏览器输入地址 192.168.0.30(我的 nginx 节点 ip 地址为 192.168.0.30,具体以你所配置的为准),等待一会,就会出现 wordpress 的五分钟安装程序了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值