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>

注意路径!!!

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容