=========>>系统约定<<===========================
源码包存放路径:/usr/local/src/
Nginx安装路径:/usr/local/nginx/
MySQL安装路径:/usr/local/mysql/
Php安装路径:/usr/local/php/
#安装编译工具和及库文件
#yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig \
fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc \
kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng* libpng-devel \
libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libX* \
libtiff libtiff* make mpfr ncurses* ntp openssl nasm nasm* openssl-devel patch pcre-devel perl php-common php-gd \
policycoreutils ppl telnet t1lib t1lib* wget zlib-devel
#编译安装MySQL数据库
tar xf cmake-3.0.2.tar.gz
cd cmake-3.0.2
./configure
make && make install
groupadd mysql
useradd -g mysql mysql -s /bin/false
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
tar xf mysql-5.6.21.tar.gz
cd mysql-5.6.21
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc
make && make install
cd /usr/local/mysql/
ls
rm -rf /etc/my.cnf
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
ln -s /usr/local/mysql/my.cnf /etc/my.cnf
cp ./support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig mysqld on
vim /etc/my.cnf 加入
basedir=/usr/local/mysql #MySQL程序安装路径
datadir=/data/mysql #MySQl数据库存放目录
service mysqld start
vim /etc/profile 加入
export PATH=$PATH:/usr/local/mysql/bin:.
source /etc/profile
vim /etc/ld.so.conf.d/mysql.conf 加入
/usr/local/mysql/lib
ldconfig
ln -sv /usr/local/mysql/include /usr/include/mysql
mkdir /var/lib/mysql
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
#编译安装Nginx
mkdir /usr/local/zlib
tar xf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib
make && make install
cd ..
mkdir /usr/local/pcre
tar xf pcre-8.36.tar.gz
cd pcre-8.36
./configure --prefix=/usr/local/pcre
make && make install
cd ..
mkdir /usr/local/openssl
tar xf openssl-1.0.1j.tar.gz
cd openssl-1.0.1j
./config --prefix=/usr/local/openssl
make && make install
vim /etc/profile
source /etc/profile
groupadd www
useradd -g www www -s /bin/false
tar xf nginx-1.6.2.tar.gz
cd nginx-1.6.2
./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www \
--with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module \
--with-openssl=/usr/local/src/openssl-1.0.1j --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36
make && make install
#安装PHP
tar xf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make && make install
cd ..
ls
rz -E
tar xf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
cd ..
wget https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
rz -E
tar xf libvpx-v1.3.0.tar.xz
wget http://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
rz -E
tar xf libvpx-v1.3.0.tar.bz2
cd libvpx-v1.3.0
./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9
make && make install
cd ..
rz -E
tar xf tiff-4.0.3.tar.gz
cd tiff-4.0.3
./configure --prefix=/usr/local/tiff --enable-shared
make && make install
cd ..
rz -E
tar xf libpng-1.6.16.tar.gz
cd libpng-1.6.16
./configure --prefix=/usr/local/libpng --enable-shared
make && make install
cd ..
rz -E
tar xf freetype-2.5.4.tar.gz
cd freetype-2.5.4
./configure --prefix=/usr/local/freetype --enable-shared --without-png
make && make install
cd ..
rz -E
tar xf jpegsrc.v9a.tar.gz
cd jpeg-9a/
./configure --prefix=/usr/local/jpeg --enable-shared
make && make install
cd ..
ls
rz -E
tar xf libgd-2.1.0.tar.gz
cd libgd-2.1.0
./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx
make && make install
cd ..
rz -E
tar xf t1lib-5.1.2.tar.gz
cd t1lib-5.1.2
./configure --prefix=/usr/local/t1lib --enable-shared
make without_doc
make install
\cp -frp /usr/lib64/libltdl.so* /usr/lib/
\cp -frp /usr/lib64/libXpm.so* /usr/lib/
tar xf php-5.6.3.tar.gz
cd php-5.6.3
export LD_LIBRARY_PATH=/usr/local/libgd/lib
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql \
--with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype \
--with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib \
--with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization \
--enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl \
--enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session \
--with-mcrypt --with-curl --enable-ctype
make && make install
cp php.ini-production /usr/local/php/etc/php.ini
rm -rf /etc/php.ini
ln -s /usr/local/php/etc/php.ini /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf
vim /usr/local/php/etc/php-fpm.conf
user = www #设置php-fpm运行账号为www
group = www #设置php-fpm运行组为www
pid = run/php-fpm.pid #取消前面的分号
cp /usr/local/src/php-5.6.3/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm on
vi /usr/local/php/etc/php.ini
找到:disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,r
eadlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_to
tal_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,p
osix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posi
x_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix
_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;date.timezone =
修改为:date.timezone = PRC #设置时区
找到:expose_php = On
修改为:expose_php = Off #禁止显示php版本的信息
找到:short_open_tag = Off
修改为:short_open_tag = ON #支持php短标签
找到opcache.enable=0
修改为opcache.enable=1 #php支持opcode缓存
找到:;opcache.enable_cli=1 #php支持opcode缓存
修改为:opcache.enable_cli=0
在最后一行添加:zend_extension=opcache.so #开启opcode缓存功能
vim /usr/local/nginx/conf/nginx.conf
user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php/etc/php-fpm.conf中的user,group配置相同,否则php运行出错
index index.html index.htm index.php; #添加index.php
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
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;
}
#取消FastCGI server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
/etc/init.d/nginx restart
vim /usr/local/nginx/conf/nginx.conf
/etc/init.d/nginx restart
/etc/init.d/php-fpm start
= 安装zabbix
zabbix-2.2.6
http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.6/zabbix-2.2.6.tar.gz
上传zabbix-2.2.6.tar.gz到服务器/usr/local/src目录下面
一、创建、导入zabbix数据库
cd /usr/local/src #进入软件包下载目录
tar zxvf zabbix-2.2.6.tar.gz #解压
cd /usr/local/src/zabbix-2.2.6/database/mysql #进入mysql数据库创建脚本目录
ls #列出文件,可以看到有schema.sql、p_w_picpaths.sql、data.sql这三个文件
mysql -u root -p #输入密码,进入MySQL控制台
create database zabbix character set utf8; #创建数据库zabbix,并且数据库编码使用utf8
grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by '123456' with grant option; #允许账户zabbix能从本机连接到数据库zabbix
flush privileges; #再次刷新系统授权表
use zabbix #进入数据库
source /usr/local/src/zabbix-2.2.6/database/mysql/schema.sql #导入脚本文件到zabbix数据库
source /usr/local/src/zabbix-2.2.6/database/mysql/p_w_picpaths.sql #导入脚本文件到zabbix数据库
source /usr/local/src/zabbix-2.2.6/database/mysql/data.sql #导入脚本文件到zabbix数据库
注意:请按照以上顺序进行导入,否则会出错。
exit #退出
cd /usr/lib64/mysql #32位系统为/usr/lib/mysql,注意系统版本同,文件版本可能不一样,这里是16.0.0
ln -s libmysqlclient.so.16.0.0 libmysqlclient.so #添加软连接
ln -s libmysqlclient_r.so.16.0.0 libmysqlclient_r.so #添加软连接
二、安装zabbix
1、添加用户:
groupadd zabbix #创建用户组zabbix
useradd zabbix -g zabbix -s /bin/false #创建用户zabbix,并且把用户zabbix加入到用户组zabbix中
2、安装依赖包 #CentOS使用yum命令安装
yum install net-snmp-devel curl curl-devel mysql-devel
备注:以上软件包如果在安装Web环境LAMP或者LNMP时已经安装过,此步骤可忽略
3、安装zabbix
ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2 #添加软连接
/sbin/ldconfig #使配置立即生效
cd /usr/local/src/zabbix-2.2.6 #进入安装目录
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-net-snmp --with-libcurl --enable-proxy --with-mysql=/usr/bin/mysql_config #配置
make #编译
make install #安装
ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/ #添加系统软连接
ln -s /usr/local/zabbix/bin/* /usr/local/bin/ #添加系统软连接
说明:find / -name mysql_config 查找位置,如果没有mysql_config,需要安装yum install mysql-devel
4、添加zabbix服务对应的端口
vi /etc/services #编辑,在最后添加以下代码
# Zabbix
zabbix-agent 10050/tcp # Zabbix Agent
zabbix-agent 10050/udp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
zabbix-trapper 10051/udp # Zabbix Trapper
:wq! #保存退出
5、修改zabbix配置文件
cd /usr/local/zabbix/etc
vi /usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix #数据库名称
DBUser=zabbix #数据库用户名
DBPassword=123456 #数据库密码
ListenIP=127.0.0.1 #数据库ip地址
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts #zabbix运行脚本存放目录
:wq! #保存退出
vi /usr/local/zabbix/etc/zabbix_agentd.conf
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
UnsafeUserParameters=1 #启用自定义key
:wq! #保存退出
6、添加开机启动脚本
cp /usr/local/src/zabbix-2.2.6/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server #服务端
cp /usr/local/src/zabbix-2.2.6/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd #客户端
chmod +x /etc/rc.d/init.d/zabbix_server #添加脚本执行权限
chmod +x /etc/rc.d/init.d/zabbix_agentd #添加脚本执行权限
chkconfig zabbix_server on #添加开机启动
chkconfig zabbix_agentd on #添加开机启动
7、修改zabbix开机启动脚本中的zabbix安装目录
vi /etc/rc.d/init.d/zabbix_server #编辑服务端配置文件
BASEDIR=/usr/local/zabbix/ #zabbix安装目录
:wq! #保存退出
vi /etc/rc.d/init.d/zabbix_agentd #编辑客户端配置文件
BASEDIR=/usr/local/zabbix/ #zabbix安装目录
:wq! #保存退出
四、配置web站点
cd /usr/local/src/zabbix-2.2.6
cp -r /usr/local/src/zabbix-2.2.6/frontends/php /usr/local/nginx/html/zabbix
chown www.www -R /usr/local/nginx/html/zabbix
备注:/usr/local/nginx/html为Nginx默认站点目录 www为Nginx运行账户
service zabbix_server start #启动zabbix服务端
service zabbix_agentd start #启动zabbix客户端
六、修改php配置文件参数
1、vi /etc/php.ini #编辑修改
post_max_size =16M
max_execution_time =300
max_input_time =300
:wq! #保存退出
2、vi /usr/local/php/etc/php-fpm.conf #编辑修改
request_terminate_timeout = 300
:wq! #保存退出
service php-fpm reload #重启php-fpm
七、安装web
在浏览器中打开:
http://192.168.21.127/zabbix/setup.php
八、更改zabbix默认语言为简体中文、替换监控图像上系统默认的中文字体
1、修改系统配置文件,让web页面支持简体中文显示
vi /usr/local/nginx/html/zabbix/include/locales.inc.php #编辑修改
'zh_CN' => array('name' => _('Chinese (zh_CN)'), 'display' => false),
修改为
'zh_CN' => array('name' => _('Chinese (zh_CN)'), 'display' => true),
:wq! #保存退出
2、替换监控图像上系统默认的字体 #默认字体不支持中文,如果不替换,图像上会显示乱码
在Windows系统中的C:\Windows\Fonts目录中复制出一个中文字体文件,例如msyh.ttf
把字体文件msyh.ttf上传到zabbix站点根目录下fonts文件夹中
例如:/usr/local/nginx/html/zabbix/fonts
备份默认的字体文件:DejaVusSans.ttf-bak
修改msyh.ttf名称为DejaVusSans.ttf
转载于:https://blog.51cto.com/darren88/1677053