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
虛擬主機的網站
[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>
注意路徑!!!