小雪崩 发表于 2019-1-19 08:12:00

zabbix监控之Centos基于LNMP环境安装

  本文描述zabbix在lnmp环境中的搭建过程,为减少配置难度,mysql,php采用yum安装。系统版本是centos6.4。
  本安装过程以直接高效的方式叙述。
  

1、Yum安装mysql
  mysql使用yum安装方式
yum install mysql-servermysql-devel mysql
/etc/init.d/mysqld start
2、Yum安装php
  yum安装后的php配置文件是/etc/php.ini。
yum install -y php php-mysqlphp-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpcphp-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm

sed -i 's/^user =.*/user =nginx/g' /etc/php-fpm.d/www.conf
sed -i 's/^group =.*/group =nginx/g' /etc/php-fpm.d/www.conf
/etc/init.d/php-fpm start
3、编译安装nginx
3.1 安装pcre
  nginx安装需要pcre的支持。
wgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
yum install gcc*   #解决编译无gcc包问题
tar -zxf pcre-8.33.tar.gz
cd pcre-8.33
./configure
echo $?
make && make install
3.2 安装nginx
wgethttp://nginx.org/download/nginx-1.4.7.tar.gz
useradd nginx -s /sbin/nologin-M
./configure --user=nginx--group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module--with-http_ssl_module
echo $?
make && make install
3.3 测试nginx
# /usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx:error while loading shared libraries: libpcre.so.1: cannot open shared objectfile: No such file or directory
echo /usr/local/lib>>/etc/ld.so.conf
ldconfig
# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file/usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file/usr/local/nginx/conf/nginx.conf test is successful
  #此时可以在浏览器输入nginx的IP地址。
  

4、配置nginx关联php
  4.1 修改nginx配置文件
  在nginx.conf中加入如下红色内容
vi/usr/local/nginx/conf/nginx.conf
    server {
      listen       80;
      server_namelocalhost;
      location / {
            root   html;
            indexindex.html index.htm index.php;
      }
      location ~ \.php$ {
            root         html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_indexindex.php;
            fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
            include      fastcgi_params;
            include      fastcgi.conf;
      }
}
  #红色这段作用是把php结尾的url交给php进程处理。
4.2 添加phpinfo
  创建phpinfo文件
cat >/usr/local/nginx/html/index.php
页: [1]
查看完整版本: zabbix监控之Centos基于LNMP环境安装