码迷,mamicode.com
首页 > 系统相关 > 详细

linux源码安装zabbix_server

时间:2017-07-04 13:15:52      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:zabbix

  1. 安装mysql

tar xf cmake-3.8.2.tar.gz

cd cmake-3.8.2/

./configure

make && make install

yum install -y gcc* gcc-c++* autoconf* automake* zlib* libxml*  libgcrypt* libtool*

yum install -y openssl openssl-devel ncurses ncurses-devel

yum install -y readline-devel bison

groupadd mysql

useradd -g mysql mysql -s /bin/false

tar xf mysql-boost-5.7.18.tar.gz

cd mysql-5.7.18/

mkdir /opt/mysql-5.7.18

mkdir /opt/mysql-5.7.18/data

mkdir /opt/mysql-5.7.18/log

mkdir /opt/mysql-5.7.18/etc

chown -R mysql:mysql /opt/mysql-5.7.18/

cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql-5.7.18 -DSYSCONFDIR=/opt/mysql-5.7.18/etc -DMYSQL_DATADIR=/opt/mysql-5.7.18/data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_BOOST=/home/software/mysql-5.7.18/boost

make && make install

rm -rf /etc/my.cnf

vim my.cnf


basedir = /opt/mysql-5.7.18

datadir = /opt/mysql-5.7.18/data

server_id = 2

socket = /tmp/mysqld.sock


cd /opt/mysql-5.7.18/bin/

chmod 755 ./mysqld

./mysqld --initialize --user=mysql --basedir=/opt/mysql-5.7.18 --datadir=/opt/mysql-5.7.18/data

mkdir /opt/mysql-5.7.18/init.d

cp /opt/mysql-5.7.18/support-files/mysql.server /opt/mysql-5.7.18/init.d/mysqld

chmod +x /opt/mysql-5.7.18/init.d/mysqld

/opt/mysql-5.7.18/init.d/mysqld start

ln -s /opt/mysql-5.7.18/ /opt/mysql

ln -s /opt/mysql/init.d/mysqld /etc/rc.d/init.d/mysqld

chkconfig mysqld on

/opt/mysql/bin/mysql -uroot -p‘p3pX;<Bs3jF&‘

mysql> set password for ‘root‘@‘localhost‘ = password(‘system32‘);

  1. 安装nginx

groupadd nginx

useradd -g nginx nginx -s /bin/false

tar xf nginx-1.13.0.tar.gz

cd nginx-1.13.0/

./configure --user=nginx --group=nginx --prefix=/opt/nginx-1.13.0 --with-http_stub_status_module --with-http_ssl_module

make && make install

ln -s /opt/nginx-1.13.0/ /opt/nginx

设置开机启动

touch /etc/rc.d/init.d/nginx

vim /etc/rc.d/init.d/nginx


#! /bin/sh

# chkconfig: 2345 85 15

# description: Nginx is a World Wide Web server.

#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DESC="nginx daemon"

NAME=nginx

DAEMON=/opt/nginx/sbin/$NAME

CONFIGFILE=/opt/nginx/conf/$NAME.conf

PIDFILE=/opt/nginx/logs/$NAME.pid

SCRIPTNAME=/etc/init.d/$NAME

set -e

[ -x "$DAEMON" ] || exit 0

do_start() {

$DAEMON -c $CONFIGFILE || echo -n "nginx already running"

}

do_stop() {

kill -INT `cat $PIDFILE` || echo -n "nginx not running"

}

do_reload() {

kill -HUP `cat $PIDFILE` || echo -n "nginx can‘t reload"

}

case "$1" in

start)

echo -n "Starting $DESC: $NAME"

do_start

echo "."

;;

stop)

echo -n "Stopping $DESC: $NAME"

do_stop

echo "."

;;

reload|graceful)

echo -n "Reloading $DESC configuration..."

do_reload

echo "."

;;

restart)

echo -n "Restarting $DESC: $NAME"

do_stop

do_start

echo "."

;;

*)

echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2

exit 3

;;

esac

exit 0


chmod a+x /etc/rc.d/init.d/nginx

chkconfig nginx on

  1. 安装php

yum install -y gd gd-devel libpng libpng-devel openjpeg openjpeg-devel freetype freetype-devel gettext gettext-devel libxml2 libxml2-devel

tar xf php-7.1.6.tar.gz

cd php-7.1.6/

./configure --prefix=/opt/php-7.1.6 --enable-fpm --with-mysqli --enable-mysqlnd --with-pdo-mysql=mysqlnd --enable-bcmath --enable-mbstring --enable-sockets --with-gd --with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext --with-libxml-dir=/usr/include/libxml2

make && make install

cp /home/software/php-7.1.6/php.ini-development /opt/php-7.1.6/lib/php.ini

ln -s /opt/php-7.1.6/ /opt/php

cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf

