系统:centos6.8
Zabbix-server(服务端):192.168.137.36
Zabbix-agent(客户端):192.168.137.35
以下是zabbix-server服务端安装操作
yum install lrzsz -y
安装Nginx
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum clean all
yum repolist
yum install -y Nginx
安装MysqL
wget https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm
rpm -Uvh MysqL57-community-release-el6-9.noarch.rpm
yum install MysqL-community-server
service MysqLd start
grep 'temporary password' /var/log/MysqLd.log
MysqL -uroot -p
set global validate_password_policy=0;
set global validate_password_length=6;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'abc123';
安装PHP
下载PHP 源码包
wget http://cn2.php.net/distributions/php-5.6.0.tar.xz
xz -d PHP-5.6.0.tar.xz
tar xf PHP-5.6.0.tar -C /usr/local/src/
安装依赖
yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel
创建www 用户
groupadd www
useradd -g www -s /sbin/nologin -M www
编译安装
cd /usr/local/src/PHP-5.6.0/
./configure \
--prefix=/usr/local/PHP56 \
--with-config-file-path=/usr/local/PHP56/etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-readline
# make -j8
# make install
配置PHP
配置文件:
cp PHP.ini-development /usr/local/PHP56/etc/PHP.ini
PHP-fpm 服务
cp /usr/local/PHP56/etc/PHP-fpm.conf.default /usr/local/PHP56/etc/PHP-fpm.conf
cp sapi/fpm/init.d.PHP-fpm /etc/init.d/PHP-fpm56
chmod +x /etc/init.d/PHP-fpm56
启动PHP-fpm
service PHP-fpm56 start
PHP-fpm 可用参数start|stop|force-quit|restart|reload|status
编辑~/.bash_profile,将:
PATH=$PATH:$HOME/bin
改为:
PATH=$PATH:$HOME/bin:/usr/local/PHP56/bin
使PHP 环境变量生效:
. ~/.bash_profile
查看PHP 版本
PHP -v
测试短语、
vim /usr/share/Nginx/html/a.PHP
<?PHP
PHPinfo();
?>
如出现以上界面表示lnmp环境搭建成功
如果访问网址的时候回报错 解决方法:
location ~ \.PHP$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME /usr/share/Nginx/html$fastcgi_script_name;
include fastcgi_params;
}
zabbix安装
下载zabbix的安装包
创建zabbix用户
groupadd zabbix
useradd -g zabbix zabbix -s /sbin/nologin
解压源码包
tar zxvf zabbix-3.0.2.tar.gz -C /usr/src/
进入数据库
MysqL -u root -p
创建zabbix数据库
CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
创建zabbix授权库账户zabbix,密码是123456
grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
导入zabbix数据表结构
use zabbix;
source /usr/src/zabbix-3.0.2/database/MysqL/schema.sql;
source /usr/src/zabbix-3.0.2/database/MysqL/data.sql;
source /usr/src/zabbix-3.0.2/database/MysqL/images.sql;
安装组件
yum install -y net-snmp net-snmp-devel curl curl-devel
进入解压目录,编译安装
cd /usr/src/zabbix-3.0.2/
./configure --prefix=/usr/local/zabbix --with-MysqL --with-net-snmp --with-libcurl --enable-server --enable-agent --enable-proxy
会报错:
configure: error: MysqL library not found
the problem is not installed MysqL-devel
make && make install
创建日志目录
mkdir /usr/local/zabbix/logs
编辑zabbix_agentd配置文件
cd /usr/local/zabbix/etc/
mv zabbix_agentd.conf zabbix_agentd.conf.bak
vim zabbix_agentd.conf
内容如下:
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Server=127.0.0.1
#ServerActive=127.0.0.1
Hostname=Zabbix server
编辑zabbix_server配置文件
mv zabbix_server.conf zabbix_server.conf.bak
vim zabbix_server.conf
内容如下:
LogFile=/usr/local/zabbix/logs/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBHost=localhost
DBPassword=123456
AlertScriptsPath=/usr/local/zabbix/alertscripts
创建自定义脚本目录,设置权限,目录下的脚步,可以被zabbix调用
mkdir /usr/local/zabbix/alertscripts
chown zabbix:zabbix -R /usr/local/zabbix
sed -i 's/post_max_size = 8M/post_max_size = 32M/g' /usr/local/PHP56/etc/PHP.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /usr/local/PHP56/etc/PHP.ini
sed -i 's/;date.timezone =/date.timezone =PRC/' /usr/local/PHP56/etc/PHP.ini
sed -i 's/max_execution_time = 30/max_execution_time = 600/g' /usr/local/PHP56/etc/PHP.ini
sed -i 's/max_input_time = 60/max_input_time = 600/g' /usr/local/PHP56/etc/PHP.ini
sed -i 's/memory_limit = 128M/memory_limit = 256M/g'/usr/local/PHP56/etc/PHP.ini
vim /usr/local/PHP56/etc/PHP.ini
cgi.fix_pathinfo=0
改为
cgi.fix_pathinfo=1
重启PHP-fpm
service PHP-fpm56 restart
进入源码目录,复制启动脚本
cd /usr/src/zabbix-3.0.2/misc/
cp init.d/tru64/zabbix_server /etc/init.d/
cp init.d/tru64/zabbix_agentd /etc/init.d/
chmod +x /etc/init.d/zabbix_*
修改zabbix_agentd、zabbix_server程序目录的位置
vim /etc/init.d/zabbix_agentd
内容如下:
DAEMON=/usr/local/zabbix/sbin/zabbix_agentd
vim /etc/init.d/zabbix_server
内容如下:
DAEMON=/usr/local/zabbix/sbin/zabbix_server
由于zabbix_server 服务不支持chkconfig,使用下列方法自启动
vim /etc/init.d/zabbix_server
在#!/bin/sh下面一行添加
#chkconfig: 345 95 95
#description: Zabbix_Server
vim /etc/init.d/zabbix_agentd
在#!/bin/sh下面一行添加
#chkconfig: 345 95 95
#description: Zabbix_agentd
添加到系统服务
chkconfig zabbix_server on
chkconfig zabbix_agentd on
编辑系统库配置文件
vim /etc/ld.so.conf
加入一行
/usr/local/MysqL/lib/
重新加载
ldconfig
启动服务
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
查看端口
netstat -ntpl|grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 21188/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 21140/zabbix_server
cp -rf /usr/src/zabbix-3.0.2/frontends/PHP/ /usr/local/zabbix/PHP
chown www:www -R /usr/local/zabbix/PHP/
vim /etc/Nginx/conf.d/default.conf
内容如下:
server {
listen 80;
server_name localhost;
root /usr/local/zabbix/PHP;
index index.PHP index.html index.htm;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.PHP/$1 last;
break;
}
}
location ~ \.PHP {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
include fastcgi_params;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.PHP)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
}
重新加载Nginx
/etc/init.d/Nginx restart
vim /usr/local/zabbix/PHP/include/locales.inc.PHP
打开'zh_CN' => ['name' => _('Chinese (zh_CN)'),'display' =>true],
/etc/init.d/PHP-fpm56 restart
访问@L_301_8@例如:http://192.168.137.36/setup.PHP
出现报错
解决方法:
PHP option “always_populate_raw_post_data”must be set to -1”
打开/usr/local/PHP56/etc/PHP.ini文件把always_populate_raw_post_data = -1这一行注释打开,保存重启PHP-fpm56
1.Freetype
wget "http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2"
tar jxvf freetype-2.4.0.tar.bz2
cd freetype-2.4.0
./configure --prefix=/usr/local/freetype && make && make install
2. jpegsrc
wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
tar zxvf jpegsrc.v9.tar.gz
cd jpeg-9
CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/jpeg && make && make install
3. libpng
tar zxvf libpng-1.6.31.tar
cd libpng-1.6.31
CFLAGS="-O3 -fPIC"./configure --prefix=/usr/local/libpng && make && make install
cd /usr/local/src/PHP-5.6.0/ext/gd/
运行/usr/local/PHP56/bin/PHPize 命令
./configure --with-PHP-config=/usr/local/PHP56/bin/PHP-config --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype
出现了异常error: png.h not found.
解决办法:
yum install libpng-devel,下面就是编译安装
./configure --with-PHP-config=/usr/local/PHP56/bin/PHP-config --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype
make && make install
接着修改PHP.ini文件在; default extension directory. 下面添加一行extension=gd.so
yum install PHP-gd
service Nginx restart
/etc/init.d/PHP-fpm56 restart
输入密码123456
ln -s /var/lib/MysqL/MysqL.sock /tmp/
vim /usr/local/PHP56/etc/PHP.ini
MysqLi.default_socket = /var/lib/MysqL/MysqL.sock
/etc/init.d/PHP-fpm56 restart
然后一直下一步 输入用户名Admin,密码zabbix
原文链接:https://www.f2er.com/centos/375662.html