WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站。也可以把 WordPress当作一个内容管理系统(CMS)来使用. WordPress是一款个人博客系统,并逐步演化成一款内容管理系统软件

官网:https://wordpress.org/
官方文档:https://codex.wordpress.org/Main_Page
wordpress最新版下载(目前最新版是4.8):https://wordpress.org/latest.tar.gz
wordpress安装要求:https://wordpress.org/about/requirements/

1
2
3
4
#wordpress 4.8系统安装要求
php version >= 7
mysql version >=5.6 or MariaDB version >= 10.0
https support

官方安装文档:https://codex.wordpress.org/Installing_WordPress#Famous_5-Minute_Install

安装LNMP环境

环境:
   Centos 7.3
   wordpress version 4.8
   mysql version 5.6.36
   php version 7.1.5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@localhost ~]# yum -y install mysql-community-server mysql-community-client
[root@localhost ~]# systemctl start mysql
[root@localhost ~]# systemctl list-unit-files | grep -i mysql
mysql.service enabled
mysqld.service enabled
[root@localhost ~]#
#更新yum源
[root@localhost ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#安装php71
[root@localhost ~]# yum install php71w-fpm php71w-devel php71w-gd php71w-imap php71w-mysql php71w-odbc
#安装nginx1.12.0-1.w7
[root@localhost ~]# yum install nginx1w
[root@localhost ~]# systemctl start php-fpm
[root@localhost ~]# systemctl enable php-fpm
[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl enable nginx

安装wordpress

1
2
3
#官方只提供最新版下载,本文附件会提供wordpress-4.8下载
[root@localhost ~]# wget https://wordpress.org/latest.tar.gz -O wordpress-4.8.tar.gz
[root@localhost ~]# tar -zxf wordpress-4.8.tar.gz -C /usr/local/

配置nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@localhost ~]# cd /etc/nginx/conf.d/
[root@localhost conf.d]# cat wordpress.conf
server {
listen 80;
server_name 192.168.1.199;
root /usr/local;
location /wordpress {
index index.php;
access_log /var/log/nginx/host_wordpress.access.log main;
try_files $uri $uri/ /index.php?$args;
}
location /info {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location ~ ^(.+.php)(.*)$ {
fastcgi_split_path_info ^(.+.php)(.*)$;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
[root@localhost conf.d]#
[root@localhost conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost conf.d]# systemctl reload nginx
[root@localhost ~]# curl -I http://192.168.1.199/info
[root@localhost ~]# curl -I http://192.168.1.199/wordpress

访问http://ip/info
php_info

访问http://ip/wordpress
wordpress_setup

1
2
3
4
#创建mysql库wordpress
mysql> create database wordpress DEFAULT CHARACTER SET utf8;
mysql> create user wordpress_user identified by 'wordpress_pass';
mysql> grant all privileges on wordpress.* TO 'wordpress_user';

1
2
[root@localhost ~]# cd /usr/local/wordpress
[root@localhost wordpress]# cp wp-config-sample.php wp-config.php

如果打开时报这个错误,是因为没有正确在 wp-config.php 配置mysql数据库连接信息

1
Error establishing a database connection

1
2
3
4
5
6
7
8
[root@localhost wordpress]# grep -i '^define' wp-config.php | grep -i 'db'
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress_user');
define('DB_PASSWORD', 'wordpress_pass');
define('DB_HOST', '192.168.1.199');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
[root@localhost wordpress]#

wordpress_setup
wordpress_setup
wordpress_setup
wordpress_setup
wordpress_setup
wordpress_setup

Wordpress安装成功

附件:
wordpress-4.8.tar.gz
mysql57-community-release-el7-11.noarch.rpm
此mysql yum源安装后,修改mysql-community.repo即可


本文出自”Jack Wang Blog”:http://www.yfshare.vip/2017/06/25/部署wordpress/