1、部署分离的LAMP,部署到二台服务器上,php加载xcache模块
1、环境:
两台机器:
192.168.43.137 httpd php-fpm php-mysql
192.168.43.108 mariadb
2、137上安装httpd、 php-fpm 、php-mysql
[root@ka2 conf.modules.d]#yum install httpd php-fpm php-mysql
3、创建session目录,确保运行php-fpm进程的用户对session目录有读写权限
[rot@ka2 conf.modules.d]#mkdir /var/lib/php/session
[root@ka2 conf.modules.d]#chown apache.apache /var/lib/php/session
4、创建httpd的fcgi配置文件,将访问.php文件指定到具体目录:
[root@ka2 conf.modules.d]#vim /etc/httpd/conf.d/fcgi.conf
DirectoryIndex index.php
ProxyRequests Off
ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/var/www/html/$1
5、验证http是否支持fcgi
[root@ka2 conf.modules.d]#httpd -M|grep fcgi
proxy_fcgi_module (shared)
6、重启httpd服务,启动php-fpm服务:
[root@ka1 conf.d]#systemctl restart httpd
[root@ka1 html]#systemctl start php-fpm
7、编译安装xcache:
[root@ka1 apps]#yum -y install php-devel
[root@ka1 apps]#phpize
[root@ka1 apps]#tar xvf /app/xcache-3.2.0.tar.gz -C /apps/
[root@ka1 apps]#cd xcache-3.2.0/
[root@ka1 xcache-3.2.0]#./configure --enable-xcache
[root@ka1 xcache-3.2.0]#make && make install
[root@ka1 xcache-3.2.0]#cp xcache.ini /etc/php.d/
[root@ka1 xcache-3.2.0]#ll /usr/lib64/php/modules/ |grep xcache
-rwxr-xr-x 1 root root 702000 Apr 9 21:53 xcache.so
[root@ka1 xcache-3.2.0]#systemctl restart httpd.service
8、在192.168.43.108上安装mariadb服务
[root@centos7 ~]#yum install mariadb-server
2、部署wordpress论坛,并实现正常访问登录论坛。
在1的环境之上
1、将wordpress-5.0.3-zh_CN.tar.gz 解压后放到http的默认站点/var/www/html/里:
2、确认httpd的fcgi配置:
[root@ka1 html]#cat /etc/httpd/conf.d/fcgi.conf
DirectoryIndex index.php
ProxyRequests Off
ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/var/www/html/$1
或者将wordpress的配置单独放在一个配置文件中:
3、创建wordpress所需的数据库和用户:
MariaDB [(none)]> create database wpdb;
Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> grant all privileges on wpdb.* to wpuser@'%' identified by "123456";
Query OK, 0 rows affected (0.00 sec)
4、将wordpress服务apache用户rwx权限:
[root@ka1 conf.d]#setfacl -R -m u:apache:rwx /apps/vhosts/wordpress
5、重启httpd服务:
[root@ka1 html]#systemctl restart httpd
6、访问http://192.168.43.137/wordpress 或者 wordpress.wang.com/wordpress,进行安装:
7、登录
3、收集apache访问日志,并实现图形化展示。
接着以上的实验环境:
192.168.43.137 日志服务器
192.168.43.108 mariadb服务器
1、在日志服务器137 上上安装mysql模块相关的程序包rsyslog-mysql:
#yum install rsyslog-mysql
#rpm -ql rsyslog-mysql
/usr/lib64/rsyslog/ommysql.so
/usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql
2、在108上授权rsyslog用户能连接至当前服务器:
MariaDB [(none)]> GRANT ALL ON Syslog.* TO 'Syslog'@'192.168.43.%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
3、在107上将/usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql导入到108的mariadb中,进行创建数据库:
#mysql -uSyslog -p123456 -h192.168.43.108 < /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql
4、改日志服务器rsyslog的配置文件/etc/rsyslog.conf
MODULES
$ModLoad ommysql
RULES ####将local5日志写到mysql数据库中
local5.* :ommysql:192.168.43.108,Syslog,Syslog,123456
重启rsyslog服务:
#systemctl restart rsyslog
5、修改日志服务器137上htpd配置,修改http的日志配置:
vim /etc/httpd/conf/httpd.conf
CustomLog "logs/access_log" combined
CustomLog "|/usr/bin/logger -p local5.info" combined重启httpd服务:
#systemctl restart httpd
6、日志服务器137上准备amp或nmp组合
yum install httpd php php-mysql php-gd
7、在日志服务器137上安装logLogAnalyzer:
#tar xf loganalyzer-4.1.7.tar.gz
#cp -a loganalyzer-4.1.7/src/ /apps/vhosts/loganalyzer
#cd /apps/vhosts/loganalyzer
#touch config.php
#chmod 666 config.php在http中添加虚拟主机:
[root@ka1 vhosts]#vim /etc/httpd/conf.d/vhosts.conf
<VirtualHost :80>
ServerName logs.wang.com
DocumentRoot /apps/vhosts/
ProxyRequests Off
ProxyPassMatch ^/(.
.php)$ fcgi://127.0.0.1:9000/apps/vhosts/$1
<Directory "/apps/vhosts/">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
改文件全新,否则报错
#chmod 777 /var/lib/php/session
修改hosts文件:
192.168.43.137 logs.wang.com
重启httpd:
systemctl start httpd.service
8、访问:http://logs.wang.com/Loganalyzer 进行安装
-----完成-----
架构班小伙伴看折柳:
1、创建jdk和tomcat镜像,使用 nginx + tomcat + NFS 实现web请求的动静分离
2、实现k8s一个pod多个容器实现LNMP的wordpress服务
来源:oschina
链接:https://my.oschina.net/u/4397718/blog/3288017