標籤:lnmp zabbix centos6.5
1.編譯安裝nginx
1)編譯安裝pcre。
nginx安裝需要pcre的支援。
[[email protected] ~]# mkdir -p /taokey/tools
[[email protected] ~]# cd /taokey/tools/
[[email protected] tools]# yum install -y gcc gcc-c++
[[email protected] tools]# tar -zxf pcre-8.33.tar.gz
[[email protected] tools]# cd pcre-8.33
[[email protected] pcre-8.33]# ./configure
[[email protected] pcre-8.33]# make && make install
[[email protected] pcre-8.33]# cd ..
1)建立nginx普通使用者。
[[email protected] ~]# useradd nginx -s /sbin/nologin -M
2)下載並解壓nginx源碼包。
[[email protected] tools]# wget http://nginx.org/download/nginx-1.6.3.tar.gz
[[email protected] tools]# tar -zxf nginx-1.6.3.tar.gz
[[email protected] tools]# cd nginx-1.6.3
[[email protected] nginx-1.6.3]# yum -y install openssl openssl-devel
3)編譯安裝nginx。
[[email protected] nginx-1.6.3]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
[[email protected] nginx-1.6.3]# make && make install
4)啟動nginx。
[[email protected] nginx-1.6.3]# echo /usr/local/lib >>/etc/ld.so.conf
[[email protected] nginx-1.6.3]# ldconfig
[[email protected] nginx-1.6.3]# /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
[[email protected] nginx-1.6.3]# /usr/local/nginx/sbin/nginx
[[email protected] nginx-1.6.3]# ps -ef | grep nginx
root 11456 1 0 14:39 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 11457 11456 0 14:39 ? 00:00:00 nginx: worker process
root 11459 1794 0 14:39 pts/1 00:00:00 grep nginx
2.yum安裝MySQL
[[email protected] ~]# yum install -y mysql-server mysql-devel mysql
[[email protected] ~]# /etc/init.d/mysqld start
[[email protected] ~]# ps -ef | grep mysql
root 11567 1 0 14:41 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 11669 11567 1 14:41 pts/1 00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root 11693 1794 0 14:42 pts/1 00:00:00 grep mysql
[[email protected] ~]# netstat -anpt | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 11669/mysqld
3.yum安裝PHP。
[[email protected] ~]# yum install -y php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm php-pecl*
[[email protected] ~]# sed -i ‘s/^user =.*/user = nginx/g‘ /etc/php-fpm.d/www.conf
[[email protected] ~]# sed -i ‘s/^group =.*/group = nginx/g‘ /etc/php-fpm.d/www.conf
[[email protected] ~]# /etc/init.d/php-fpm start
正在啟動 php-fpm:[確定]
[[email protected] ~]# ps -ef | grep php
root 11746 1 0 14:45 ? 00:00:00 php-fpm: master process (/etc/php-fpm.conf)
nginx 11747 11746 0 14:45 ? 00:00:00 php-fpm: pool www
nginx 11748 11746 0 14:45 ? 00:00:00 php-fpm: pool www
nginx 11749 11746 0 14:45 ? 00:00:00 php-fpm: pool www
nginx 11750 11746 0 14:45 ? 00:00:00 php-fpm: pool www
nginx 11751 11746 0 14:45 ? 00:00:00 php-fpm: pool www
root 11754 1794 0 14:45 pts/1 00:00:00 grep php
4.配置nginx,結合php環境、
vi /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include fastcgi.conf;
}
}
[[email protected] ~]# /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
[[email protected] ~]# /usr/local/nginx/sbin/nginx -s reload
5.測試一下php環境是否可以正常運行。
[[email protected] ~]# cat > /usr/local/nginx/html/index.php <<EOF
<?php
phpinfo();
?>
EOF
6.安裝zabbix server端軟體包。
1)安裝相應的庫和軟體包,並且建立zabbix使用者。
[[email protected] ~]# yum -y install libcurl-devel net-snmp-devel
[[email protected] ~]# useradd zabbix -s /sbin/nologin
2.下載zabbix源碼包,編譯安裝zabbix
[[email protected] tools]# tar -zxf zabbix-2.4.0.tar.gz
[[email protected] tools]# cd zabbix-2.4.0
[[email protected] zabbix-2.4.0]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
[[email protected] zabbix-2.4.0]# make install
7.在MySQL中建立zabbix所需資料庫,以及帳號密碼;
[[email protected] zabbix-2.4.0]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to [email protected]‘%‘ identified by ‘zabbix‘;
Query OK, 0 rows affected (0.01 sec)
mysql> delete from mysql.user where user="";
Query OK, 2 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
8.zabbix資料匯入建立好的zabbix資料庫中。
[[email protected] zabbix-2.4.0]# mysql -uzabbix -pzabbix -h127.0.0.1 zabbix < database/mysql/schema.sql
[[email protected] zabbix-2.4.0]# mysql -uzabbix -pzabbix -h127.0.0.1 zabbix < database/mysql/images.sql
[[email protected] zabbix-2.4.0]# mysql -uzabbix -pzabbix -h127.0.0.1 zabbix < database/mysql/data.sql
9.拷貝zabbix服務端和用戶端的開機檔案。
[[email protected] zabbix-2.4.0]# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/
[[email protected] zabbix-2.4.0]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
10.修改設定檔及開機檔案
[[email protected] zabbix-2.4.0]# sed -i ‘s/^DBUser=.*$/DBUser=zabbix/g‘ /usr/local/zabbix/etc/zabbix_server.conf
[[email protected] zabbix-2.4.0]# sed -i ‘s/^.*DBPassword=.*$/DBPassword=zabbix/g‘ /usr/local/zabbix/etc/zabbix_server.conf
[[email protected] zabbix-2.4.0]# sed -i ‘s/^.*DBHost=.*$/DBHost=127.0.0.1/g‘ /usr/local/zabbix/etc/zabbix_server.conf
[[email protected] zabbix-2.4.0]# sed -i ‘s/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g‘ /etc/init.d/zabbix_server
[[email protected] zabbix-2.4.0]# sed -i ‘s/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g‘ /etc/init.d/zabbix_agentd
11.在/etc/services檔案中,添加zabbix服務連接埠
[[email protected] zabbix-2.4.0]# cat >>/etc/services <<EOF
> zabbix-agent 10050/tcp Zabbix Agent
> zabbix-agent 10050/udp Zabbix Agent
> zabbix-trapper 10051/tcp Zabbix Trapper
> zabbix-trapper 10051/udp Zabbix Trapper
> EOF
[[email protected] zabbix-2.4.0]# tail -4 /etc/services
zabbix-agent 10050/tcp Zabbix Agent
zabbix-agent 10050/udp Zabbix Agent
zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper
12.複製zabbix程式檔案端到nginx的指定web目錄下,並且設定相應許可權
[[email protected] zabbix-2.4.0]# cp -ra frontends/php/ /usr/local/nginx/html/zabbix
[[email protected] zabbix-2.4.0]# chown -R nginx.nginx /usr/local/nginx/html/zabbix
13.啟動zabbix server和zabix agent。
[[email protected] zabbix-2.4.0]# /etc/init.d/zabbix_server start
[[email protected] zabbix-2.4.0]# /etc/init.d/zabbix_agentd start
[[email protected] zabbix-2.4.0]# netstat -anpt | grep 10050
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 19850/zabbix_agentd
[[email protected] zabbix-2.4.0]# netstat -anpt | grep 10051
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 19786/zabbix_server
tcp 0 0 127.0.0.1:10051 127.0.0.1:37229 TIME_WAIT -
14.在瀏覽器中輸入:http://192.168.1.40/zabbix/setup.php 安裝zabbix server的web介面。
15.修改php配置滿足zabbix安裝要求。
[[email protected] zabbix-2.4.0]# sed -i ‘s/^\(.*\)date.timezone =.*$/date.timezone = Asia\/Shanghai/g‘ /etc/php.ini
[[email protected] zabbix-2.4.0]# sed -i ‘s/^\(.*\)post_max_size =.*$/post_max_size = 16M/g‘ /etc/php.ini
[[email protected] zabbix-2.4.0]# sed -i ‘s/^\(.*\)max_execution_time =.*$/max_execution_time = 300/g‘ /etc/php.ini
[[email protected] zabbix-2.4.0]# sed -i ‘s/^\(.*\)max_input_time =.*$/max_input_time = 300/g‘ /etc/php.ini
[[email protected] zabbix-2.4.0]# /etc/init.d/php-fpm restart
停止 php-fpm:[確定]
正在啟動 php-fpm:[確定]
本文出自 “創者思” 部落格,請務必保留此出處http://strongit.blog.51cto.com/10020534/1638110
Centos 6.5系統lnmp環境搭建zabbix2.4