1、编译安装nginx前安装依赖
yum install openssl-devel openssl yum install pcre pcre-devel zlib zlib-devel
2、安装pcre
1
2
3
4
5
6
| [iyunv@zabbix-service src]# pwd
/usr/local/src
[iyunv@zabbix-service src]# tar xf pcre-8.30.tar.gz
[iyunv@zabbix-service src]# cd pcre-8.30
[iyunv@zabbix-service pcre-8.30]# ./configure
[iyunv@zabbix-service pcre-8.30]# make && make install
|
3、安装nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [iyunv@zabbix-service nginx-1.8.1]# pwd
/usr/local/src/nginx-1.8.1
[iyunv@zabbix-service nginx-1.8.1]# useradd -s /sbin/nologin nginx
[iyunv@zabbix-service nginx-1.8.1]# ./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre
|
1
| [iyunv@zabbix-service nginx-1.8.1]# make && make install
|
4、配置nginx启动脚本
ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 //32bit系统
ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 //64bit系统
chmod +x /etc/init.d/nginx
chkconfig --add nginx chkconfig nginx on
5、编译安装mysql5.6
a、安装依赖
yum -y install make gcc-c++ cmake bison-devel ncurses-devel b、编译安装mysql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [iyunv@zabbix-service src]# pwd
/usr/local/src
[iyunv@zabbix-service src]# tar xf mysql-5.6.30.tar.gz
[iyunv@zabbix-service src]# cd mysql-5.6.30
[iyunv@zabbix-service mysql-5.6.30]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
|
1
| [iyunv@zabbix-service mysql-5.6.30]# make && make install
|
1
2
3
4
5
6
| groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig mysqld on
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
|
6、编译安装php5.4(编译安装php,这个环境真心,总会报错的,只能缺什么就补什么)
a、安装如下包
b、安装步骤如下
1
2
| [iyunv@zabbix-service freetype-2.3.10]# ./configure --prefix=/usr/local/freetype
[iyunv@zabbix-service freetype-2.3.10]# make && make install
|
1
2
| [iyunv@zabbix-service gd-2.0.33]# ./configure --prefix=/usr/local/gd
[iyunv@zabbix-service gd-2.0.33]# make && make install
|
1
2
| [iyunv@zabbix-service jpeg-7]# ./configure --prefix=/usr/local/jpeg-7
[iyunv@zabbix-service jpeg-7]# make && make install
|
1
2
| [iyunv@zabbix-service libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[iyunv@zabbix-service libiconv-1.14]# make && make install
|
1
2
3
4
5
6
7
8
9
10
| [iyunv@zabbix-service libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt
[iyunv@zabbix-service libmcrypt-2.5.7]# make && make install
[iyunv@zabbix-service libpng-1.2.41]# ./configure --prefix=/usr/local/libpng
[iyunv@zabbix-service libpng-1.2.41]# make && make install
yum -y install bzip2-devel
yum -y install libxml2
yum -y install libxml2-devel
yum -y install curl-devel
yum install php-mcrypt libmcrypt libmcrypt-devel
|
c、开始编译安装php5.4
1
2
3
| [iyunv@zabbix-service php-5.4.13]# pwd
/usr/local/src/php/php-5.4.13
[iyunv@zabbix-service php-5.4.13]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir--with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts --with-curl --with-libmcrypt
|
d、设置php的配置文件和启动脚本
1
2
3
4
5
6
| [iyunv@zabbix-service etc]# pwd
/usr/local/php/etc
[iyunv@zabbix-service etc]# ll
total 52
-rw-r--r--. 1 root root 1148 Apr 28 04:31 pear.conf
-rw-r--r--. 1 root root 22794 Jun 8 2016 php-fpm.conf
|
1
2
3
| -rwxr-xr-x. 1 root root 2.3K Jun 8 2016 php-fpm
[iyunv@zabbix-service init.d]# pwd
/etc/init.d
|
7、nginx配置php关联
1
2
3
4
5
| #upstream php
upstream php {
server 127.0.0.1:9000 max_fails=0;
server 127.0.0.1:9001 max_fails=0;
}
|
8、配置zabbix需要站点nginx虚拟目录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [iyunv@zabbix-service vhosts]# pwd
/etc/nginx/vhosts
[iyunv@zabbix-service vhosts]# cat monitor.conf
server {
listen 80;
server_name 10.0.20.88;
access_log logs/zabbix_access.log main;
error_log logs/zabbix_error.log;
location / {
root /var/www/zabbix;
index index.php index.html index.htm ;
}
location ~ \.php$ {
root /var/www/zabbix;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name ;
fastcgi_index index.php;
include fastcgi_params;
}
}
|
9、以上需要的LNMP环境安装好了,接下来就开始编译安装zabbix
1
2
3
4
| [iyunv@zabbix-service zabbix-3.0.3]# pwd
/usr/local/src/zabbix-3.0.3
[iyunv@zabbix-service zabbix-3.0.3]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --enable-java
[iyunv@zabbix-service zabbix-3.0.3]# make && make install
|
安装过程中报如下错
configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
解决办法
yum install net-snmp-devel -y
10、拷贝web站点代码,并且导入zabbix数据表结构
1
2
3
| [iyunv@zabbix-service frontends]# pwd
/usr/local/src/zabbix-3.0.3/frontends
[iyunv@zabbix-service frontends]# cp -rf php/* /var/www/zabbix/
|
1
2
3
4
5
6
| mysql> use mysql;
mysql> create database zabbix character set utf8;
mysql> use zabbix;
mysql> source /usr/local/src/zabbix-3.0.3/database/mysql/schema.sql;
mysql> source /usr/local/src/zabbix-3.0.3/database/mysql/data.sql;
mysql> source /usr/local/src/zabbix-3.0.3/database/mysql/images.sql;
|
11、修改配置文件
1
2
3
4
5
6
7
8
9
| [iyunv@localhost conf]# egrep -v "^$|^#" /usr/local/zabbix/etc/zabbix_server.conf
ListenPort=10051
LogFile=/tmp/zabbix_server.log
DBHost=127.0.0.1
DBName=zabbix
DBUser=root
DBSocket=/var/lib/mysql/mysql.sock
Timeout=4
LogSlowQueries=3000
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| [iyunv@localhost conf]# egrep -v "^$|^#" /var/www/zabbix/conf/zabbix.conf.php
<?php
// Zabbix GUI configuration file.
global $DB;
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = '127.0.0.1';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'root';
$DB['PASSWORD'] = '';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
$ZBX_SERVER = '192.168.100.123';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'baofoo';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
|
|