lanp
安装环境:
主机ip | 需要安装的服务 |
---|---|
192.168.120.11 | mysql php zabbix |
192.168.120.23 | nginx |
在11上安装服务
在23上安装nginx
- 安装开发工具
[root@localhost nginx-1.12.0]# yum groups mark install 'Development Tools'
yum -y install wget bzip2 bzip2-devel gcc gcc-c++
yum -y install gcc-c++ autoconf automake
- 创建用户
[root@localhost ~]# groupadd -r nginx
[root@localhost ~]# useradd -r -s /sbin/nologin -M -g nginx nginx
- 安装依赖包
yum -y install pcre-devel openssl openssl-devel gd-devel
- 创建日志存放目录
[root@localhost log]# mkdir /var/log/nginx
[root@localhost log]# chown -R nginx.nginx /var/log/nginx/
- 下载nginx,并安装
[root@localhost log]# cd /usr/src
[root@localhost src]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
[root@localhost src]# ls
a.pass debug kernels mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz nginx-1.12.0.tar.gz
[root@localhost nginx-1.12.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
[root@localhost ~]# make && make install
- 安装后配置
[root@localhost ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@localhost ~]# . /etc/profile.d/nginx.sh
- 启动服务
[root@localhost ~]# nginx
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
[root@localhost ~]#
- 修改php配置文件
[root@jun ~]# vim /usr/local/php7/etc/php-fpm.d/www.conf
listen = 192.168.120.11:9000 // 监听本机ip
listen.allowed_clients = 192.168.120.23 // 允许链接php服务的ip(nginx端ip)
- zabbix web界面安装配置
[root@jun php]# mkdir -pv /www/jun/zabbix
[root@jun php]# cp -a * /www/jun/zabbix
[root@jun php]# pwd
/usr/src/zabbix-4.0.3/frontends/php
- 安装nfs共享
[root@jun ~]# yum -y install nfs-utils
[root@jun ~]# systemctl start rpcbind nfs-server
[root@jun ~]# vim /etc/exports
[root@jun ~]# exportfs -r
[root@jun ~]# cat /etc/exports
/www/jun/zabbix 192.168.120.23(rw)
[root@jun ~]#
- 修改nginx配置为文件
#access_log logs/host.access.log main;
location / {
root html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /www/jun/zabbix;
fastcgi_pass 192.168.120.11:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/jun/zabbix$fastcgi_script_name;
include fastcgi_params;
}
- 挂载共享zabbix
[root@localhost ~]# yum -y install nfs-utils
[root@localhost ~]# mount -t nfs 192.168.120.11:/www/jun/zabbix /usr/local/nginx/html/
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 17G 4.7G 13G 28% /
devtmpfs devtmpfs 901M 0 901M 0% /dev
tmpfs tmpfs 912M 0 912M 0% /dev/shm
tmpfs tmpfs 912M 8.7M 903M 1% /run
tmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 143M 872M 15% /boot
tmpfs tmpfs 183M 0 183M 0% /run/user/0
192.168.120.11:/www/jun/zabbix nfs4 17G 6.0G 12G 35% /usr/local/nginx/html
- 重启服务
- 验证