1.安装tengine-2.1.2
yum -y install gcc gcc-c++ make pcre-devel openssl openssl-devel
tar xf tengine-2.1.2.tar.gz
groupadd nginx
useradd -g nginx nginx -s /sbin/nologin
cd tengine-2.1.2
./configure --prefix=/opt/www/nginx --sbin-path=/usr/sbin/nginx --conf-path=/opt/www/nginx/conf/nginx.conf --error-log-path=/data/ic/nginx/error_log/error.log --http-log-path=/data/ic/nginx/access_log/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_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_v2_module --with-http_sub_module --with-pcre
make && make install
2.安装php
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
tar xvf php-5.6.30.tar.gz
./configure --prefix=/opt/php --with-config-file-path=/opt/php/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/opt/php --with-png-dir=/opt/php --with-freetype-dir=/opt/php --enable-gd-native-ttf --with-iconv-dir=/opt/php --enable-calendar --with-gettext --with-libxml-dir=/opt/php --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath --enable-mbstring
make && make install
cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf
cp /opt/php-5.6.30/php.ini-production /opt/php/etc/php.ini
sed -i "s/post_max_size = 8M/post_max_size = 16M/g" /opt/php/etc/php.ini
sed -i "s/max_execution_time = 30/max_execution_time = 300/g" /opt/php/etc/php.ini
sed -i "s/max_input_time = 60/max_input_time = 300/g" /opt/php/etc/php.ini
sed -i "s/;date.timezone =/date.timezone = Asia\/Shanghai/g" /opt/php/etc/php.ini
sed -i "s/;always_populate_raw_post_data = -1/always_populate_raw_post_data = -1/g" /opt/php/etc/php.ini
/opt/php/sbin/php-fpm
3.整合php与nginx
vim /opt/www/nginx/conf/nginx.conf
server {
listen 80;
server_name 10.12.61.197;
location / {
root /data/zabbix;
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 /data/zabbix$fastcgi_script_name;
include fastcgi_params;
}
安装zabbix
yum install -y net-snmp-devel libxml2-devel libcurl-devel libevent-devel
./configure --prefix=/opt/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
groupadd zabbix
useradd -g zabbix zabbix -s /sbin/nologin
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
create database zabbix default charset utf8;
source /opt/zabbix-3.4.4/database/mysql/schema.sql;
source /opt/zabbix-3.4.4/database/mysql/images.sql;
source /opt/zabbix-3.4.4/database/mysql/data.sql;
vim /opt/zabbix/etc/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBPort=3306
find / -name libperconaserverclient.so.20
/opt/mysql/lib/libperconaserverclient.so.20
echo "/opt/mysql/lib" >> /etc/ld.so.conf
echo "/opt/mysql/lib/libperconaserverclient.so.20" >> /etc/ld.so.conf
ldconfig
/opt/zabbix/sbin/zabbix_server -c /opt/zabbix/etc/zabbix_server.conf
zabbix-agent安装
tar xvf zabbix-3.4.4.tar.gz
yum install -y net-snmp-devel libxml2-devel libcurl-devel libevent-devel php php-mysql
cd /opt/zabbix-3.4.4
./configure --prefix=/opt/zabbix_agent --enable-agent
make install
groupadd zabbix
useradd -g zabbix zabbix -s /sbin/nologin
cd /opt/
yum localinstall -y percona-zabbix-templates-1.1.7-2.noarch.rpm
vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
mysql_user = 'zabbix'
mysql_pass = 'zabbix'
mysql_socket = '/tmp/mysql.sock'
cp userparameter_percona_mysql.conf /opt/zabbix_agent/etc/zabbix_agentd.conf.d/
sed -i "s/Server=127.0.0.1/Server=10.12.61.190/g" /opt/zabbix_agent/etc/zabbix_agentd.conf
sed -i "s/ServerActive=127.0.0.1/ServerActive=10.12.61.190/g" /opt/zabbix_agent/etc/zabbix_agentd.conf
sed -i "s/Hostname=Zabbix server/#Hostname=Zabbix server/g" /opt/zabbix_agent/etc/zabbix_agentd.conf
sed -i "s/# HostnameItem=system.hostname/HostnameItem=system.hostname/g" /opt/zabbix_agent/etc/zabbix_agentd.conf
sed -i "s/# UnsafeUserParameters=0/UnsafeUserParameters=1/g" /opt/zabbix_agent/etc/zabbix_agentd.conf
vim /opt/zabbix_agent/etc/zabbix_agentd.conf
Include=/opt/zabbix_agent/etc/zabbix_agentd.conf.d/
/opt/zabbix_agent/sbin/zabbix_agentd -c /opt/zabbix_agent/etc/zabbix_agentd.conf
GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT ON *.* TO 'zabbix'@'localhost' identified by'zabbix';
flush privileges;
/usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host localhost --items gg
chown zabbix.zabbix /tmp/localhost-mysql_cacti_stats.txt
vim ~zabbix/.my.cnf
[mysql]
user=zabbix
password=zabbix
socket=/tmp/mysql.sock
sh /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave