手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux基本知识点总结——Apache

[日期:2013-05-14] 来源:Linux社区  作者:sunshyfangtian [字体:大 中 小]

二、Apache服务器配置

1.首先创建测试需要用到的主面文件,如下:

[root@itpro html]# ls

index.html  op  sq

[root@itpro html]# cat index.html

this is home page

server: 192.168.56.53

[root@itpro html]# cat op/index.html

this is op page

server: 192.168.56.53

[root@itpro html]# cat sq/index.html

this is sq page

server: 192.168.56.53

2.修改主配文件/etc/httpd/conf/httpd.conf

首先启用NameVirtualHost字段,该字段为一个基于域名的虚拟主机指定一个IP地址,*表示本机当前使用的IP地址。

NameVirtualHost *:80  #这一行默认是注释掉了的,要将其前面的#去掉

然后在文件末尾增加以下内容:

<VirtualHost *:80>

#    ServerAdmin webmaster@dummy-host.example.com

    DocumentRoot /var/www/html  #文档的根目录。默认情况下,所有的请求从这个目录进行应答

    ServerName 192.168.56.53  #机子的名称,用IP地址或域名表示

#    ErrorLog logs/dummy-host.example.com-error_log #可以指定错误日志存放目录,若不指定,默认是在/etc/httpd/logs/access_log里

#    CustomLog logs/dummy-host.example.com-access_log common

</VirtualHost>

<VirtualHost *:80>

    DocumentRoot /var/www/html/op

    ServerName www.op.com

</VirtualHost>

<VirtualHost *:80>

    DocumentRoot /var/www/html/sq

    ServerName www.sq.com

</VirtualHost>

 

 

3.重启httpd服务

[root@itpro ~]# service httpd restart

Stopping httpd:                                            [  OK  ]

Starting httpd: httpd: apr_sockaddr_info_get() failed for zoro

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

                                                          [  OK  ]

linux
相关资讯       Linux基本知识点总结 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款