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