70-lnmp-搭建wordpress博客站点

列表

lnmp一键安装脚本

#本章并不使用,仅提供了解

lnmp自动化安装脚本下载

详细说明

#脚本执行命令
wget http://soft.vpser.net/lnmp/lnmp1.7.tar.gz -cO lnmp1.7.tar.gz && tar zxf lnmp1.7.tar.gz && cd lnmp1.7 && ./install.sh {lnmp|lnmpa|lamp}

lnmp1.7脚本 某盘下载链接
提取码:so16

wordpress博客站点搭建:相关安装包下载

Discuz_X3.4_SC_UTF8【20191201】.zip
提取码:2sck

poweradmin-2.1.7.tgz
提取码:3zmq

wordpress-5.2.4-zh_CN.tar.gz
提取码:t38e

xcache-3.2.0.tar.gz
提取码:arkn

epel-aliyun-yum源
提取码:7c5r

实验开始

#准备一台虚拟机,默认主机已关闭防火墙、关闭SELINUX
主机版本 主机IP 主机名
CentOS 7 192.168.124.13 C7-3
#配置yum源
[root@C7-3 ~]# cd /etc/yum.repos.d/
[root@C7-3 yum.repos.d]# mkdir 2020
[root@C7-3 yum.repos.d]# mv ./* 2020/ &> /dev/null

#上传yum源文件
[root@C7-3 yum.repos.d]# ll
total 8
drwxr-xr-x. 2 root root  204 Dec 24 12:05 2020
-rw-r--r--  1 root root 2523 Nov 16  2019 aliyun-7.repo
-rw-r--r--  1 root root  664 Nov 16  2019 epel-7.repo

[root@C7-3 yum.repos.d]# mkdir /usr/src/discuz

#将Discuz_X3.4_SC_UTF8【20191201】.zip 上传至该目录
[root@C7-3 yum.repos.d]# cd /usr/src/discuz/
[root@C7-3 discuz]# ll
total 11524
-rw-r--r-- 1 root root 11800498 Jun  4 14:50 Discuz_X3.4_SC_UTF8【20191201】.zip

#安装实验相关软件包
[root@C7-3 discuz]# yum -y install httpd php php-xml php-mysqlnd mariadb-server unzip

#解压Discuz
[root@C7-3 discuz]# unzip Discuz_X3.4_SC_UTF8【20191201】.zip

[root@C7-3 discuz]# ll
total 11620
-rw-r--r--  1 root root 11800498 Jun  4 14:50 Discuz_X3.4_SC_UTF8【20191201】.zip
-rw-r--r--  1 root root    18451 Jul  3  2019 qqqun.png
drwxr-xr-x  2 root root      102 Dec  1  2019 readme
-rw-r--r--  1 root root    70883 Dec  1  2019 readme.html
drwxr-xr-x 13 root root     4096 Dec  1  2019 upload
drwxr-xr-x  4 root root       94 Dec  1  2019 utility


#将upload 目录移动至/var/www/html 下并重命名为 forum
#移动完成后修改属主属组为apache
[root@C7-3 discuz]# mv upload/ /var/www/html/forum
[root@C7-3 discuz]# chown -R apache:apache /var/www/html/forum
[root@C7-3 discuz]# ll /var/www/html/forum -d
drwxr-xr-x 13 apache apache 4096 Dec  1  2019 /var/www/html/forum


#启动mariadb服务
[root@C7-3 discuz]# systemctl start mariadb
[root@C7-3 discuz]# lsof -i:3306
-bash: lsof: command not found
[root@C7-3 discuz]# yum -y install lsof

#查看3306端口谁来监听
[root@C7-3 discuz]# lsof -i:3306
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  2548 mysql   14u  IPv4  37388      0t0  TCP *:mysql (LISTEN)


[root@C7-3 discuz]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
……………………..
MariaDB [(none)]> create database ultrax;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on ultrax.* to ultrax@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> exit;
Bye


#启动httpd服务
[root@C7-3 discuz]# systemctl start httpd

Discuz 安装向导

#在浏览器输入:192.168.124.13/forum