cp /opt/php/etc/php-fpm.d/www.conf.default /opt/php/etc/php-fpm.d/www.conf

开机启动php-fpm

touch /etc/rc.d/init.d/php-fpm

vim /etc/rc.d/init.d/php-fpm


#! /bin/sh

#chkconfig: 2345 60 90

## vi /opt/php/etc/php-fpm.conf

#uncomment pid under [global]

#pid = run/php-fpm.pid

## vi /etc/rc.d/init.d/php-fpm

## chmod +x /etc/rc.d/init.d/php-fpm

## chkconfig php-fpm on

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DESC="php-fpm daemon"

NAME=php-fpm

INSTALLDIR=/opt/php

DAEMON=$INSTALLDIR/sbin/$NAME

CONFIGFILE=$INSTALLDIR/lib/$NAME.conf

PIDFILE=$INSTALLDIR/var/run/$NAME.pid

SCRIPTNAME=/etc/init.d/$NAME

set -e

[ -x "$DAEMON" ] || exit 0

do_start() {

$DAEMON -D || echo -n "php-fpm already running"

}

do_stop() {

kill -INT `cat $PIDFILE` || echo -n "php-fpm not running"

}

do_test() {

$DAEMON -t || echo -n "php-fpm can‘t test"

}

case "$1" in

start)

echo -n "Starting $DESC: $NAME"

do_start

echo "."

;;

stop)

echo -n "Stopping $DESC: $NAME"

do_stop

echo "."

;;

restart)

echo -n "Restarting $DESC: $NAME"

do_stop

do_start

echo "."

;;

test)

echo -n "Testing $DESC: $NAME"

do_test

echo "."

;;

*)

echo "Usage: $SCRIPTNAME {start|stop|restart|test}" >&2

exit 3

;;

esac

exit 0


chmod a+x /etc/rc.d/init.d/php-fpm

chkconfig php-fpm on

vim /opt/nginx/conf/nginx.conf


添加nginx对php的支持

location ~ \.php {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include /opt/nginx/conf/fastcgi_params;

fastcgi_split_path_info         ^(.+\.php)(/.+)$;

fastcgi_param PATH_INFO         $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED   $document_root$fastcgi_path_info;

fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;

}

添加php主页

location / {

root   html;

index  index.html index.htm index.php;

}


  1. 修改php配置文件

vim /opt/php/lib/php.ini


max_execution_time = 300

memory_limit = 128M

post_max_size = 16M

upload_max_filesize = 2M

max_input_time = 300

date.timezone = PRC

mysqli.default_socket = 添加mysql sock文件路径


  1. 安装zabbix

yum install -y unixODBC* OpenIPMI* net-snmp* libcurl*

groupadd zabbix

useradd -g zabbix zabbix -s /bin/false

tar xf zabbix-3.2.6.tar.gz

cd zabbix-3.2.6/

./configure --prefix=/opt/zabbix-3.2.6 --enable-server --with-mysql=/opt/mysql/bin/mysql_config --with-net-snmp=/usr/bin/net-snmp-config --with-libcurl=/usr/bin/curl-config --with-libxml2

make && make install

ln -s /opt/zabbix-3.2.6/ /opt/zabbix

ln -s /opt/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20

ln -s /opt/mysql/lib/libmysqlclient.so.20 /usr/lib/libmysqlclient.so.20

/opt/mysql/bin/mysql -uroot -p‘system32‘


create database zabbix default charset utf8;

GRANT ALL PRIVILEGES ON zabbix.* TO ‘zabbix‘@‘localhost‘ IDENTIFIED BY ‘12345678‘;

flush privileges;

use zabbix;

source /home/software/zabbix-3.2.6/database/mysql/schema.sql

source /home/software/zabbix-3.2.6/database/mysql/images.sql

source /home/software/zabbix-3.2.6/database/mysql/data.sql


设置开机启动

cp /home/software/zabbix-3.2.6/misc/init.d/tru64/zabbix_server /etc/rc.d/init.d/

vim /etc/rc.d/init.d/zabbix_server

# chkconfig: - 95 95

# description: Zabbix Server

DAEMON=/opt/zabbix/sbin/zabbix_server

chmod +x /etc/rc.d/init.d/zabbix_server

chkconfig zabbix_server on

  1. 修改zabbix配置

vim /opt/zabbix/etc/zabbix_server.conf


DBName=zabbix

DBUser=zabbix

DBPassword=12345678


  1. 复制zabbix网页文件

cp -R /home/software/zabbix-3.2.6/frontends/php/ /opt/nginx/html/


sed -i ‘/$last = strtolower(substr($val, -1));/a$val = substr($val,0,-1);‘ /opt/nginx/html/php/include/func.inc.php

linux源码安装zabbix_server

标签:zabbix

原文地址:http://954320420.blog.51cto.com/7212932/1944298

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!