一、拓扑图
二、准备工作:
1.三台独立主机(虚拟机)
Nginx:10.0.0.11
PHP-fpm:10.0.0.2
mariadb:10.0.0.13
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.安装
@H_403_71@yuminstallNginx-y @H_403_71@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.创建相应的目录
@H_403_71@mkdir/web/www/-pv echoNginxwebtest>>/web/www/4.启动Nginx服务并测试
@H_403_71@systemctlstartNginx2.PHP-fpm主机操作
1.安装
@H_403_71@yuminstallPHP-fpmPHP-MysqLPHP-mbstringPHP-mcryptPHP-xcache-y修改图中三处位置
3.启动PHP-fpm服务
@H_403_71@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:::* @H_403_71@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.安装
@H_403_71@yuminstallmariadb-server-y @H_403_71@vi/etc/my.cnf.d/server.cnf #thisisonlyfortheMysqLdstandalonedaemon [MysqLd] skip_name_resolve=ON innodb_file_per_table=ON3.安全加固
@H_403_71@MysqL_secure_installation @H_403_71@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.解压
@H_403_71@tar-xfPHPMyAdmin-4.0.10.20-all-languages.tar.gz3.创建软链接(因为名字太长)
@H_403_71@ln-svPHPMyAdmin-4.0.10.20-all-languages.tar.gzpma4.更改名字
@H_403_71@cdpma cpconfig.sample.inc.PHPconfig.inc.PHP5.编辑配置文件
修改图中两处信息
第一处为随机加入字符,加密作用
第二处为加入数据库ip地址
6.测试
5.安装wordpress
1.准备工作
下载wordpress(https://wordpress.org/download/)
Nginx主机以及PHP主机都要安装wordpress以及进行下面的操作。解压文件分别放在对应的站点目录中。
Nginx站点目录:/web/www PHP-fpm站点目录:/web/www/PHP
2.解压wordpress
@H_403_71@tar-xvfwordpress-4.7.4-zh_CN.tar.gz 修改图中四处信息,分别为:数据库名称,用户名,密码,以及数据库主机ip地址
4.测试页面