70-lnmp-搭建wordpress博客站点插图

#当显示此页面时,说明已经可以进行安装了

70-lnmp-搭建wordpress博客站点插图(1)
70-lnmp-搭建wordpress博客站点插图(2)

#若无显示红色报错便继续下一步

70-lnmp-搭建wordpress博客站点插图(3)

#填写内容,继续下一步

70-lnmp-搭建wordpress博客站点插图(4)

70-lnmp-搭建wordpress博客站点插图(5)

70-lnmp-搭建wordpress博客站点插图(6)

#部署PowerDNS
#安装包
[root@C7-3 discuz]# yum install -y pdns pdns-backend-mysql


[root@C7-3 discuz]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
…………………….
MariaDB [(none)]> create database powerdns;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on powerdns.* to powerdns@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit;
Bye


#配置PowerDNS使用 mariadb 作为后台数据存储
[root@C7-3 discuz]# vim /etc/pdns/pdns.conf
#跳到第250行将其注释并编写其他内容
250 #launch=bind
251 launch=gmysql
252 gmysql-host=localhost
253 gmysql-port=3306
254 gmysql-dbname=powerdns
255 gmysql-user=powerdns
256 gmysql-password=123456


#过滤查看
[root@C7-3 discuz]# egrep -v "^#|^$" /etc/pdns/pdns.conf 
launch=gmysql
gmysql-host=localhost
gmysql-port=3306
gmysql-dbname=powerdns
gmysql-user=powerdns
gmysql-password=123456
setgid=pdns
setuid=pdns


#设置服务开机自启
[root@C7-3 discuz]# systemctl enable --now pdns mariadb httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/pdns.service to /usr/lib/systemd/system/pdns.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

#安装php相关依赖包
[root@C7-3 discuz]# yum -y install php-devel php-gd php-mcrypt php-imap php-ldap php-odbc php-pear php-xmlrpc php-mbstring php-mhash gettext

#上传poweradmin包至该目录
[root@C7-3 discuz]# cd /usr/src/
[root@C7-3 src]# ll power*
-rw-r--r-- 1 root root 296469 Jun  4 15:55 poweradmin-2.1.7.tgz

#解压至/var/www/html
[root@C7-3 src]# tar xf poweradmin-2.1.7.tgz -C /var/www/html/
[root@C7-3 src]# cd /var/www/html/
[root@C7-3 html]# mv poweradmin-2.1.7 poweradmin

PowerDNS 安装向导

#在浏览器输入:192.168.124.13/poweradmin

70-lnmp-搭建wordpress博客站点插图(7)

#浏览器很有可能会出现此类报错,但不必担心
#重启httpd服务,然后重新搜索
[root@C7-3 html]# systemctl restart httpd

70-lnmp-搭建wordpress博客站点插图(8)

#下一步

70-lnmp-搭建wordpress博客站点插图(9)

#下一步

70-lnmp-搭建wordpress博客站点插图(10)

#下一步

70-lnmp-搭建wordpress博客站点插图(11)

#下一步

70-lnmp-搭建wordpress博客站点插图(12)

#下一步

70-lnmp-搭建wordpress博客站点插图(13)

[root@C7-3 html]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
…………#粘贴上面复制的内容回车即可
MariaDB [(none)]> GRANT SELECT, INSERT, UPDATE, DELETE
    -> ON powerdns.*
    -> TO 'poweradmin'@'localhost'
    -> IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit;
Bye
#下一步

70-lnmp-搭建wordpress博客站点插图(14)

[root@C7-3 html]# cd /var/www/html/poweradmin/inc/
[root@C7-3 inc]# mv config-me.inc.php config.inc.php
[root@C7-3 inc]# vim config.inc.php
$db_host = 'localhost';
$db_port = '';
$db_user = 'poweradmin';
$db_pass = '123456';
$db_name = 'powerdns';
$db_type = 'mysql';
//$db_file              = '';           # used only for SQLite, provide full path to database file
//$db_debug             = false;        # show all SQL queries
$db_layer               = 'PDO';        # or MDB2
//$db_ssl_ca            = '';
// Security settings
// This should be changed upon install
$session_key = 'BjeGo!nT{]qq$}8unW}eiYjIg!*VX~_erhoFsPI~g$$dWz';
$password_encryption = 'md5'; // or md5salt

