国产成人毛片视频|星空传媒久草视频|欧美激情草久视频|久久久久女女|久操超碰在线播放|亚洲强奸一区二区|五月天丁香社区在线|色婷婷成人丁香网|午夜欧美6666|纯肉无码91视频

RHEL5配置HTTP服務(wù)

RHEL5.4配置HTTP 服務(wù)下面是關(guān)于linux 下面配置HTTP 服務(wù)的討論,HTTP 介紹HTTP 的全名為Hyper Text Transfer Protocol(超文本傳輸協(xié)議)在linu

RHEL5.4配置HTTP 服務(wù)

下面是關(guān)于linux 下面配置HTTP 服務(wù)的討論,

HTTP 介紹

HTTP 的全名為Hyper Text Transfer Protocol(超文本傳輸協(xié)議)

在linux 下面實(shí)現(xiàn)web 服務(wù),通常使用Apache 來實(shí)現(xiàn),Apache 一直是Internet 上面最流行的web 服務(wù)器,web 服務(wù)器的架設(shè),在linux 下面有個(gè)很著名的架構(gòu)叫l(wèi)amp :linux apache mysql php。

下面是關(guān)于HTTP 這個(gè)服務(wù)的屬性

HTTP 的相關(guān)軟件包

Httpd

HTTP 的守護(hù)進(jìn)程

/usr/sbin/httpd

HTTP 的腳本

/etc/init.d/httpd

HTTP 的端口

80(http) 443(https)

HTTP 的配置文件

