配置dns和apache
環境描述
我的環境:2臺Linux redhat6-2 2.6.32-220.el6.i686和1臺windXp做測試
A:192.168.16.11 RedHat 作 DNS伺服器
B:192.168.16.12 RedHat 作 APACHE伺服器
C:192.168.16.1 真機winXp作測試端
配置DNS
在計算機A上用yum工具裝DNS的軟體包:
[root@redhat6-1 named]# yum install bind*
檢視配置檔案許可權
[root@redhat6-1 named]# cd /etc/
[root@redhat6-1 etc]# ll named.conf
-rw-r-----. 1 root named 930 Feb 15 2010 named.conf
修改配置檔案,新增訪問限制,此處全改為any,也可根據自己需求變更:
[root@redhat6-1 ~]# vi /etc/named.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
在修改配置檔案時很容易發現區zone檔案的路徑:
新增自己的zone:
[root@redhat6-1 ~]# vi /etc/named.rfc1912.zones
#正解:
zone "myapache.com" IN {
type master;
file "named.myapache.com";
};
#反解:
zone "192.168.16.in-addr.arpa" IN {
type master;
file "named.192.168.16";
};
編輯正反解檔案
該檔案有模板,留心的話在配置檔案中可以看到它的目錄:/usr/share/doc/bind*/sample/
可以直接copy到named的目錄
# cp /usr/share/doc/bind-9.7.3/sample/var/named/* /var/named/chroot/var/named/ -p
[root@redhat6-1 named]# cp -rf named.localhost named.myapache.com
[root@redhat6-1 named]# vi named.myapache.com
注意後面的 ’.’
$TTL 1D
@ IN SOA myapache.com. root.myapache.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
www A 192.168.16.12
[root@redhat6-1 named]# vi named.192.168.16
$TTL 1D
@ IN SOA myapache.com. root.myapache.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
12 IN PTR
[root@redhat6-1 named]# service named restart
Stopping named: . [ OK ]
Starting named: [ OK ]
注:需要有防火牆配置,此處我直接把防火牆關了
B機上配置APACHE
仍然利用yum安裝http包
[root@redhat6-2 named]# yum install http*
具體安裝的包如下:
httpd-2.2.15-15.el6.i686
httpd-devel-2.2.15-15.el6.i686
httpd-manual-2.2.15-15.el6.noarch
httpd-tools-2.2.15-15.el6.i686
啟動apache
[root@redhat6-2 ~]# service httpd start
Starting httpd: [ OK ]
到此處基本的環境配置完成,可以在windows機器上測試了~
注:我所用的方法是禁用本地連結,指定VMnet1網路卡的DNS為我的DNS伺服器(兩天redhat網路卡均為Host-only),也可以直接修改瀏覽器的代理伺服器,此處不贅述。
開啟瀏覽器,輸入剛剛配置的域:
可以看到apache的歡迎介面,
配置個人主頁:
修改配置檔案:
[root@redhat6-2 ~]# vi /etc/httpd/conf/httpd.conf
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
#UserDir disabled //開啟個人目錄功能
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
UserDir public_html
ptions Indexes FollowSymLinks
Order allow,deny
Allow from all
/var/www/html為預設的目錄,有必要的話也可以自己修改,此處不用修改
末行加入:
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny //allow,deny為兩個規則,有先後順序,衝突的話後者有效
Allow from all //此處沒有任何限制
建立使用者:
[root@redhat6-2 ~]# useradd tuantuan
[root@redhat6-2 ~]# passwd tuantuan
Changing password for user tuantuan.
New password:
BAD PASSWORD: it is WAY too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@redhat6-2 ~]# su - tuantuan
[tuantuan@redhat6-2 ~]$ mkdir public_html
[tuantuan@redhat6-2 ~]$ su - root
[root@redhat6-2 home]# chmod 755 tuantuan
[tuantuan@redhat6-2 ~]$ vi ./public_html/Hello.txt
Hello Apache !!!
再次開啟瀏覽器輸入進行測試
設定個人主頁密碼:
[root@redhat6-2 tuantuan]# cd /home/tuantuan/public_html/
[root@redhat6-2 public_html]# vi .htaccess
AuthType Basic
AuthName "your password text" //密碼提示
AuthUserFile /home/tuantuan/public_html/.passwords //密碼檔案路徑
Require user tuantuan //所設定的使用者名稱
[root@redhat6-2 public_html]# htpasswd -c /home/tuantuan/public_html/.passwords tuantuan
New password:
Re-type new password:
Adding password for user tuantuan
再次訪問 彈出密碼提示
可以看到自己的主目錄下的檔案了
右鍵點選一個檔案,另存為便可下載儲存到自己的電腦
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8494287/viewspace-1349501/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ubuntu 配置靜態IP 和 DNSUbuntuDNS
- 偽靜態配置apache 和nginxApacheNginx
- php和apache2的配置PHPApache
- solaris DNS 配置DNS
- RHEL8&CentOS8配置IP地址和DNSCentOSDNS
- 配置linux DNSLinuxDNS
- scan-dns配置DNS
- CENTOS下配置DNSCentOSDNS
- RHEL 5 DNS 配置DNS
- DNS配置全文(轉)DNS
- solaris的dns配置DNS
- DNS劫持和DNS汙染DNS
- Apache + PHP配置ApachePHP
- linux 修改 dns 配置LinuxDNS
- Linux中DNS配置LinuxDNS
- Apache Thrift 配置環境和執行(Linux)ApacheLinux
- apache tomcat叢集配置和負載均衡ApacheTomcat負載
- 配置apache和nginx的tomcat負載均衡ApacheNginxTomcat負載
- windows環境下Resin和apache的配置薦WindowsApache
- Windows下PHP和Apache的安裝與配置WindowsPHPApache
- Ubuntu配置Django和apache+mod_python(轉)UbuntuDjangoApachePython
- Linux DNS 伺服器安裝、配置和維護LinuxDNS伺服器
- apache路由埠配置Apache路由
- apache配置反向代理Apache
- DNS和BINDDNS
- 配置Ubuntu DNS伺服器UbuntuDNS伺服器
- consul dns 轉發配置DNS
- Redhat linux DNS配置指南RedhatLinuxDNS
- redhat 5 dns配置示例一RedhatDNS
- dns配置高階篇(轉)DNS
- DNS.com和DNS盾免費DNS解析、DNSPOD阿里公共DNS等DNS阿里
- apache 配置檔案的配置(轉)Apache
- Apache+php在windows下的安裝和配置ApachePHPWindows
- CentOs 6下配置帶Apache和Passenger的Rails 4CentOSApacheAI
- DNS 配置單純為轉發的DNS伺服器DNS伺服器
- linux apache泛域名解析及dns相關LinuxApacheDNS
- PHP1:在Windows上安裝和配置PHP,Apache和MySQLPHPWindowsApacheMySql
- DNS劫持與DNS汙染是什麼意思、dns劫持和汙染DNS