CentOS 7.4 yum方式搭建LNMP环境,部署WordPress博客,并安装XCache模块

一、演示环境:

IP

安装的程序包

版本

192.168.1.221

Nginxepel源)

1.12.2

PHP

5.4.16

PHP-fpmFastCGI进程管理器)

PHP-MysqLPHP连接MysqL时需要用到的驱动)

192.168.1.222

mariadb-server

5.5.56

备注:CentOS 7.4已经不再内置MysqL-server程序包

二、搭建LNMP

1、安装前准备:

(1)校对服务器时间

(2)配置epel

2、安装Nginx# yum -y install Nginx # systemctl start Nginx.service # ss -tunlp | grep :80

配置文件及目录:

Ø 配置文件/etc/Nginx/Nginx.conf

Ø 辅助配置文件/etc/Nginx/*

Ø 网页存放根目录:/usr/share/Nginx/html

3、安装PHP# yum -y install PHP配置文件/etc/PHP.ini

4、安装配置PHP-fpm

# yum -y install PHP-fpm

# vim /etc/PHP-fpm.d/www.conf修改以下参数的值:

listen = 192.168.1.221:9000 //PHP-fpm监听的地址端口

listen.allowed_clients = 192.168.1.221 //允许连接的FastCGI客户端地址

user = Nginx

group = Nginx

# systemctl start PHP-fpm.service

# ss -tunlp | grep :9000

配置文件

Ø 配置文件/etc/PHP-fpm.conf

Ø 辅助配置文件/etc/PHP-fpm.d/www.conf

5、安装配置mariadb

# yum -y install mariadb-server mariadb mariadb-devel

# systemctl start mariadb.service

# ss -tunlp | grep :3306

mariadb配置文件/etc/my.cnf

//修改mariadb数据库root用户密码为123456认为空)、删除匿名用户删除测试数据库、重载授权表

# MysqL_secure_installation

# MysqL -uroot -p


MariaDB [(none)]> grant all on *.* to 'root'@'192.168.%.%' identified by '123456'; //授权root用户远程登录

MariaDB [(none)]> flush privileges;

6、安装PHP-MysqL# yum -y install PHP-MysqL

7、配置Nginx支持PHP

# cd /etc/Nginx

# cp Nginx.conf Nginx.conf.bak

# vim Nginx.conf


# systemctl reload Nginx.service

# systemctl restart PHP-fpm.service

三、测试LNMP

# cd /usr/share/Nginx/html

# vim index.PHP

浏览器中输入http://192.168.1.221/index.PHP


停止192.168.1.222上的mariadb# systemctl stop mariadb.service


mariadbPHP通信正常

访问http://192.168.1.221



四、安装配置wordpress

wordpress是一种使用PHP语言和MariaDB数据库开发的开源、免费的Blog引擎,用户可以在支持PHPMariaDB数据库的服务器上建立自己的Blogwordpress一个功能非常强大的博客系统插件众多,易于扩展,安装和使用都非常方便。目前wordpress已经成为主流的Blog搭建平台。下载地址https://cn.wordpress.org/,此处以wordpress-4.8.1-zh_CN.zip为例。

# yum -y install unzip

# unzip -q wordpress-4.8.1-zh_CN.zip

# cp -a wordpress/ /usr/share/Nginx/html

# cd /usr/share/Nginx/html/wordpress

# cp wp-config-sample.PHP wp-config.php

# vim wp-config.php修改数据库相关信息:


# MysqL -uroot -p

MariaDB [(none)]> create database wpdb;

MariaDB [(none)]> grant all on wpdb.* to 'wpuser'@'%' identified by "123456";

MariaDB [(none)]> flush privileges;

# MysqL -uwpuser -p

MariaDB [(none)]> show databases;


修改Nginx配置文件,在index参数后新增index.PHP

# vim /etc/Nginx/Nginx.conf

location / {

index index.PHP index.html index.htm;

}

# systemctl reload Nginx.service

浏览器中输入http://192.168.1.221/wordpress


点击“安装wordpress”:


点击“登录”:


输入用户名和密码,点击“登录”:



删除安装文件# rm -rf /usr/share/Nginx/html/wordpress/wp-admin/install.PHP

博客前台登录地址http://192.168.1.221/wordpress/

博客后台管理地址http://192.168.1.221/wordpress/wp-admin/

五、安装XCache模块:

配置epel源,安装XCache# yum -y install PHP-xcache --> 3.1.1

# rpm -ql PHP-xcache --> /etc/PHP.d/xcache.ini/usr/lib64/PHP/modules/xcache.so

# systemctl restart PHP-fpm.service

已加载XCache相关模块:

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native