配置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 www.myapache.com.
[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),也可以直接修改瀏覽器的代理伺服器,此處不贅述。
開啟瀏覽器,輸入剛剛配置的域:http://www.myapache.com/
可以看到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 !!!
再次開啟瀏覽器輸入http://www.myapache.com/~tuantuan/Hello.txt進行測試
設定個人主頁密碼:
[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
再次訪問http://www.myapache.com/~tuantuan 彈出密碼提示
可以看到自己的主目錄下的檔案了
右鍵點選一個檔案,另存為便可下載儲存到自己的電腦
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29320885/viewspace-1236913/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ubuntu 配置靜態IP 和 DNSUbuntuDNS
- 偽靜態配置apache 和nginxApacheNginx
- RHEL8&CentOS8配置IP地址和DNSCentOSDNS
- Apache Thrift 配置環境和執行(Linux)ApacheLinux
- DNS劫持和DNS汙染DNS
- Apache安全配置Apache
- Apache + PHP配置ApachePHP
- apache路由埠配置Apache路由
- 配置Apache2.4.46Apache
- apache常用的配置Apache
- linux apache泛域名解析及dns相關LinuxApacheDNS
- 配置Ubuntu DNS伺服器UbuntuDNS伺服器
- DNS和BINDDNS
- Apache 配置日誌切割Apache
- Apache的配置詳解Apache
- 1.3.1 apache的配置(下)Apache
- Apache配置與應用Apache
- 案例:配置apache和nginx的SSL加密傳輸協議ApacheNginx加密協議
- Linux 中檢視 DNS 與 配置LinuxDNS
- DNS劫持與DNS汙染是什麼意思、dns劫持和汙染DNS
- DHCP 和 DNS 示例DNS
- apache虛擬機器配置步驟和修改訪問埠Apache虛擬機
- apache代理伺服器配置Apache伺服器
- phpstudy apache 配置 https 證照PHPApacheHTTP
- Linux+apache 跨域配置LinuxApache跨域
- Apache靜態快取配置Apache快取
- 電腦dns配置錯誤無法上網怎麼辦 dns配置錯誤不能上網DNS
- DNS域名解析服務及其配置DNS
- PowerDNS 配置 DNS 名稱伺服器DNS伺服器
- Linux---DNS域名解析如何配置LinuxDNS
- 雙AdguardHome配置做DNS伺服器DNS伺服器
- 阿里雲映象站DNS——Chrome配置方法阿里DNSChrome
- Centos 6 DNS 配置 解決 Unknown hostCentOSDNS
- dns異常怎麼修復 dns配置異常怎麼處理DNS
- 用phpStudy配置apache伺服器PHPApache伺服器
- 如何配置 Apache Web 伺服器ApacheWeb伺服器
- apache配置Expire/Cache-Control頭Apache
- dns配置錯誤網頁打不開 電腦dns配置錯誤無法上網怎麼辦DNS網頁
- Centos7系統配置DNS服務CentOSDNS