zabbix安裝篇之lnmp

zabbix 監控安裝配置之lnmp搭建

說明:

    在使用zabbix監控時候,我們第一步是需要配置個php 運行環境,我們可以採用lamp或lnmp,本文采用lnmp環境。

約定:

    1. CentOS 6.5 x86_64

    2. nginx 1.6.2

    3. PHP 5.5.19

    4. FastCGI

步驟:

    1. nginx

       a. 達到nginx支持urlrewrite、gzip壓縮、ssl、nginx status等

       b. 過程:

# rpm -ivh http://mirrors.ustc.edu.cn/epel/6Server/x86_64/epel-release-6-8.noarch.rpm
# yum install zlib-devel pcre-devel openssl-devel -y
# cd /usr/local/src
# wget http://nginx.org/download/nginx-1.6.2.tar.gz
# tar xzvf nginx-1.6.2.tar.gz
# cd nginx-1.6.2
# useradd -M -s /sbin/nologin nginx
# ./configure --prefix=/opt/nginx  --with-zlib=  --with-pcre  --with-http_ssl_module --with-openssl= --user=nginx --group=nginx --with-http_stub_status_module
# make && make install clean

      c. 啓動nginx

# /opt/nginx/sbin/nginx

    2. MySQL

        a. 安裝  

# yum install mysql-server mysql-devel -y

        b. 啓動

# service mysqld start
# chkconfig mysqld on
# mysql_secure_installation   ---一步一來,設置root密碼等

    3. PHP

        a. php編譯依賴的庫

# yum install libxml2-devel bzip2-devel libcurl-devel libjpeg-devel freetype libjpeg-develbpng-devel libmcrypt-devel

        b. 下載安裝PHP

# cd /usr/local/src
# wget http://cn2.php.net/distributions/php-5.5.19.tar.bz2
# tar xjvf php-5.5.19.tar.bz2
# cd php-5.5.19
# useradd -M -s /sbin/nologin php-fpm
# ./configure --prefix=/opt/php   --with-mcrypt --enable-mbstring --enable-pdo --with-curl --disable-debug --enable-inline-optimization --with-bz2  --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli  --enable-fpm --with-gd   --with-freetype-dir --with-jpeg-dir --with-png-dir --with-gettext --enable-xmlwriter --enable-xmlreader --enable-ctype --with-config-file-path=/opt/php/etc --enable-bcmath
# make && make install

        c. 啓動FastCGI

# cp php.ini-production  /opt/php/etc/php.ini
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm
# cp sapi/fpm/php-fpm.conf /opt/php/etc/phhp-fpm.conf
# sed -i 's/\;pid/pid/;s/user\ =\ nobody/user\ =\ php-fpm/; s/group\ =\ nobody/group\ =\ php-fpm/' /opt/php/etc/php-fpm.conf
# service php-fpm start

    4. nginx 支持FastCGI

        a. 取消註釋

# vim /opt/nginx/conf/nginx.conf
location ~ \.php$ {
              root           html;
              fastcgi_pass   127.0.0.1:9000;
              fastcgi_index  index.php;
              #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
              fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
              include        fastcgi_params;
}

        b. 平滑重啓nginx

# kill -HUP `ps -ef | grep -P 'nginx:\s+master'|awk '{print $2}'`

    5. 測試:

# vim /opt/nginx/html/test.php
<?php
  phpinfo();
?>
# service iptables stop

用瀏覽器打開測試下

        http//192.168.0.100/test.php



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章