存档

‘Linux’ 分类的存档

freebsd上安装MYDNS

2011年7月16日 admin 没有评论

mydns也是开源的dns解析服务器软件,国内很多商家都在使用。本文是在freebsd6.0上安装的,采用了mydns+mysql的形式。

1. 安装mydns

# cd /usr/ports/dns/mydns
# make extract
# mkdir /usr/local/www/data/mydns
# cp work/mydns-1.1.0/contrib/MyDNS.pm admin.php create_domain.pl stats.php /usr/local/www/data/mydns
# make install clean

# cd /usr/local/www/data/mydns
# vi admin.php

$dbhost = "localhost";
$dbuser = "mydns";
$dbpass = "password";
$dbname = "mydns";

2. 创建数据库

# mysqladmin -u root -p create mydns

创建数据表

# mydns --create-tables | mysql -u root -p mydns

3. 创建数据库用户

# mysql -u root -p mydns

mysql> GRANT select,insert,update,delete,create,drop ON mydns.* TO mydns@localhost IDENTIFIED BY 'password';
mysql> GRANT select ON mydns.* TO user@localhost IDENTIFIED BY 'password';

4. mydns配置文件

# cp /usr/local/etc/mydns.conf.sample /usr/local/etc/mydns.conf
# chmod 600 /usr/local/etc/mydns.conf
# vi /usr/local/etc/mydns.conf

db-host = localhost             # SQL server hostname
db-user = user                  # SQL server username
db-password = password          # SQL server password
database = mydns                # MyDNS database name

5. 启动mydns

# vi /etc/rc.conf
mydns_enable="YES"
 
# /usr/local/etc/rc.d/mydns.sh start

6. 通过浏览器添加一个域名

http://localhost/mydns/admin.php
分类: Linux 标签: ,

Centos Yum管理安装Apache+PHP+Mysql的基本安装

2011年7月14日 admin 没有评论

1. 安装Apahce, PHP, Mysql, 以及php连接mysql库组件。

yum -y install httpd php mysql mysql-server php-mysql

2. 配置开机启动服务

/sbin/chkconfig httpd on             [设置apache服务器httpd服务开机启动]
/sbin/chkconfig --add mysqld         [在服务清单中添加mysql服务]
/sbin/chkconfig mysqld on             [设置mysql服务开机启动]
/sbin/service httpd start            [启动httpd服务,与开机启动无关]
/sbin/service mysqld start           [启动mysql服务,与开机无关]

3.设置mysql数据库root帐号密码。

mysqladmin -u root password 'newpassword'           [引号内填密码]

4. 让mysql数据库更安全

mysql -u root -p
mysql> DROP DATABASE test;                            [删除test数据库]
mysql> DELETE FROM mysql.user WHERE user = '';        [删除匿名帐户]
mysql> FLUSH PRIVILEGES;                              [重载权限]

5. 按照以上的安装方式, 配置出来的默认站点目录为/var/www/html/
新建一个test.php脚本:

<?php
   phpinfo();
?>

进入centos系统 打开firefox 浏览器输入 http://localhost/test.php就会出来结果

6. 新建一个数据库,添加一个数据库用户,设置用户权限。写个php脚本测试一下数据库连接吧。

mysql> CREATE DATABASE my_db;
mysql> GRANT ALL PRIVILEGES ON my_db.* TO 'user'@'localhost' IDENTIFIED BY 'password';
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql   [安装apache扩展]
yum install php-gd [安装php的扩展]
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
yum -y installmysql-connector-odbcmysql-devel libdbi-dbd-mysql [安装mysql扩展]
分类: Linux 标签: , , ,

在CentOS中安装gcc配置c语言开发环境(转)

2011年7月8日 admin 没有评论

CentOs是linux系统的一种,只要该操作系统安装了gcc软件包,就可以在linux操作系统中进行C语言程序设计。CentOS安装光盘中带有gcc的安装包。

笔者的操作系统是win2003,通过虚拟机安装了CentOS 5.2。CentOS默认安装之后,是没有安装gcc开发包的,需要手动安装,步骤如下:

1 打开VMWare界面,选择菜单VM–Settings,在对话框中选择CDROM,设置参数为Use ISO image,选择CentOS镜像安装文件;

