centos7.3搭建LNMP并部署wordpress站点
一、拓扑图

二、准备工作:
1.三台独立主机(虚拟机)
Nginx:10.0.0.11
PHP-fpm:10.0.0.2
mariadb:10.0.0.13
准备好yum环境(推荐阿里云yum源,请百度搜索)
2.相关的软件包准备
10.0.0.11(Nginx)
yum install Nginx -y
10.0.0.2(PHP-fpm)
yum install PHP-fpm PHP-MysqL PHP-mbstring PHP-mcrypt PHP-xcache -y
10.0.0.13(mariadb)
yum install mariadb-server -y
三、搭建步骤
1.Nginx主机操作
1.安装
yuminstallNginx-y
2.配置Nginx支持反向代理PHP-fpm
vi/etc/Nginx/conf.d/huwho.conf
server{
listen80;
server_namewww.huwho.com;#web站点域名
indexindex.PHPindex.htmlindex.htm;
#定义一个Nginx的web站点,放置web静态资源
location/{
root/web/www;
indexindex.htmlindex.htmindex.PHP;
}
#定义一个web状态页
location/status{
stub_status;
}
#passthePHPscriptstoFastCGIserverlisteningon10.0.0.2:9000
#反向代理PHP,放置web动态资源
location~*\.PHP${
root/web/www/PHP;#PHP的站点根目录
fastcgi_pass10.0.0.2:9000;#fastcgi的地址
fastcgi_indexindex.PHP;
fastcgi_paramSCRIPT_FILENAME/web/www/PHP/$fastcgi_script_name;
includefastcgi_params;
}
}
3.创建相应的目录
mkdir/web/www/-pv echoNginxwebtest>>/web/www/
4.启动Nginx服务并测试
systemctlstartNginx

2.PHP-fpm主机操作
1.安装
yuminstallPHP-fpmPHP-MysqLPHP-mbstringPHP-mcryptPHP-xcache-y
2.PHP-fpm配置文件修改
修改图中三处位置
vi/etc/PHP-fpm.d/www.conf


3.启动PHP-fpm服务
systemctlstartPHP-fpm [root@localhost~]#ss-tln StateRecv-QSend-QLocalAddress:PortPeerAddress:Port LISTEN0128*:111*:* LISTEN05192.168.122.1:53*:* LISTEN0128*:22*:* LISTEN0128127.0.0.1:631*:* LISTEN0100127.0.0.1:25*:* LISTEN012810.0.0.2:9000*:* LISTEN0128:::111:::* LISTEN0128:::22:::* LISTEN0128::1:631:::* LISTEN0100::1:25:::*
4.创建动态资源目录,以及一个index.PHP文件做测试
mkdir/web/www/PHP-pv
cd/web/www/PHP
viindex.PHP
<h1>welcometowww.huwho.comwebsite.</h1>
<?PHP
$conn=MysqL_connect('10.0.0.13','jerry','123456');
if($conn)
echo"It'sok";
else
echo"bad";
PHPinfo();
?>

3.MysqL主机操作
1.安装
yuminstallmariadb-server-y
2.MysqL配置文件修改
vi/etc/my.cnf.d/server.cnf #thisisonlyfortheMysqLdstandalonedaemon [MysqLd] skip_name_resolve=ON innodb_file_per_table=ON
3.安全加固
MysqL_secure_installation
4.建立一个用户以及数据库
grantallonwordpress.*to'jerry'@'10.0.%.%'identifiedby'123456';
4.安装PHPMyAddmin数据库管理工具(PHP-fpm主机中操作)
1.下载PHPMyAdmin-4.0.10.20-all-languages.tar.gz
下载地址https://www.PHPmyadmin.net/
2.解压
tar-xfPHPMyAdmin-4.0.10.20-all-languages.tar.gz
3.创建软链接(因为名字太长)
ln-svPHPMyAdmin-4.0.10.20-all-languages.tar.gzpma
4.更改名字
cdpma cpconfig.sample.inc.PHPconfig.inc.PHP
5.编辑配置文件
修改图中两处信息
第一处为随机加入字符,加密作用
第二处为加入数据库ip地址
viconfig.inc.PHP

6.测试

5.安装wordpress
1.准备工作
下载wordpress(https://wordpress.org/download/)
Nginx主机以及PHP主机都要安装wordpress以及进行下面的操作。解压文件分别放在对应的站点目录中。
Nginx站点目录:/web/www PHP-fpm站点目录:/web/www/PHP
2.解压wordpress
tar-xvfwordpress-4.7.4-zh_CN.tar.gz
3.修改配置文件
修改图中四处信息,分别为:数据库名称,用户名,密码,以及数据库主机ip地址
cdwordpress/ cpwp-config-sample.PHPwp-config.php viwp-config.php

4.测试页面

