WWW服務:

Apache

卸載httpd:

[root@bogon ~]# yum remove httpd

查詢httpd是否安裝:

[root@bogon ~]# rpm -qa|grep httpd

安裝httpd

[root@bogon ~]# yum install httpd

進入httpd主配置文件:

[root@bogon ~]# vi /etc/httpd/conf/httpd.conf

修改主配置文件:

262 ServerAdmin root@123.com 改不改都可以

276 ServerName www.123.com:80

402 DirectoryIndex index.html index.html.var a.html

創建網站主文件

[root@bogon ~]# cd /var/www/html/

[root@bogon html]# touch a.html 創建一個a.html的文件

[root@bogon html]# echo "hello">a.html 將hello放入a.html中

[root@bogon html]# cat a.html 查看a.html中的內容

hello

[root@bogon html]#

啟動服務:

[root@bogon html]# service httpd restart

Stopping httpd: [FAILED]

Starting httpd: [ OK ]

安裝命令行的瀏覽器

[root@bogon ~]# yum install lynx

測試網站

[root@bogon ~]# lynx www.123.com

關閉防火墻

[root@bogon ~]# service iptables stop

虛擬主機的網站

www.123.com

www1.123.com

www2.123.com

[root@bogon named]#cd /var/named

[root@bogon named]# vi z

$TTL 1D

@ IN SOA @ rname.invalid. (

0 ; serial

1D ; refresh

1H ; retry

1W ; expire

3H ) ; minimum

NS @

A 192.168.1.100

www A 192.168.1.100

www1 A 192.168.1.100

www2 A 192.168.1.100

[root@bogon named]# service named restart

Stopping named: .[ OK ]

Starting named: [ OK ]

[root@bogon named]# vi /etc/httpd/conf/httpd.conf

NameVirtualHost 192.168.1.100:80

#

# NOTE: NameVirtualHost cannot be used without a port specifier

# (e.g. :80) if mod_ssl is being used, due to the nature of the

# SSL protocol.

#

#

# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.

# The first VirtualHost section is used for requests without a known

# server name.

<VirtualHost www.123.com:80>

DocumentRoot /var/www/html

ServerName www.123.com

DirectoryIndex a.html

</VirtualHost>

<VirtualHost www1.123.com:80>

DocumentRoot /www1

ServerName www1.123.com

DirectoryIndex b.html

</VirtualHost>

<VirtualHost www2.123.com:80>

DocumentRoot /www2

ServerName www2.123.com

DirectoryIndex c.html

</VirtualHost>

啟動服務:

[root@bogon html]# service httpd restart

Stopping httpd: [FAILED]

Starting httpd: [ OK ]

<VirtualHost www.123.com:80>

DocumentRoot /var/www/html

ServerName www.123.com

DirectoryIndex a.html

</VirtualHost>

<VirtualHost www1.123.com:80>

DocumentRoot /www1

ServerName www1.123.com

DirectoryIndex b.html

</VirtualHost>

<VirtualHost www2.123.com:80>

DocumentRoot /www2

ServerName www2.123.com

DirectoryIndex c.html

</VirtualHost>

注意路徑!!!

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容