安装流程
1)安装LNMP环境
Zabbix监控管理控制台需要通过Web页面展示出来,并且还需要使用MySQL来存储数据,因此需要先为Zabbix准备基础LNMP环境。
[root@zabbixserver ~]# yum -y install gcc pcre-devel openssl-devel
[root@zabbixserver ~]# tar -xf nginx-1.12.2.tar.gz
[root@zabbixserver ~]# cd nginx-1.12.2
[root@zabbixserver nginx-1.12.2]# ./configure --with-http_ssl_module
[root@zabbixserver nginx-1.12.2]# make && make install
[root@zabbixserver ~]# yum -y install php php-mysql \
> mariadb mariadb-devel mariadb-server
[root@zabbixserver ~]# yum -y install php-fpm-5.4.16-42.el7.x86_64.rpm
//注意,php-fpm这个软件包在lnmp_soft/目录下
2)修改Nginx配置文件
配置Nginx支持PHP动态网站,因为有大量PHP脚本需要执行,因此还需要开启Nginx的各种fastcgi缓存,加速PHP脚本的执行速度。
[root@zabbixserver ~]# vim /usr/local/nginx/conf/nginx.conf
… …
http{
… …
fastcgi_buffers 8 16k; //缓存php生成的页面内容,8个16k
fastcgi_buffer_size 32k; //缓存php生产的头部信息
fastcgi_connect_timeout 300; //连接PHP的超时时间
fastcgi_send_timeout 300; //发送请求的超时时间
fastcgi_read_timeout 300; //读取请求的超时时间
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
… …
3)启动服务
启动Nginx、PHP-FPM、MariaDB服务,关闭SELinux与防火墙。
[root@zabbixserver ~]# systemctl start mariadb
[root@zabbixserver ~]# systemctl start php-fpm
[root@zabbixserver ~]# ln -s /usr/local/nginx/sbin/nginx /sbin/nginx
[root@zabbixserver ~]# nginx
[root@zabbixserver ~]# firewall-cmd --set-default-zone=trusted
[root@zabbixserver ~]# setenforce 0
4)客户端测试LNMP环境
服务器创建PHP测试页面,浏览器访问页面测试网页连通性。
[root@zabbixserver ~]# cat /usr/local/nginx/html/test.php
<?php
$i=33;
echo $i;
?>
[root@zabbixserver ~]# curl http://192.168.2.5/test.php
一键安装脚本
vim lnmp-setup.sh
#!/bin/bash
yum -y install gcc pcre-devel openssl-devel
tar -xf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --with-http_ssl_module
make;make install
yum -y install php php-mysql mariadb mariadb-devel mariadb-server php-fpm
sed -i "65,68s/#//" /usr/local/nginx/conf/nginx.conf
sed -i "70,71s/#//" /usr/local/nginx/conf/nginx.conf
sed -i 's/fastcgi_params/fastcgi.conf/' /usr/local/nginx/conf/nginx.conf
systemctl start mariadb php-fpm
/usr/local/nginx/sbin/nginx
firewall-cmd --set-default-zone=trusted
setenforce 0
#写个php测试文件test.php
#测试
curl 127.0.0.1/test.php