Zabbix LAMP搭建zabbix

sed -i 's/SELINUX=enabled/SELINUX=disabled/g' /etc/selinux/config

getenforce 0

/etc/init.d/iptables stop

cat /etc/redhat-release

uname -r

uname -m


#su -

#chmod 777 /usr/local/src

yum -y install gcc wget libtool expat-devel pcre-devel zlib-devel openssl-devel


#安装apache

cd /usr/local/src

useradd -s /sbin/nologin -M www

wget -c http://mirrors.cnnic.cn/apache//apr/apr-1.6.3.tar.gz  

wget -c http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz

wget -c http://mirrors.aliyun.com/apache/httpd/httpd-2.4.29.tar.gz 

#编译安装apr

tar xf apr-1.6.3.tar.gz

cd apr-1.6.3

./configure --prefix=/usr/local/apr-1.6.3

make && make install

echo $?

ln -s /usr/local/apr-1.6.3/ /usr/local/apr

cd ..


tar zvxf apr-util-1.5.2.tar.gz  

cd apr-util-1.5.2

./configure --prefix=/usr/local/apr-util-1.5.2--with-apr=/usr/local/apr-1.6.3/

echo $?

make && make install

echo $?

ln -s /usr/local/apr-util-1.5.2/ /usr/local/apr-util

cd ..


tar zxvf httpd-2.4.29.tar.gz

cd httpd-2.4.29

./configure --prefix=/usr/local/httpd-2.4.29 --with-expat=builtin--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so--enable-deflate --enable-expires --enable-headers --enable-ssl--enable-rewrite --enable-mpms-shared=all --with-mpm=prefork --enable-mods-shared=most

echo $?

make

make install

ln -s /usr/local/httpd-2.4.29/ /usr/local/httpd


#配置http环境变量

echo "export PATH=/usr/local/httpd/bin:$PATH">>/etc/profile

. /etc/profile


#查看安装的模块、

apachectl -t -D DUMP_MODULES


#apache配置文件位置

#/usr/local/httpd/conf/httpd.conf


#启动apache服务

apachectl start


#配置启动脚本

cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

chmod +x /etc/init.d/httpd

/etc/init.d/httpd stop

netstat -lntup|grep httpd

/etc/init.d/httpd start

netstat -lntup|grep httpd

vim /etc/init.d/httpd

#在开始位置添加:

# chkconfig: 345 85 15

# description: this my apache is httpd server

#加入系统启动服务,开机自启动

chkconfig --add httpd

chkconfig httpd on

chkconfig --list httpd





#搭建MYSQL

useradd -s /sbin/nologin -M mysql

wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

mv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql-5.7.17

ln -s /usr/local/mysql-5.7.17 /usr/local/mysql


#创建数据库文件目录

mkdir -p /data/mysql

chown -R mysql.mysql /data/

#配置启动脚本文件,并加入系统服务,自启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld on

#配置mysql配置文件

cat > /etc/my.cnf << EOF

[client]

port = 3306

socket = /tmp/mysql.sock

default-character-set = utf8

[mysqld]

port = 3306

socket = /tmp/mysql.sock

basedir = /usr/local/mysql

datadir = /data/mysql

pid-file = /data/mysql/mysql.pid

user = mysql

bind-address = 0.0.0.0

server-id = 1

init-connect = 'SET NAMES utf8'

character-set-server = utf8

#skip-name-resolve

#skip-networking

back_log = 300

max_connections = 1000

max_connect_errors = 6000

open_files_limit = 65535

table_open_cache = 128

max_allowed_packet = 4M

binlog_cache_size = 1M

max_heap_table_size = 8M

tmp_table_size = 16M

read_buffer_size = 2M

read_rnd_buffer_size = 8M

sort_buffer_size = 8M

join_buffer_size = 8M

key_buffer_size = 4M

thread_cache_size = 8

query_cache_type = 1

query_cache_size = 8M

query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin

binlog_format = mixed

expire_logs_days = 30

log_error = /data/mysql/mysql-error.log

slow_query_log = 1

long_query_time = 1

slow_query_log_file = /data/mysql/mysql-slow.log

performance_schema = 0

explicit_defaults_for_timestamp

#lower_case_table_names = 1

skip-external-locking

default_storage_engine = InnoDB

#default-storage-engine = MyISAM

innodb_file_per_table = 1

innodb_open_files = 500

innodb_buffer_pool_size = 64M

innodb_write_io_threads = 4

innodb_read_io_threads = 4

innodb_thread_concurrency = 0

innodb_purge_threads = 1

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 2M

innodb_log_file_size = 32M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 90

innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M

myisam_sort_buffer_size = 8M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

interactive_timeout = 28800

wait_timeout = 28800

[mysqldump]

quick

max_allowed_packet = 16M

[myisamchk]

key_buffer_size = 8M

sort_buffer_size = 8M

read_buffer = 4M

write_buffer = 4M

EOF


#初始化数据库:

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql--basedir=/usr/local/mysql --datadir=/data/mysql

#配合环境变量

echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile

. /etc/profile

#启动MySQL服务

/etc/init.d/mysqld start


#修改root密码

mysql -uroot

#mysql -uroot -pk8008.com -e "use mysql;update user set

authentication_string=password('新密码') where user='root';"

update mysql.user set authentication_string=password("geeboo")where user='root';



#安装PHP

#安装第三方yum源

wget http://www.atomicorp.com/installers/atomic

sh ./atomic

#使用yum命令安装

yum -y install zlib libxml libjpeg freetype libpng gd curl libiconvzlib-devel gd-devel curl-devel openssl-devel libxslt-devel* php-mcryptlibmcrypt libmcrypt-devel mhash mhash-devel libevent libevent-devel libxml2libxml2-devel bzip2-devel libcurl-devel libjpeg-devel libpng-develfreetype-devel


