顶九网服务器搭建手册之AMPF环境搭建(2)

二、安装MySQL

1、安装mysql

# cd /usr/ports/databases/mysql50-server

# make WITH_CHARSET=gbk \

WITH_XCHARSET=all \

SKIP_DNS_CHECK=yes \

BUILD_OPTIMIZED=yes \

BUILD_STATIC=yes

#make install

#make clean

2、使mysql50和系统一起启动

# vi /etc/rc.conf  加入

mysql_enable=”YES”

3、启动mysql50

#/usr/local/share/mysql/mysql.server start

/usr/local/etc/rc.d/mysql-server.sh start

如果以上两条命令不能启动mysql

那么请reboot系统来启动mysql

 

4、设置mysql50的密码

# /usr/local/bin/mysqladmin -u root password ‘password’

这里的密码password可以自由设定。不一定为password.

5、登陆mysql5数据库.

# mysql -u root –p password

如果见到下面信息,即表示登陆成功。

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 77 to server version: 5.0.22

 

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

 

mysql>

 

三、mysql数据库优化 .(略)

二、安装apache2.2.2

一、安装apache

# cd /usr/ports/www/apache22

# make install clean

在弹出的PYTHON安装选择框里选择:HUGE_STACK_SIZE  Use a larger thread stack

在安装gettext ,将EXAMPLES 与HTMLMAN 两项选项都选上。

二、编辑/etc/rc.conf,加入

Apache22_enable=”YES”

三、重启服务器。

顶九网服务器搭建手册之AMPF环境搭建(1)

安装webmin

Webmin是一个强大而非常有用的在线管理软件,可以管理所有服务器的配置文件.

# cd /usr/ports/sysutils/webmin

# make

# make install

# make clean

# make rmconfig

# /usr/local/lib/webmin/setup.sh

 

# /usr/local/lib/webmin/setup.sh

***********************************************************************

*            Welcome to the Webmin setup script, version 1.270        *

***********************************************************************

Webmin is a web-based interface that allows Unix-like operating

systems and common Unix services to be easily administered.

 

Installing Webmin in /usr/local/lib/webmin …

 

***********************************************************************

Webmin uses separate directories for configuration files and log files.

Unless you want to run multiple versions of Webmin at the same time

you can just accept the defaults.

 

Log file directory [/var/log/webmin]:  #这里直接按回车,选默认值

***********************************************************************

Webmin is written entirely in Perl. Please enter the full path to the

Perl 5 interpreter on your system.

 

Full path to perl (default /usr/bin/perl): #也是直接按回车,选默认值

Testing Perl …

Perl seems to be installed ok

 

***********************************************************************

Operating system name:    FreeBSD

Operating system version: 6.0

 

***********************************************************************

Webmin uses its own password protected web server to provide access

to the administration programs. The setup script needs to know :

– What port to run the web server on. There must not be another

web server already using this port.

– The login name required to access the web server.

– The password required to access the web server.

– If the webserver should use SSL (if your system supports it).

– Whether to start webmin at boot time.

 

Web server port (default 10000): #这是也是按回车,选默认值

Login name (default admin): #这里也是直接按回车,选默认值

Login name (default admin):

Login password:

Password again: #这里输入两次密码

Use SSL (y/n): y

然后,编辑/etc/rc.conf增加启动.

# vi  /etc/rc.conf

添加

webmin_enable=”YES”

然后重启系统,webmin的在线管理服务器功能就生效。

FreeBSD 下用nagios来监控网络服务器和网络服务(8)

service_description         mysql

is_volatile               0

check_period             24×7

max_check_attempts         1

normal_check_interval       1

retry_check_interval         1

contact_groups             admins

notification_options         w,u,c,r

notification_interval       960

notification_period         24×7

check_command             check_mysql!100.0,20%!500.0,60%

}

 

define service{

use                   generic-service       ; Name of service template to use

host_name               test_nrpe

service_description         ntp

is_volatile               0

check_period             24×7

max_check_attempts         1

normal_check_interval       1

retry_check_interval         1

contact_groups             admins

notification_options         w,u,c,r

notification_interval       960

notification_period         24×7

check_command             check_ntp!100.0,20%!500.0,60%

}

 

define service{

use                   generic-service       ; Name of service template to use

host_name               test_nrpe

service_description         qmail_smtp

is_volatile               0

check_period             24×7

max_check_attempts         1

normal_check_interval       1

retry_check_interval         1

contact_groups             admins

notification_options         w,u,c,r

notification_interval       960

notification_period         24×7

check_command             check_smtp!100.0,20%!500.0,60%

}

 

define service{

use                   generic-service       ; Name of service template to use

host_name               test_nrpe

service_description         qmail_pop3

is_volatile               0

check_period             24×7

max_check_attempts         1

normal_check_interval       1

retry_check_interval         1

contact_groups             admins

notification_options         w,u,c,r

notification_interval       960

notification_period         24×7

check_command             check_pop!100.0,20%!500.0,60%

}

 

define service{

use                   generic-service       ; Name of service template to use

host_name               test_nrpe

service_description         test_load

is_volatile               0

check_period             24×7

max_check_attempts         1

normal_check_interval       1

retry_check_interval         1

contact_groups             admins

notification_options         w,u,c,r

notification_interval       960

notification_period         24×7

check_command             check_load!100.0,20%!500.0,60%

}

 

define service{

use                   generic-service       ; Name of service template to use

host_name               test_nrpe

service_description         test_disk

is_volatile               0

check_period             24×7

max_check_attempts         1

normal_check_interval       1

retry_check_interval         1

contact_groups             admins

notification_options         w,u,c,r

notification_interval       960

notification_period         24×7

check_command             check_disk!100.0,20%!500.0,60%

}

 

四、检查配置参数并重启nagios

 

 

9)如何在nagios中使用外部命令

vi /usr/local/nagios/etc/nagios.cfg

check_external_commands=1

 

mkdir /usr/local/nagios/var/rw

chown nagios.nagcmd /usr/local/nagios/var/rw

chmod u+rw /usr/local/nagios/var/rw

chmod g+rw /usr/local/nagios/var/rw

chmod g+s /usr/local/nagios/var/rw

 

svc -t /service/nagios/

/usr/local/apache2/bin/apachectl restart