2 启动虚拟机中的CentOS系统,用root登录,在桌面上用鼠标右键新建一终端窗口;

3 在终端中输入 cd /media/CentOS_5.2_Final/CentOS 回车

4 在终端中继续分别输入如下命令
rpm -ivh cpp-4.1.2-42.el5.i386.rpm 回车
rpm -ivh kernel-headers-2.6.18-92.el5.i386.rpm 回车
rpm -ivh glibc-headers-2.5-24.i386.rpm 回车
rpm -ivh glibc-devel-2.5-24.i386.rpm 回车
rpm -ivh libgomp-4.1.2-42.el5.i386.rpm 回车
rpm -ivh gcc-4.1.2-42.el5.i386.rpm 回车

这样gcc就安装好了,可以用如下命令测试一下
gcc – v 测试一下,例如笔者就显示出
“gcc 版本 4.1.2 20080704 (Red Hat 4.1.2-46) “

分类: Linux 标签: ,

Bind 简介

2011年5月13日 admin 1 条评论

一.、Bind 简介。

Bind是一款开放源码的DNS服务器软件,Bind由美国加州大学Berkeley分校开发和维护的,全名为Berkeley Internet Name Domain它是目前世界上使用最为广泛的DNS服务器软件,支持各种unix平台和windows平台。本文将介绍它在Red hat Linux 9中最基本的安装和配置。

二.、软件的相关资源。

官方网站:http://www.bind.com/

源码软件包:Bind 是开源的软件,可以去其官方网站下载。http://www.isc.org/index.pl/sw/bind/ ,目前最新版本为bind-9.3.1。

帮助文档:http://www.isc.org/index.pl/sw/bind/ 有该软件比较全面的帮助文档。

FAQ:http://www.isc.org/index.pl/sw/bind/ 回答了该软件的常见问题。

配置文件样例:http://www.bind.com/bind.html 一些比较标准的配置文件样例。

三.、软件的安装。

1.安装

由其官方网站中下载其源码软件包bind-9.3.1. tar.gz。接下来我将对安装过程的一些重要步骤,给出其解释:

[root@localhost root]#tar xzvf bind-9.3.1. tar.gz
[root@localhost root]#cd bind-9.3.1
[root@localhost bind-9.3.1]#./configure 
[root@localhost bind-9.3.1]#make
[root@localhost bind-9.3.1]#make install

tar xzvf bind-9.3.1.tar.gz 解压缩软件包。

./configure 针对机器作安装的检查和设置,大部分的工作是由机器自动完成的,但是用户可以通过一些参数来完成一定的设置,其常用选项有:

./configure –help 察看参数设置帮助。

–prefix= 指定软件安装目录(默认/usr/local/)。

–enable-ipv6 支持ipv6。

可以设置的参数很多,可以通过 -help察看需要的,一般情况下,默认设置就可以了。