/etc/http/* /var/www/*

下面來具體搭建HTTP 服務(wù)

現(xiàn)在我們主要來實(shí)現(xiàn)虛擬主機(jī)的搭建,

虛擬主機(jī)可以實(shí)現(xiàn)在一臺(tái)服務(wù)器上面運(yùn)行多個(gè)站點(diǎn),而且之間互不影響。可以大大的節(jié)約成本。虛擬主機(jī)技術(shù)可以通過三種方式來實(shí)現(xiàn):

基于域名,基于IP ,基于端口的虛擬主機(jī)。

下面主要討論基于域名的虛擬主機(jī)的實(shí)現(xiàn),

在實(shí)現(xiàn)基于域名的虛擬主機(jī)的之前,我們先要在DNS 服務(wù)器里面做好解析。 我已經(jīng)為192.168.0.254這個(gè)IP 地址做了兩個(gè)解析,一個(gè)是www1.example.com ,還有一個(gè)station1.example.com 。

第一步,安裝軟件包

[root@localhost ~]#

[root@localhost ~]# yum -y install httpd

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Cluster | 1.3 kB 00:00

ClusterStorage | 1.3 kB 00:00

Server | 1.3 kB 00:00

,

VT | 1.3 kB 00:00

Setting up Install Process

Resolving Dependencies

There are unfinished transactions remaining. You might consider running

yum-complete-transaction first to finish them.

The program yum-complete-transaction is found in the yum-utils package.

--> Running transaction check

---> Package httpd.i386 0:2.2.3-31.el5 set to be updated

--> Processing Dependency: libapr-1.so.0 for package: httpd

--> Processing Dependency: libaprutil-1.so.0 for package: httpd

--> Running transaction check

---> Package apr.i386 0:1.2.7-11.el5_3.1 set to be updated

---> Package apr-util.i386 0:1.2.7-7.el5_3.2 set to be updated

--> Processing Dependency: libpq.so.4 for package: apr-util

--> Running transaction check

---> Package postgresql-libs.i386 0:8.1.11-1.el5_1.1 set to be updated

--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

Package Arch Version Repository Size

================================================================================

Installing:

1.2 M

Installing for dependencies:

apr i386 1.2.7-11.el5_3.1 Server 123 k

apr-util i386 1.2.7-7.el5_3.2 Server 76 k

postgresql-libs i386 8.1.11-1.el5_1.1 Server 196 k

Transaction Summary

================================================================================

Install 4 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

,

Total size: 1.6 M

Total download size: 1.2 M

Downloading Packages:

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : apr 1/4

Installing : postgresql-libs 2/4

Installing : apr-util 3/4

Installing : httpd 4/4

Installed:

Dependency Installed:

apr.i386 0:1.2.7-11.el5_3.1 apr-util.i386 0:1.2.7-7.el5_3.2 postgresql-libs.i386 0:8.1.11-1.el5_1.1

Complete!

[root@localhost ~]#

HTTP 軟件包就安裝成功了,

第二步,編輯http 的配置文件

vim /etc/httpd/conf/httpd.conf

這個(gè)文件里面的語法很多,我們建議在定義虛擬站點(diǎn)的時(shí)候在這個(gè)文件的最后編輯,從這個(gè)文件的972行開始都是虛擬站點(diǎn)的模板文件,我們可以根據(jù)這些模板文件來定義虛擬站點(diǎn)。

NameVirtualHost 192.168.0.254:80

DocumentRoot /var/www/virt1

ServerName station1. example .com

ServerAlias server1.example .com

DocumentRoot /var/www/virt2

,

ServerName www1. example. com

OK ,現(xiàn)在兩個(gè)基于域名的虛擬站點(diǎn)基本就配置成功了。

現(xiàn)在,這兩個(gè)基于域名的虛擬站點(diǎn)中根目錄還沒有建立,

[root@server1 ~]#

[root@server1 ~]# cd /var/www/

[root@server1 www]# mkdir virt1

[root@server1 www]# mkdir virt2

[root@server1 www]# cd virt1/

[root@server1 virt1]# vim index.html

[root@server1 virt1]# cat index.html

This is station1.example.com webstie!!!

[root@server1 virt1]#

[root@server1 virt1]# cd ../virt2/

[root@server1 virt2]#

[root@server1 virt2]# vim index.html

[root@server1 virt2]# cat index.html

This is www1.example.com website!!!

[root@server1 virt2]#

OK ,這兩個(gè)虛擬站點(diǎn)的根目錄就建立,并且還分別建立了一個(gè)測試頁面。 首先,重啟下http 服務(wù),

[root@server1 ~]#

[root@server1 ~]# service httpd restart

Stopping httpd: [ OK ] Starting httpd: [ OK ]

[root@server1 ~]#

OK ,服務(wù)啟動(dòng)成功了,測試下。

現(xiàn)在我們到瀏覽器里面輸入station1.example.com

,

OK ,頁面顯示正常。

然后在瀏覽器里面輸入www1.example.com

,

OK ,顯示也沒有問題。

剛才我們給station1.example.conf 做了一個(gè)別名為server1.example.com 。 現(xiàn)在我們來測試下,

最后在瀏覽器里面輸入server1.example.com

,

OK ,是和station1這個(gè)顯示的相同的內(nèi)容。

關(guān)于http 服務(wù)的自身的訪問控制

我們可以通過directory 來做權(quán)限控制,

在/etc/httpd/conf/httpd.conf文件的虛擬主機(jī)之間加入directory 選項(xiàng)。 NameVirtualHost 192.168.0.254:80

DocumentRoot /var/www/virt1

ServerName station1. example .com

ServerAlias server1.example. com

options -Indexes -Followsymlinks

order allow,deny

allow from all

deny from 192.168.0.10

,

DocumentRoot /var/www/virt2

ServerName www1. example .com

options -Indexes -Followsymlinks

order deny,allow

deny from all

allow from 192.168.0.10

關(guān)于http 服務(wù)語法參數(shù)的解釋:

NameVirtualHost 192.168.0.254:80

通告虛擬主機(jī)在那個(gè)服務(wù)器上面以及那個(gè)端口,

第一個(gè)虛擬主機(jī)的站點(diǎn),

DocumentRoot /var/www/virt1

虛擬主機(jī)站點(diǎn)的根目錄,

ServerName station1.example.com

定義虛擬主機(jī)站點(diǎn)的域名,

ServerAlias server1.example.com

定義一個(gè)虛擬主機(jī)域名的別名,

定義虛擬主機(jī)站點(diǎn)的訪問控制,

options -Indexes -Followsymlinks

去掉Indexes 和Followsymlinks 的功能,

order allow,deny

allow from all

deny from 192.168.0.10

允許所有,拒絕特定的主機(jī)。(這個(gè)是有順序的)

order deny,allow

deny from all

allow from 192.168.0.10

拒絕所有,允許特定的主機(jī)。(這個(gè)是有順序的)

這個(gè)是語法,與對(duì)應(yīng),表示結(jié)束。

這個(gè)是語法,與對(duì)應(yīng),表示結(jié)束。 現(xiàn)在我們來測試一下,剛才我們定義了允許所有主機(jī)訪問

station1.example.com 這個(gè)虛擬站點(diǎn),拒絕192.168.0.10這臺(tái)主機(jī)訪問station1.example.com 這個(gè)虛擬站點(diǎn)。還定義了拒絕所有主機(jī)訪問www1.example.com 這個(gè)虛擬站點(diǎn),允許192.168.0.10這臺(tái)主機(jī)訪問www1.example.com 這個(gè)虛擬站點(diǎn)。

首先,重啟下http 服務(wù),

[root@server1 ~]#

,

[root@server1 ~]# service httpd restart

Stopping httpd: [ OK ] Starting httpd: [ OK ]

[root@server1 ~]#

OK ,服務(wù)啟動(dòng)成功了,測試下。

現(xiàn)在我們到192.168.0.10這臺(tái)主機(jī)上面去測試。

我們到瀏覽器里面輸入

station1.example.com

可以看到,192.168.0.10的確不可以訪問到station1.example.com 這個(gè)虛擬站點(diǎn)。 現(xiàn)在我們?cè)诘綖g覽器里面輸入www1.example.com

,

可以看到,192.168.0.10的確是可以訪問到www1.example.com 這個(gè)虛擬站點(diǎn)的。 現(xiàn)在我們?cè)诘?92.168.0.254上面來測試一下,它應(yīng)該可以訪問

station1.example.com 這個(gè)虛擬站點(diǎn),應(yīng)該不可以訪問www1.example.com 。 我們到瀏覽器里面輸入station1.example.com ,

標(biāo)簽: