- 上传如下软件包到 / soft目录中mysql - 5.1.71(centos6.5 64位自带)也可根据版本自行挑选,前提你了解这个版本pcre - 8.36.tar.gz nginx - 1.6.2.tar.gz jpegsrc.v9a.tar.gz libmcrypt - 2.5.8.tar.gz php - 5.6.3.tar.gz
cd /etc/yum.repos.d/
vim install.repo
[LOCALYUMSOURCE]
name=PD307
baseurl=http://192.168.100.254/1 #本地 ISO 挂载目录写法为:file:///mnt mnt 是挂载目录
http://192.168.100.254/2
gpgcheck=0
- 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
如果是按照编译安装 mysql5.7,请参考点击
yum install mysql*
安装目录:/var/lib/mysql/
拷贝 mysql64 位库文件至 32 位目录
cp /usr/lib64/mysql/* /usr/lib/mysql/,如果服务器没有 / usr/lib/mysql/ 目录,则在 / usr/lib / 目录下创建 mysql 目录即可
- tar zxvf pcre - 8.36.tar.gz cd pcre - 8.36. / configure--prefix = /usr/local / pcre make make install
了解安装 nginx,请点击
- groupadd www#添加www组useradd - g www www - s / bin / false#创建nginx运行账户www并加入到www组,不允许www用户直接登录系统tar zxvf 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 - openssl = /usr/--with - pcre = /soft/pcre - 8.36#注意: --with - pcre = /soft/pcre - 8.30指向的是源码包解压的路径,而不是安装的路径,否则会报错make make install
vi /etc/rc.d/init.d/nginx #设置 nginx 开启启动,编辑启动文件添加下面内容
View Code
- # ! /bin/sh##nginx - this script starts and stops the nginx daemin##chkconfig: -85 15#description: Nginx is an HTTP(S) server,
- HTTP(S) reverse\#proxy and IMAP / POP3 proxy server#processname: nginx#config: /www/wdlinux / nginx / conf / nginx.conf#pidfile: /www/wdlinux / nginx / logs / nginx.pid#Url http: //www.wdlinux.cn
- #Last Updated 2010.06.01#Source
- function library.. / etc / rc.d / init.d / functions#Source networking configuration.. / etc / sysconfig / network#Check that networking is up. ["$NETWORKING" = "no"] && exit 0 nginx = "/usr/local/nginx/sbin/nginx"prog = $(basename $nginx) NGINX_CONF_FILE = "/usr/local/nginx/conf/nginx.conf"NGINX_PID = "/usr/local/nginx/logs/nginx.pid" [ - f / etc / sysconfig / nginx] && . / etc / sysconfig / nginx lockfile = /var/lock / subsys / nginx start() { [ - x $nginx] || exit 5[ - f $NGINX_CONF_FILE] || exit 6 echo - n $ "Starting $prog: "daemon $nginx - c $NGINX_CONF_FILE retval = $ ? echo#service php - fpm start[$retval - eq 0] && touch $lockfile
- return $retval
- }
- stop() {
- echo - n $ "Stopping $prog: "$nginx - s stop echo_success retval = $ ? echo#service php - fpm stop[$retval - eq 0] && rm - f $lockfile
- return $retval
- }
- restart() {
- stop start
- }
- reload() {
- configtest ||
- return $ ? echo - n $ "Reloading $prog: "$nginx - s reload RETVAL = $ ? echo
- }
- force_reload() {
- restart
- }
- configtest() {
- $nginx - t - c $NGINX_CONF_FILE
- }
- rh_status() {
- status $prog
- }
- rh_status_q() {
- rh_status > /dev/null 2 > &1
- }
- case "$1" in start) rh_status_q && exit 0 $1;;
- stop) rh_status_q || exit 0 $1;;restart | configtest) $1;;reload) rh_status_q || exit 7 $1;;force - reload) force_reload;;status) rh_status;;condrestart |
- try - restart) rh_status_q || exit 0;; * ) echo $ "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"exit 2 esac
chmod 775 /etc/rc.d/init.d/nginx #赋予文件执行权限
chkconfig nginx on #设置开机启动
egrep -v "#" /usr/local/nginx/conf/nginx.conf
#此为参考配置示例
View Code
- user www www;#取消注释,修改为www用户和www组worker_processes 1;
- events {
- worker_connections 1024;
- }
- http {
- include mime.types;
- default_type application / octet - stream;
- sendfile on;
- keepalive_timeout 65;
- server {
- listen 80;
- server_name localhost;
- root / usr / local / nginx / html;#修改nginx默认目录index index.php index.html index.htm;#添加nginx支持php索引error_page 500 502 503 504 / 50x.html;
- location = /50x.html {
- root html;
- }
- location ~ \.php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #修改为$document_root$fastcgi_script_name;
- include fastcgi_params;
- }
- }/
/etc/rc.d/init.d/nginx restart #重启
- cd / soft / jpeg - 9a / tar zxf jpegsrc.v9a.tar.gz cd jpeg - 9a / . / configure--prefix = /usr/local / jpeg make && make install
- cd / soft#libmcrypt - 2.5.8.tar.gz软件包路径tar - zxvf libmcrypt - 2.5.8.tar.gz cd / usr / local / src / libmcrypt - 2.5.8. / configure--prefix = /usr/local make && make install
View Code
- cd / soft tar - zvxf php - 5.6.3.tar.gz cd php - 5.6.3 mkdir - p / usr / local / php5#建立php安装目录. / configure--prefix = /usr/local / php5--with - config - file - path = /usr/local / php5 / etc--with - mysql = /usr --with-mysqli=/usr / lib64 / mysql / mysql_config--with - mysql - sock = /var/lib / mysql / mysql.sock--with - gd--with - iconv--with - zlib--enable - xml--enable - magic - quotes--enable - safe - mode--enable - bcmath--enable - shmop--enable - sysvsem--enable - inline - optimization--with - curlwrappers--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--with - jpeg - dir--with - freetype - dir--with - jpeg - dir = /usr/local / jpeg make && make install PHP系统配置文件设置cp php.ini - production / usr / local / php5 / etc / php.ini#复制php配置文件到安装目录rm - rf / etc / php.ini#删除系统自带配置文件ln - s / usr / local / php5 / etc / php.ini / etc / php.ini#添加软链接cp / usr / local / php5 / etc / php - fpm.conf.
- default / usr / local / php5 / etc / php - fpm.conf#拷贝模板文件为php - fpm配置文件PHP修改添加Nginx用户vi / usr / local / php5 / etc / php - fpm.conf#编辑user = www#设置php - fpm运行账号为www group = www#设置php - fpm运行组为www pid = run / php - fpm.pid#取消前面的分号cp / soft / php - 5.6.3 / sapi / fpm / init.d.php - fpm / etc / rc.d / init.d / php - fpm#设置php - fpm开机启动,拷贝php - fpm到启动目录chmod + x / etc / rc.d / init.d / php - fpm#添加执行权限chkconfig php - fpm on#设置开机启动PHP配置文件设置vi / usr / local / php5 / etc / php.ini找到;
- disable_functions = 修改为disable_functions = passthru,
- exec,
- system,
- chroot,
- scandir,
- chgrp,
- chown,
- shell_exec,
- proc_open,
- proc_get_status,
- ini_alter,
- ini_alter,
- ini_restore,
- dl,
- openlog,
- syslog,
- readlink,
- symlink,
- popepassthru,
- stream_socket_server,
- escapeshellcmd,
- dll,
- popen,
- disk_free_space,
- checkdnsrr,
- checkdnsrr,
- getservbyname,
- getservbyport,
- disk_total_space,
- posix_ctermid,
- posix_get_last_error,
- posix_getcwd,
- posix_getegid,
- posix_geteuid,
- posix_getgid,
- posix_getgrgid,
- posix_getgrnam,
- posix_getgroups,
- posix_getlogin,
- posix_getpgid,
- posix_getpgrp,
- posix_getpid,
- posix_getppid,
- posix_getpwnam,
- posix_getpwuid,
- posix_getrlimit,
- posix_getsid,
- posix_getuid,
- posix_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版本的信息修改PHP参数post_max_size = 8M#改为16M max_execution_time = 30#改为300 max_input_time = 60#改为300
Zabbix 软件包:
zabbix-2.4.2.tar.gz
zabbix-agent-2.4.2-1.el6.x86_64.rpm
Zabbix 所需依赖包:
- yum - y install net - snmp net - snmp - devel OpenIPMI OpenIPMI - devel OpenIPMI - tools OpenIPMI - libs libssh2 * unixODBC *
创建并赋予权限
- /etc/init.d / mysqld start mysqladmin - u root password yd_12345678 mysql - uroot - pyd_12345678 > create database zabbix character set utf8; > use mysql; > grant all privileges on zabbix. * to zabbix@localhost identified by 'yd_12345678'; > flush privileges; > quit;
如出现
- mysql - u root–p Enter password: ERROR 1045(28000) : Access denied
- for user 'root'@'localhost' (using password: YES)
解决办法
- > set password
- for 'root'@'localhost' = PASSWORD('yd_12345678');
View Code
- cd / soft / tar zxvf zabbix - 2.4.2.tar.gz cd zabbix - 2.4.2#导入数据库 / soft / zabix - 2.4.2目录下#注意要按顺序导入,不然会报错mysql - uzabbix - pyd_12345678 zabbix < database / mysql / schema.sql mysql - uzabbix - pyd_12345678 zabbix < database / mysql / images.sql mysql - uzabbix - pyd_12345678 zabbix < database / mysql / data.sql编译安装:. / configure--prefix = /usr/local / zabbix--enable - server--enable - agent--with - mysql = /usr/lib64 / mysql / mysql_config--with - net - snmp--with - libcurl--enable - proxy--with - openipmi--with - unixodbc--with - ssh2 make install#注意:在编译时,如果缺少相应的依赖包,configure过程会给出提示,然后用yum安装相应的软件。
vim /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
- groupadd zabbix useradd - g zabbix - m zabbix mkdir - p / etc / zabbix cp conf / {
- zabbix_server.conf,
- zabbix_agentd.conf
- }
- /etc/zabbix chmod 400 / etc / zabbix / zabbix_server.conf chown zabbix / etc / zabbix / zabbix_server.conf chown - R zabbix: zabbix / etc / zabbix chmod 0755 / etc / zabbix / zabbix_server.conf
ln -sf /usr/local/zabbix/etc/zabbix_server.conf /etc/zabbix/zabbix_server.conf
vim /etc/zabbix/zabbix_server.conf
View Code
- ln - sf / usr / local / zabbix / etc / zabbix_server.conf / etc / zabbix / zabbix_server.conf vim / etc / zabbix / zabbix_server.conf LogFile = /tmp/zabbix_server.log DBHost = localhost DBName = zabbix zabbix所属数据库名称DBUser = zabbix zabbix所属数据库用户DBPassword = yd_12345678 zabbix数据库密码DBSocket = /var/lib / mysql / mysql.sock StartPollers = 30轮询的初始值(0 - 1000)StartIPMIPollers = 4 IPMI轮询的初始值(0 - 1000)StartPollersUnreachable = 30轮询不可达的主机数(包括IPMI 0 - 1000)StartTrappers = 8捕获的初始值(0 - 1000)StartPingers = 4 ping的初始值(0 - 1000)StartDiscoverers = 0自动发现的初始值(0 - 250)CacheSize = 384M缓存大小CacheUpdateFrequency = 300缓存更新的频率StartDBSyncers = 8数据库同步时间TrendCacheSize = 128M总趋势缓存大小AlertScriptsPath = /usr/bin脚本的存放位置LogSlowQueries = 1000日志慢查询设定#AlertScriptsPath = /usr/local / zabbix / scripts#指定告警脚本存放位置
View Code
- cd frontends / # / soft / zabbix - 2.4.2 / frontends软件包解压路径cp - rf php / usr / local / nginx / html cd / usr / local / nginx / html mv php zabbix chown - R zabbix: zabbix zabbix vi / usr / local / php5 / etc / php.ini date.timezone = Asia / Shanghai sed - i "s#;always_populate_raw_post_data = -1#always_populate_raw_post_data = -1#g" / usr / local / php5 / etc / php.ini sed - i "s#;cgi.fix_pathinfo=0#cgi.fix_pathinfo=0#g" / usr / local / php5 / etc / php.ini
View Code
- cp / usr / local / zabbix / sbin / zabbix_server / etc / init.d / cp / usr / local / zabbix / sbin / zabbix_agentd / etc / init.d / chmod 755 / etc / init.d / zabbix_ * sed - i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" / etc / init.d / zabbix_server sed - i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" / etc / init.d / zabbix_agentd chkconfig--add zabbix_server chkconfig--add zabbix_agentd chkconfig--level 345 zabbix_server on chkconfig--level 345 zabbix_agentd on service zabbix_server restart service zabbix_agentd restart
- vim / etc / sysconfig / iptables - A INPUT - s 192.168.0.0 / 16 - p tcp - m multiport--dports 10050,
- 10051 - j ACCEPT
Zabbix 的服务端口为 10050 和 10051
到此,zabbix 配置完成.
可以使用 web 访问 / setup.php
默认用户名和密码: admin/zabbix
1. 启用防火环境设置防火墙开放 80,9000,10050,10051 端口
2. 设置系统 Selinux 已经关闭
3. 设置 Mysql、Nginx、php-fpm 服务自启动
{chkconfig –level 2345 mysqld on; chkconfig --level 2345 nginx on; chkconfig --level 2345 php-fpm on ;chkconfig}
4. 设置 / etc/init.d/zabbix_server 开机引导,加入 / etc/rc.local
vim /usr/local/nginx/html/zabbix/conf/zabbix.conf.php;
chmod 777 /usr/local/nginx/html/zabbix/conf
View Code
- php
- // Zabbix GUI configuration file
- global $DB;
- $DB['TYPE'] = 'MYSQL';
- $DB['SERVER'] = 'localhost';
- $DB['PORT'] = '0';
- $DB['DATABASE'] = 'zabbix';
- $DB['USER'] = 'root';
- $DB['PASSWORD'] = 'yd_12345678';
- // SCHEMA is relevant only for IBM_DB2 database
- $DB['SCHEMA'] = '';
- $ZBX_SERVER = 'localhost';
- $ZBX_SERVER_PORT = '10051';
- $ZBX_SERVER_NAME = 'pd';
- $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
vim /usr/local/nginx/html/zabbix/include/locales.inc.php
第 55 行中结尾处 false 改成 true,IE 浏览器使用 admin 登录 zabbix 主页面右上方 Profile 中 Language 中选择 Chinese(zh CN)点击 Update。
一、
来源: http://www.cnblogs.com/renfanzi/p/5825485.html