// Interface settings
$iface_lang = 'en_EN';
$iface_style = 'example';
$iface_rowamount = 50;
$iface_expire = 1800;
$iface_zonelist_serial = false;
$iface_title = 'Poweradmin';
$iface_add_reverse_record = true;

// Predefined DNS settings
$dns_hostmaster = 'powerdnsserver';
$dns_ns1 = '192.168.124.13';
$dns_ns2 = '192.168.124.13';
#下一步

70-lnmp-搭建wordpress博客站点插图(15)

#安装完成,现在必须删掉install目录
[root@C7-3 inc]# rm -rf /var/www/html/poweradmin/install/

#在浏览器输入:192.168.124.13/poweradmin
#输入admin和密码,点击Go继续
70-lnmp-搭建wordpress博客站点插图(16)

70-lnmp-搭建wordpress博客站点插图(17)

#测速
[root@C7-3 inc]# ab -c10 -n 100 http://192.168.124.13/poweradmin
………………………………
Concurrency Level:      10
Time taken for tests:   0.040 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Non-2xx responses:      100
Total transferred:      48400 bytes
HTML transferred:       24100 bytes
Requests per second:    2519.65 [#/sec] (mean)
Time per request:       3.969 [ms] (mean)
Time per request:       0.397 [ms] (mean, across all concurrent requests)
Transfer rate:          1190.93 [Kbytes/sec] received
………………….

php加速器

#通常情况下php访问速度较慢,因此
#php加速器:基于PHP的特殊机制如opcode缓存扩展能够将opcode缓存于php的共享内存中
#从而让同一段代码的后续重复执行时跳过编译阶段以提高性能
#这些加速器并非真正提高了opcode的运行速度,仅仅只是通过分析opcode并将它们重新排序
#以达到快速执行的目的
#安装清华源
[root@C7-3 inc]# yum -y install https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm
[root@C7-3 inc]# yum -y install php56-php php56-php-mysqlnd

[root@C7-3 inc]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
………….
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on wordpress.* to wordpress@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> exit;
Bye


#上传wordpress包至此目录
[root@C7-3 inc]# cd /usr/src/
[root@C7-3 src]# ls word*
wordpress-5.2.4-zh_CN.tar.gz

#解压至/var/www/html/ 并修改属主属组
[root@C7-3 src]# tar xf wordpress-5.2.4-zh_CN.tar.gz -C /var/www/html/
[root@C7-3 src]# cd /var/www/html/
[root@C7-3 html]# chown -R apache:apache wordpress/
[root@C7-3 html]# ll wordpress/ -d
drwxr-xr-x 5 apache apache 4096 Nov 14  2019 wordpress/


#上传xcache,解压、编译安装
[root@C7-3 html]# cd /usr/src/
[root@C7-3 src]# ls xca*
xcache-3.2.0.tar.gz

[root@C7-3 src]# tar xf xcache-3.2.0.tar.gz 
[root@C7-3 src]# cd xcache-3.2.0

[root@C7-3 xcache-3.2.0]# /opt/remi/php56/root/usr/bin/phpize 
Can't find PHP headers in /opt/remi/php56/root/usr/include/php
The php56-php-devel package is required for use of this command.

#报错,缺失依赖包
[root@C7-3 xcache-3.2.0]# yum -y install php56-php-devel


#重新执行
[root@C7-3 xcache-3.2.0]# /opt/remi/php56/root/usr/bin/phpize 
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226


[root@C7-3 xcache-3.2.0]# ./configure --enable-xcache --with-phpconfig=/opt/remi/php56/root/usr/bin/php-config

[root@C7-3 xcache-3.2.0]# make && make install



[root@C7-3 xcache-3.2.0]# cat xcache.ini >> /opt/remi/php56/root/etc/php.ini 
[root@C7-3 xcache-3.2.0]# cp xcache.ini /etc/php.d/


[root@C7-3 xcache-3.2.0]# ab -c20 -n 100 http://192.168.124.13/poweradmin
…………………………….
Concurrency Level:      20
Time taken for tests:   0.042 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Non-2xx responses:      100
Total transferred:      48400 bytes
HTML transferred:       24100 bytes
Requests per second:    2365.35 [#/sec] (mean)
Time per request:       8.455 [ms] (mean)
Time per request:       0.423 [ms] (mean, across all concurrent requests)
Transfer rate:          1118.00 [Kbytes/sec] received
………………………………..
#浏览器输入:http://192.168.124.13/wordpress

70-lnmp-搭建wordpress博客站点插图(18)

#CentOS7默认yum安装的php版本为5.4,所以我们必须升级php
#首先移除系统自带的php-common
[root@C7-3 ~]# yum remove php-common -y

#更新软件源
[root@C7-3 ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
[root@C7-3 ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

#安装依赖包
[root@C7-3 ~]# yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring

[root@C7-3 ~]# yum provides php-fpm
…………..
php56w-fpm-5.6.40-1.w7.x86_64 : PHP FastCGI Process Manager
Repo        : webtatic
Matched from:
Provides    : php-fpm = 5.6.40-1.w7
…………………………..

[root@C7-3 ~]# yum install -y php56w-fpm-5.6.40-1.w7.x86_64


#确保运行php-fpm进程的用户对session目录有读写权限
[root@C7-3 ~]# ll /var/lib/php/session/ -d
drwxrwx--- 2 root apache 45 Jan 12  2019 /var/lib/php/session/


[root@C7-3 ~]# egrep -v "^;|^$|^ " /etc/php-fpm.d/www.conf 
[www]
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 500
pm.start_servers = 100
pm.min_spare_servers = 100
pm.max_spare_servers = 200
pm.max_requests = 500000
pm.status_path = /pm_status
ping.path = /ping
ping.response = ping-pong
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache
#文件说明

70-lnmp-搭建wordpress博客站点插图(19)

#HTTPD服务器上必须启用proxy_fcgi_module模块,才能充当php-fpm客户端
[root@C7-3 ~]# httpd -M |grep fcgi
[Fri Jun 05 09:31:41.248328 2020] [so:warn] [pid 19072] AH01574: module php5_module is already loaded, skipping
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe55:30b8. Set the 'ServerName' directive globally to suppress this message proxy_fcgi_module (shared) [root@C7-3 ~]# httpd -M |grep proxy_fcgi_module [Fri Jun 05 09:32:15.521225 2020] [so:warn] [pid 19103] AH01574: module php5_module is already loaded, skipping AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe55:30b8. Set the 'ServerName' directive globally to suppress this message
 proxy_fcgi_module (shared)

[root@C7-3 ~]# cat /etc/httpd/conf.modules.d/00-proxy.conf |grep proxy_fcgi_module
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so



[root@C7-3 ~]# vim /etc/httpd/conf.d/fcig.conf
DirectoryIndex index.php

#是否开启正向代理
ProxyRequests Off

#开启FCGI反向代理,“^/”这处的”/“相对于后面的/var/www/html而言,后面的$1是指前面 的/(.*.php) 
ProxyPassMatch ^/(.*\.php)$  fcgi://127.0.0.1:9000/var/www/html/$1


#启动php-fpm
[root@C7-3 ~]# systemctl start php-fpm.service


#重启httpd服务
systemctl restart httpd

wordpress安装向导

#浏览器输入:http://192.168.124.13/wordpress

70-lnmp-搭建wordpress博客站点插图(20)

70-lnmp-搭建wordpress博客站点插图(21)

70-lnmp-搭建wordpress博客站点插图(22)

70-lnmp-搭建wordpress博客站点插图(23)

70-lnmp-搭建wordpress博客站点插图(24)

70-lnmp-搭建wordpress博客站点插图(25)

70-lnmp-搭建wordpress博客站点插图(26)

#登陆之后;主页面展现

70-lnmp-搭建wordpress博客站点插图(27)

跳至文章页尾

没有账号? 忘记密码?

社交账号快速登录