lnmp

本文详细介绍了在两台不同IP的服务器上部署LAMP(Linux, Apache, MySQL, PHP)与Nginx的过程。在192.168.120.11上安装了MySQL, PHP与Zabbix,在192.168.120.23上安装了Nginx,并通过NFS共享实现了Zabbix Web界面的数据同步。


安装环境:

主机ip需要安装的服务
192.168.120.11mysql
php
zabbix
192.168.120.23nginx

在11上安装服务

  1. mysql安装
  2. php安装
  3. zabbix安装

在23上安装nginx

  1. 安装开发工具
[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

  1. 创建用户
[root@localhost ~]# groupadd -r nginx
[root@localhost ~]# useradd -r -s /sbin/nologin -M  -g nginx nginx

  1. 安装依赖包
yum -y install pcre-devel openssl openssl-devel gd-devel
  1. 创建日志存放目录
[root@localhost log]# mkdir /var/log/nginx
[root@localhost log]# chown -R nginx.nginx /var/log/nginx/

  1. 下载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
  1. 安装后配置
[root@localhost ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@localhost ~]# . /etc/profile.d/nginx.sh

  1. 启动服务
[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 ~]# 

  1. 修改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)

  1. 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

  1. 安装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 ~]# 

  1. 修改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;
        }

  1. 挂载共享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

  1. 重启服务
  2. 验证
    在这里插入图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值