程序猿阵线联盟-汇总各类技术干货服务器配置学习

搭建WordPress博客

2018-06-05  本文已影响2人  Xiangdong_She

环境说明

操作系统: CentOS 7.2 64位

1. 准备LAMP环境

LNMP 是 Linux、Nginx、MySQL 和 PHP 的缩写,是 WordPress 博客系统依赖的基础运行环境。我们先来准备 LNMP 环境

yum install nginx -y

修改 /etc/nginx/nginx.conf,去除对 IPv6 地址的监听,如下:

server {
    listen       80 default_server;
    # listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

}

修改完成之后,启动NGINX,并设置为开机自启

nginx

chkconfig nginx on

下载rmp包。

wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

安装rpm包

rpm -Uvh mysql57-community-release-el7-9.noarch.rpm

安装MySQL

yum install mysql-community-server -y

启动MySQL

systemctl start mysqld.service

设置MySQL密码

获取 root 临时密码

grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}'

使用上一步的获得的临时密码登入 MySQL

mysql -uroot -p

更改MySQL的root密码为dettRoot$123

ALTER USER 'root'@'localhost' IDENTIFIED BY 'dettRoot$123';

退出MySQL,回到Bash shell

exit;

将MySQL设置为开机自启

chkconfig mysqld on
yum install php-fpm php-mysql -y

安装之后,启动 PHP-FPM 进程:

service php-fpm start

启动之后,可以使用下面的命令查看 PHP-FPM 进程监听哪个端口

netstat -nlpt | grep php-fpm

把 PHP-FPM 设置成开机自动启动

chkconfig php-fpm on

2. 安装并配置WordPress

安装

yum install wordpress -y

在完成安装之后,可以在 /usr/share/wordpress 看到 WordPress 的源代码。

配置MySQL数据库

## 进入mysql数据库
mysql -uroot --password='dettRoot$123'
创建数据库
CREATE DATABASE wordpress;
退出数据库
exit;

修改编辑/usr/share/wordpress/wp-config.php文件,主要修改数据库的配置信息,如下:

要根据自己之前对数据库的配置进行设置

define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'dettRoot$123');

/** MySQL hostname */
define('DB_HOST', 'localhost');

WordPress 已经安装完毕,我们配置 Nginx 把请求转发给 PHP-FPM 来处理

进入NGINX配置目录

cd /etc/nginx/conf.d/

修改/etc/nginx/nginx.conf文件,如下

server {
    listen 80;
    root /usr/share/wordpress;
    location / {
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php index.php;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    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;
    }
}

配置后,通知 Nginx 进程重新加载:

nginx -s reload

3. 检查

后台访问地址:http://IP/wp-admin/install.php

image

前端博客地址:http://IP

image

附1 . 关于微信公众号

微信公众号ID:jsj201501

微信公众号名称:瞎说开发那些事

感谢您的关注和阅读,希望这篇文章能为您带来帮助。

欢迎转载与分享,也请注明出处。

如果您有需要了解的关于Java开发、RPA的等内容,也可以给我留言或发邮件 (shexd1001@gmail.com)。

公众号二维码

附2 . 关于本文作者

本文作者:折(she) 向东

微信号:wxxdong2102

识别以下二维码,可以与作者进行更为深入的交流。

![(https:https://img.haomeiwen.com/i3269064/1b2282c8fbf9f873.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

上一篇 下一篇

猜你喜欢

热点阅读