1、编译安装nginx前安装依赖
yum install openssl-devel openssl yum install pcre pcre-devel zlib zlib-devel
2、安装pcre
[root@zabbix-service src]# pwd /usr/local/src [root@zabbix-service src]# tar xf pcre-8.30.tar.gz [root@zabbix-service src]# cd pcre-8.30 [root@zabbix-service pcre-8.30]# ./configure [root@zabbix-service pcre-8.30]# make && make install
3、安装nginx
[root@zabbix-service nginx-1.8.1]# pwd /usr/local/src/nginx-1.8.1 [root@zabbix-service nginx-1.8.1]# useradd -s /sbin/nologin nginx [root@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
[root@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
[root@zabbix-service src]# pwd /usr/local/src [root@zabbix-service src]# tar xf mysql-5.6.30.tar.gz [root@zabbix-service src]# cd mysql-5.6.30 [root@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
[root@zabbix-service mysql-5.6.30]# make && make install
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、安装步骤如下
[root@zabbix-service freetype-2.3.10]# ./configure --prefix=/usr/local/freetype [root@zabbix-service freetype-2.3.10]# make && make install
[root@zabbix-service gd-2.0.33]# ./configure --prefix=/usr/local/gd [root@zabbix-service gd-2.0.33]# make && make install
[root@zabbix-service jpeg-7]# ./configure --prefix=/usr/local/jpeg-7 [root@zabbix-service jpeg-7]# make && make install
[root@zabbix-service libiconv-1.14]# ./configure --prefix=/usr/local/libiconv [root@zabbix-service libiconv-1.14]# make && make install
[root@zabbix-service libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt [root@zabbix-service libmcrypt-2.5.7]# make && make install [root@zabbix-service libpng-1.2.41]# ./configure --prefix=/usr/local/libpng [root@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
[root@zabbix-service php-5.4.13]# pwd /usr/local/src/php/php-5.4.13 [root@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的配置文件和启动脚本
[root@zabbix-service etc]# pwd /usr/local/php/etc [root@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
-rwxr-xr-x. 1 root root 2.3K Jun 8 2016 php-fpm [root@zabbix-service init.d]# pwd /etc/init.d
7、nginx配置php关联
#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虚拟目录
[root@zabbix-service vhosts]# pwd /etc/nginx/vhosts [root@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
[root@zabbix-service zabbix-3.0.3]# pwd /usr/local/src/zabbix-3.0.3 [root@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 [root@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数据表结构
[root@zabbix-service frontends]# pwd /usr/local/src/zabbix-3.0.3/frontends [root@zabbix-service frontends]# cp -rf php/* /var/www/zabbix/
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/p_w_picpaths.sql;
11、修改配置文件
[root@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
[root@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;