wget http://mirrors.sohu.com/php/php-5.6.30.tar.gz

tar zxvf php-5.6.30.tar.gz

cd php-5.6.30


./configure \

--prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc \

--with-apxs2=/usr/local/httpd/bin/apxs \

--enable-inline-optimization \

--enable-fpm \

--with-mysql=/usr/local/mysql \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--with-pdo-mysql=/usr/local/mysql \

--with-gettext \

--enable-mbstring \

--with-iconv=/usr/local/libiconv \

--with-mcrypt \

--with-mhash \

--with-openssl \

--enable-bcmath \

--enable-soap \

--with-libxml-dir \

--enable-sockets \

--with-curl \

--with-zlib \

--enable-zip \

--with-bz2 \

--with-gd \

--with-freetype-dir \

--with-jpeg-dir \

--with-iconv \

--with-png-dir


make

make install

cp php.ini-production /usr/local/php/etc/php.ini


修改apache配置文件:

vim /usr/local/httpd/conf/httpd.conf

ServerName 127.0.0.1:80

#增加:

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

#修改用户:

User www

Group www

#修改主页文件:

DirectoryIndex index.php index.html



/usr/local/httpd/bin/apachectl -t

Syntax OK



vim /usr/local/httpd/htdocs/index.php


phpinfo();

?>

#重新加载apache配置文件

/usr/local/httpd/bin/apachectl graceful


测试访问正常!


#编写测试代码,测试数据库链接是否正常

vim /usr/local/httpd/htdocs/mysql-test.php


//$link_id=mysql_connect('主机名','用户','密码');

$link_id=mysql_connect('localhost','root','k8008.com') or mysql_error();

if($link_id){

echo "mysql is ok!\n";

}else{

echo "mysql_error()";

}

?>


#到此LAMP安装完成!




#安装ZABBIX

wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.4/zabbix-3.0.4.tar.gz

yum install net-snmp-devel

tar zxvf zabbix-3.0.4.tar.gz

cd zabbix-3.0.4

./configure --prefix=/usr/local/zabbix --enable-server --enable-agent--with-mysql --with-net-snmp --with-libcurl --with-libxml2

make && make install

echo $?


mysql

create database zabbix

grant all on zabbix.* to 'zabbixuser'@'localhost' identified by'k8008.com';

flush privileges;

use zabbix;

source /usr/local/src/zabbix-3.0.4/database/mysql/schema.sql

source /usr/local/src/zabbix-3.0.4/database/mysql/images.sql

source /usr/local/src/zabbix-3.0.4/database/mysql/data.sql


#配置zabbix_server配置文件修改如下:

LogFile=/usr/local/zabbix/logs/zabbix_server.log

DBHost=127.0.0.1

DBName=zabbix

DBUser=zabbixuser

DBPassword=k8008.com #zabbixuser的密码

LogSlowQueries=3000


cp misc/init.d/fedora/core/* /etc/init.d/

chmod +x /etc/init.d/zabbix_server

chmod +x /etc/init.d/zabbix_agentd

sed -i 's#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g' /etc/init.d/zabbix_agentd

sed -i 's#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g'/etc/init.d/zabbix_server

useradd -s /sbin/nologin -M zabbix

mkdir /usr/local/zabbix/logs

chown -R zabbix.zabbix /usr/local/zabbix/

/etc/init.d/zabbix_agentd start

/etc/init.d/zabbix_server start


#拷贝代码文件到apache发布目录下修改名为zabbix:


cp -a frontends/php /usr/local/httpd/htdocs/zabbix


sed -i 's#;date.timezone =#date.timezone = Asia/Shanghai#g'/usr/local/php/etc/php.ini

sed -i 's#post_max_size = 8M#post_max_size = 16M#g'/usr/local/php/etc/php.ini

sed -i 's#max_execution_time = 30#max_execution_time = 300#g'/usr/local/php/etc/php.ini

sed -i 's#max_input_time = 60#max_input_time = 300#g'/usr/local/php/etc/php.ini

sed -i 's#;always_populate_raw_post_data = -1#always_populate_raw_post_data= -1#g' /usr/local/php/etc/php.ini


#重新加载apache

/usr/local/httpd/bin/apachectl graceful


#zabbix登录

账号:admin

密码:zabbix

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,393评论 5 467
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 83,790评论 2 376
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,391评论 0 330
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,703评论 1 270
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,613评论 5 359
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,003评论 1 275
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,507评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,158评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,300评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,256评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,274评论 1 328
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,984评论 3 316
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,569评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,662评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,899评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,268评论 2 345
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,840评论 2 339

推荐阅读更多精彩内容

  • 一、LAMP环境的介绍 1.LAMP环境的重要性 思索许久,最终还是决定写一篇详细的LAMP的源码编译安装的实验文...
    endmoon阅读 2,589评论 4 26
  • 1.写在前面 本文主要介绍的是zabbix的编译安装过程,包含它的基础环境LNMP,虽然zabbix官方一般推荐的...
    天之蓝色阅读 2,519评论 0 16
  • 1、确认搭建LAMP所需的环境是否已经安装: [root@localhost ~]#rpm -q make gcc...
    4e855d444c9f阅读 455评论 0 0
  • 《脱下军装还是个兵》歌词 应朋友之约,为建军90周年写首关于军人的歌词,几夜构想写出《脱下军装还是个兵》送给我当过...
    号子1113阅读 372评论 1 1
  • 铁砧不知道他怎么回到铁匠铺的,他觉得自己蠢爆了,在麻商发财的院子里,当天仙般的女人向他微笑颔首问好的时候,他居然没...
    深海鲀阅读 366评论 0 4