系统:centos-7.2-x86_64
IP:172.16.10.202
服务:Smokeping
1、更新yum源
[1] 首先备份/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[2] 进入yum源配置文件所在文件夹
cd /etc/yum.repos.d/
[3] 下载163的yum源配置文件,放入/etc/yum.repos.d/(操作前请做好相应备份)
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
[4] 运行yum makecache生成缓存
yum makecache
[5] 更新系统
yum update -y
[6] 安装vim编辑器
yum -y install vim lrzsz
2、关闭seliux和iptables 允许80端口,并同步系统时间
vim /etc/selinux/config #修改SELINUX=disabled
setenforce 0 #临时生
vim /etc/sysconfig/iptables #iptables 允许80端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpdate us.pool.ntp.org
echo "0 */1 * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP" >> /var/spool/cron/root
3、安装apache和必要依赖
yum install httpd perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-IO-Socket-SSL perl-Socket6 curl libart* pango* cairo* libxml2* cpan perl perl-FCGI perl-CGI perl-Digest-HMAC perl-Net-Telnet perl-Net-OpenSSH perl-Net-SNMP perl-LDAP perl-Net-DNS perl-IO-Pty-Easy perl-Test-Simple perl-Sys-Syslog perl-libwww-perl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-Time-HiRes perl-ExtUtils-MakeMaker rrdtool rrdtool-perl curl fping httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fcgid screen -y
yum groupinstall "Compatibility libraries" "Base" "Development tools" -y
更换国外的源
在下面链接,找对应自己的版本http://www.rpmfind.net/linux/rpm2html/search.php?query=rpmforge-release
安装其它的依赖包
yum install -y fping echoping perl-CGI-SpeedyCGI perl-RadiusPerl cgilib* gcc perl-ExtUtils-MakeMaker rrdtool-devel
下载rrdtool并安装rrdtool
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.6.0.tar.gz
tar zxvf rrdtool-1.6.0.tar.gz
cd rrdtool-1.6.0
./configure --prefix=/usr/local/rrdtool && make && make install
cp /usr/local/rrdtool/lib/perl/5.16.3/x86_64-linux-thread-multi/auto/RRDs/RRDs.so /usr/lib64/perl5/
cp /usr/local/rrdtool/lib/perl/5.16.3/x86_64-linux-thread-multi/RRDs.pm /usr/lib64/perl5/
下载并安装smokeping
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz
tar zxvf smokeping-2.6.11.tar.gz
cd smokeping-2.6.11
./configure --prefix=/usr/local/smokeping
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
如果出现过IO::Pty perl module,解决方法如下
perl -e shell -MCPAN
> install IO::Pty
否则执行以下操作
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install
配置smokeping
cd /usr/local/smokeping/
cp htdocs/smokeping.fcgi.dist htdocs/smokeping.fcgi
cp etc/config.dist etc/config
cp etc/basepage.html.dist etc/basepage.html
cp etc/smokemail.dist etc/smokemail
cp etc/tmail.dist etc/tmail
cp etc/smokeping_secrets.dist etc/smokeping_secrets
创建缓存目录等
mkdir img data var cache
chmod 777 img data var cache
chown apache:apache -R ./
创建软链接
cd /usr/local/smokeping/
ln -s htdocs/smokeping.fcgi smokeping.fcgi
创建Smokeping用户及访问密码
htpasswd -c /etc/httpd/smokepingpwd smokeping
vim /etc/httpd/conf/httpd.conf
在最后添加以下内容
Alias /smokeping "/usr/local/smokeping/"
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Options Indexes FollowSymLinks EXecCGI
#AllowOverride None
AllowOverride AuthConfig
AddHandler cgi-script .cgi .fcgi
DirectoryIndex smokeping.fcgi
Order allow,deny
Allow from all
AuthType Basic
AuthName "This is Private Servers!Please verify your identity!"
AuthUserFile /etc/httpd/smokepingpwd
Require valid-user
</Directory>
systemctl restart httpd
创建smokeping启动脚本
vim /etc/init.d/smokeping
添加以下内容
#!/bin/bash
#
# chkconfig: 2345 80 05
# Description: Smokeping init.d script
# Get function from functions library
. /etc/init.d/functions
# Start the service Smokeping
start() {
echo -n "Starting Smokeping: "
/usr/local/smokeping/bin/smokeping >/dev/null 2>&1
### Create the lock file ###
touch /var/lock/subsys/smokeping
success $"Smokeping startup"
echo
}
# Restart the service Smokeping
stop() {
echo -n "Stopping Smokeping: "
kill -9 `ps ax | grep "/usr/local/smokeping/bin/smokeping" | grep -v grep | awk '{ print $1 }'` >/dev/null 2>&1 && killall speedy_backend
### Now, delete the lock file ###
rm -f /var/lock/subsys/smokeping
success $"Smokeping shutdown"
echo
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status Smokeping
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
修改smokeping脚本权限,设置必要服务的开机启动
chmod 755 /etc/init.d/smokeping
chkconfig smokeping on
systemctl enable httpd.service
chmod 600 /usr/local/smokeping/etc/smokeping_secrets
chown -R apache:apache /usr/local/smokeping
chmod u+s /usr/local/smokeping/bin/smokeping
systemctl restart httpd
/etc/init.d/smokeping restart
===================
网友评论