默认情况下,安装过程是不会建立配置文件和一些默认的域名解析的,不过并不妨碍,可以从下载一些标准的配置文件(http://www.bind.com/bind.html),也可以使用本文所提供的样例文件。

默认情况下,安装的deamon为/usr/local/sbin/named

默认的主配置文件,/etc/named.conf(须手动建立)。

2.启动:

[root@localhost root]# /usr/local/sbin/named -g

/usr/local/sbin/named默认情况是一个后台deamon ,-g选项表示前台运行,并将调试信息打印到标准输出,这在我们安装调试阶段是非常有帮助的。

如果建立了配置文件和域名解析文件(关于怎样建立将在下面的部分讲到),ps aux 应该可以查到named 的进程,或netstat -an 也可以看到53端口的服务已经起来了。(DNS默认端口为53)

如果要设置开机自启动DNS server,只需在/etc/rc.d/rc.local中加入一行

/usr/local/sbin/named

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
 
/usr/local/sbin/named

四.软件的配置。

1.主配置文件

默认安装主配置文件的位置为

/etc/named.conf

下面逐步分析一个比较基础的配置文件:(注:named配置文件采用和c语言相同的注释符号)。

(1) log options

/*
 * log option
 */
logging { 
	channel default_syslog { syslog local2; severity error; };
	channel audit_log { file "/var/log/named.log"; severity error; print-time yes; };
	category default { default_syslog; }; 
	category general { default_syslog; }; 
	category security { audit_log; default_syslog; }; 
	category config { default_syslog; }; 
	category resolver { audit_log; }; 
	category xfer-in { audit_log; }; 
	category xfer-out { audit_log; }; 
	category notify { audit_log; }; 
	category client { audit_log; }; 
	category network { audit_log; }; 
	category update { audit_log; }; 
	category queries { audit_log; }; 
	category lame-servers { audit_log; };
};

这一部分是日志的设置,其中最主要的是

file “/var/log/named.log” 这一句指定了日志文件的位置,要正常启动named,必须要保证这一文件是存在的,并且named 进程对它有读写权限。

(2) options

 
options {
	directory "/etc/namedb";
 
    listen-on-v6 { any; };
 
// If you've got a DNS server around at your upstream provider, enter
// its IP address here, and enable the line below.  This will make you
// benefit from its cache, thus reduce overall DNS traffic in the Internet.
 
	forwarders {
		your.upper.DNS.address;
	};
 
	/*
	 * If there is a firewall between you and nameservers you want
	 * to talk to, you might need to uncomment the query-source
	 * directive below.  Previous versions of BIND always asked
	 * questions using port 53, but BIND 8.1 uses an unprivileged
	 * port by default.
	 */
	// query-source address * port 53;
 
	/*
	 * If running in a sandbox, you may have to specify a different
	 * location for the dumpfile.
	 */
	dump-file "/etc/named_dump.db";
};

这一部分是一些基本的配置项:

directory “/etc/namedb”; 指定域名解析等文件的存放目录(须手动建立);

listen-on-v6 { any; }; 支持ipv6的请求;

forwarders {

your.upper.DNS.address;

}; 指定前向DNS,当本机无法解析的域名,就会被转发至前向DNS进行解析。

dump-file “/etc/named_dump.db”; 指定named_dump.db文件的位置。

(3) 线索域和回环域

// Setting up secondaries is way easier and the rough picture for this
// is explained below.
//
// If you enable a local name server, don’t forget to enter 127.0.0.1
// into your /etc/resolv.conf so this server will be queried first.
// Also, make sure to enable it in /etc/rc.conf.

zone “.” {
type hint;
file “named.root”;
};

zone “0.0.127.IN-ADDR.ARPA” {
type master;
file “localhost.rev”;
};

指定线索域和本地回环域,这一部分使用一些标准的例子就可以。

file “named.root”; 指定该域的解析文件,其目录为options中directory “/etc/namedb”;指定的。在本例中为/etc/namdb。

(4)自定义域

zone "test.com" {
	type	master;
	file	"zone.test ";
};
 
zone "0.168.192.in-addr.arpa" {
	type	master;
	file	"zone. test.rev";
};
zone "4.0.0.f.0.5.2.0.1.0.0.2.IP6.ARPA" {	
	type master;
	allow-transfer { any;};
        allow-query { any; };		
	file "ipv6.rev";
};
 
zone "lowerlevelzone.test.com" {
	type	slave;
		masters {
		192.168.1.1;
	};
};

这一部分是配置文件中我们需要重点关心的部分:

zone “test.com” {

type master;

file “zone.test “;

}; 设定test.com域;

type master 指明该域主要由本机解析;

file “zone.test “指定其解析文件为zong.test,目录为options中设定的目录本例中为/etc/named。

zone “0.168.192.in-addr.arpa” {

type master;

file “zone. test.rev”;

}; 指定ipv4地址逆向解析

type master 指明该域主要由本机解析;

file “zone.test.rev “指定其解析文件为zong.test.rev,目录为options中设定的目录本例中为/etc/named。

zone “4.0.0.f.0.5.2.0.1.0.0.2.IP6.ARPA” {

type master;

allow-transfer { any;};

allow-query { any; };

file “ipv6.rev”;

};指定ipv4地址逆向解析

type master 指明该域主要由本机解析;

file ” ipv6.rev “指定其解析文件为ipv6.rev,目录为options中设定的目录本例中为/etc/named。

zone “lowerlevelzone.test.com” {

type slave;

masters {

192.168.1.1;

};

}; 设定lowerlevelzone.test.com域;

type slave 指明该域主要由低一级的域名服务器解析;

masters {

192.168.1.1;

}; 指定低一级的域名服务器ip地址。

到此我们就初步建立了一个标准的named 的主配置文件,接下来建立对应的域名解析或逆向解析文件。

2.域名解析和IP地址逆向解析文件:

(1) 域名解析:

/etc/namedb/zone.test
 
 
;	From: @(#)localhost.rev	5.1 (Berkeley) 6/30/90
; $FreeBSD: src/etc/namedb/PROTO.localhost.rev,v 1.6 2000/01/10 15:31:40 peter Exp $
;
; This file is automatically edited by the `make-localhost' script in
; the /etc/namedb directory.
;
@	IN	SOA	ns.test.com. root.test.com.(
				2005030116; Serial
				3600	; Refresh
				900	; Retry
				3600000	; Expire
				3600 )	; Minimum
	IN	NS	ns.test.com
;
 
ns		IN	A	192.168.0.1
www6	IN	AAAA	2001:250:f004::10
www	IN	A	192.168.0.2

本文件前半部分是一些默认的参数设置,只需把域名改成对应得你要设置的域就行,其余的不用过分深究,如果读者有兴趣可以查阅相关的手册文档。

(注意,

IN NS ns.test.com;

这一条必须有,来指定本域的域名服务器 ;

域名必须以”.”结尾。)

本文件的第二部分(倒数三行),指定了该域上的主机:

ns IN A 192.168.0.1

ns 为主机名,A 代表地址类型为IPV4地址,192.168.0.1 是实际ip地址,这一条记录的含义是ns.test.com 的ip地址为 192.168.0.1

www6 IN AAAA 2001:250:f004::10

www6 为主机名,AAAA代表地址类型为IPV6地址,2001:250:f004::10 是其IPV6地址,这条记录的含义是www6.test.com 的ip地址是2001:250:f004::10 。

(2)IP地址逆向解析:

ipv4 逆向解析:

/etc/namedb/zone.test.rev

; From: @(#)localhost.rev 5.1 (Berkeley) 6/30/90
; $FreeBSD: src/etc/namedb/PROTO.localhost.rev,v 1.6 2000/01/10 15:31:40 peter Exp $
;
; This file is automatically edited by the `make-localhost’ script in
; the /etc/namedb directory.
;
@ IN SOA ns.test.com. root.test.com.(
2005030116; Serial
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ) ; Minimum
IN NS ns.test.com
;

1 IN PTR ns.test.com.
2 IN PTR www.test.com.

ipv6 逆向解析:

/etc/namedb/zone.test.rev

; From: @(#)localhost.rev 5.1 (Berkeley) 6/30/90
; $FreeBSD: src/etc/namedb/PROTO.localhost.rev,v 1.6 2000/01/10 15:31:40 peter Exp $
;
; This file is automatically edited by the `make-localhost’ script in
; the /etc/namedb directory.
;
@ IN SOA ns.test.com. root.test.com.(
2005030116; Serial
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ) ; Minimum
IN NS ns.test.com
;

10.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN www6.test.com.

这里

10.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN www6.test.com.

与主配置文件/etc/named.conf中的

zone “4.0.0.f.0.5.2.0.1.0.0.2.IP6.ARPA”

“10.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0″ + “4.0.0.f.0.5.2.0.1.0.0.2″ 刚好组成点分的32位16进制逆序ipv6地址。

实际上,ip地址逆向解析由于缺乏统一的管理和相关的标准,这项服务的使用比较混乱,可以考虑不启动该服务。所以在这里只给出两个例子,就不过多解释了。

五.安装使用的一些经验:

1.带调试信息的启动

named -g

/usr/local/sbin/named默认情况是一个后台deamon ,-g选项表示前台运行,并将调试信息打印到标准输出,这在我们安装调试阶段是非常有帮助的。

2.客户端命令nslookup简介

windows ,linux 平台均支持此调试命令。

键入nslookup即进入与服务器交互状态,这时键入域名或ip地址就可以向服务器正向或逆向查询。

>www.test.com 正向域名解析

>192.168.0.1 逆向IP解析

>set type=AAAA 设置查询地址类型为IPv6地址类型。

>set type=A 设置查询地址类型为IPv4地址类型。

>exit 退出。

参考资料:

[1]:http://www.bind.com/

[2]:http://www.isc.org/index.pl?/sw/bind/

[3]:ipv6.bupt.edu.cn

分类: Linux 标签: