红联Linux门户
Linux帮助

请教:http配置问题

发布时间:2010-01-07 14:13:32来源:红联作者:ywhqiuyun
今天我配置http,最后
service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
但是我在浏览器上输入http://www.example.com
但是不显示我都网页,输出是You have reached this web page by typing "example.com", "example.net", or "example.org" into your web browser.
These domain names are reserved for use in documentation and are not available for registration.

httpd.conf 配置如下
NameVirtualHost 192.168.100.101

ServerName www.example.com
ServerAdmin ywhqiuyun.yuer@www.example.com
DocumentRoot /var/www/virtual/www.example.com/html
ErrorLog logs/www.example.com-error_log
CustomLog logs/www.example.com-access_log combined

Options Indexes Includes




请问:是什么原因?
文章评论

共有 8 条评论

  1. ywhqiuyun 于 2010-01-09 12:52:29发表:

    8# xiadao_81

    我是配置虚拟主机。
    在浏览器上输入 http://192.168.100.101/
    输出:www.example.com

    在浏览器上输入 http://www.example.com/
    还是输出
    You have reached this web page by typing "example.com", "example.net", or "example.org" into your web browser.
    These domain names are reserved for use in documentation and are not available for registration.

    我创建了一个virtual 目录,在里面创建了www.example.com 目录,在这里里创建了html 目录,在这个里面创建了index.html,网页内容是www.example.com

    因此,httpd.conf文件修改为
    ServerName www.example.com
    DocumentRoot /var/www/virtual/www.example.com/html

    index.html 文件创建命令:

    cat > index.hml << EOF
    www.example.com
    EOF

  2. xiadao_81 于 2010-01-08 13:53:39发表:

    Apache服务器四个功能:
    1.基本网页;
    2.个人主页;
    3.虚拟主机;
    4.网页认证;

    不知你作的是哪个,请对照更改:

    1.基本网页的配置:
    修改主配置文件
    #vi /etc/httpd/conf/httpd.conf
    DocumentRoot "/var/www/html" //该行定义了基本网页所在路径,此路径可自定义
    DirectoryIndex aa index.html index.html.var //该行定义了默认的首页名称,首页名称也可自定义,且根据排列顺序决定首页名称的优先级
    #service httpd restart //启动httpd服务

    2.个人主页(www.sina.com/us1http://192.168.1.111/us1)
    修改主配置文件
    #vi /etc/httpd/conf/httpd.conf
    #UserDir disable //该行控制是否禁用个人主页功能,默认是禁用个人主页,禁用此行,表示启用个人主页功能;
    UserDir public_html //该行定义了个人主页的目录名或文件名,该目录名或文件名必须创建在用户家目录中;默认是禁用,必须启用
    #chmod 755 ~us* //打开用户家目录的访问权限
    #cd ~us1 //在用户us1家目录下创建目录public_html并创建首页文件
    #mkdir public_html
    #vi index.html

    //在用户us2家目录下创建文件public_html文件做为首页
    #cd ~us2
    #vi public_html

    //访问方式:
    http://192.168.1.111/~us1
    http://192.168.1.111/~us2

    //取消波浪号的方法:(在基本网页路径下,创建软链接)
    #cd /var/www/html
    #ln -s /home/us1/public_html us1
    #ln -s /home/us2/public_html us2

    //访问方式:
    http://192.168.1.111/us1

    3.虚拟主机的配置
    虚拟主机是指在同一台服务器,同一个IP,同一个port,可以支持不同域名的不同网页内容的显示;
    使用的方法是为不同域名指向到不同目录的网页内容;如:
    www.sina.com;www.163.net;www.china.cn
    必须先创建多个域名,配置DNS;

    //修改主配置文件,创建虚拟主机功能
    #vi /etc/httpd/conf/httpd.conf
    :$

    //修改如下:
    NameVirtualHost 192.168.1.111


    DocumentRoot /sina
    ServerName www.sina.com



    DocumentRoot /www/163
    ServerName www.163.net



    DocumentRoot /mnt/china
    ServerName www.china.cn


    //保存退出,重启httpd服务
    #service httpd restart


    4.网页认证功能
    //基本网页的认证,修改主配置文件:
    #vi /etc/httpd/conf/httpd.conf

    :301 //此行,表示控制是否开启apache的网页认证功能,修改为:
    AllowOverride AuthConfig

    :335 //此行控制是否开启基本网页的认证功能,修改为:
    AllowOverride AuthConfig

    :414 //此行控制认证窗口的文件名,可自定义文件名;默认是隐含文件.htaccess
    AccessFileName .htaccess

    //保存退出,并到需要做认证的网页路径下创建.htaccess文件,现在要在/var/www/html基本网页路径下创建文件.htaccess
    #cd /var/www/html
    #vi .htaccess

    //网页认证文件的内容如下:
    AuthName "login name" //定义认证窗口的名称
    AuthType Basic //定义认证窗口类型,basic:基本;digest:摘要
    AuthUserFile /home/apa.pwd //定义认证的用户密码文件及路径
    Require valid-user //表示用户密码文件中的所有用户都能验证
    #Require user aa bb //表示用户密码文件中的aa和bb能验证,此行和上一行不能同时定义;

    //生成用户密码文件并打开其访问权限
    #cd /home
    #htpasswd -c apa.pwd aa
    #chmod 644 apa.pwd

    //启动httpd服务并测试
    #service httpd restart

  3. ywhqiuyun 于 2010-01-08 13:26:19发表:

    6# disitian789

    我在里面写了:
    www.example.com

  4. disitian789 于 2010-01-07 21:30:20发表:

    你进入这个网站是正确的,下面是解释:
    你已经达到了这个网页
      example.com打字,或者example.org,example.net进你的浏览器
      这些域名正在保留用于文档和不可供注册
    你没在网叶里写东西吧,你再写点文字看下能不能现实吧,这个 DocumentRoot /example 这样配置的。

  5. ywhqiuyun 于 2010-01-07 16:44:44发表:

    2# sclzwj

    您好!我是新手,请问一下配置 http 需要启动哪些服务?

  6. ywhqiuyun 于 2010-01-07 16:10:57发表:

    我倒!

  7. ywhqiuyun 于 2010-01-07 15:47:43发表:

    named么?启动了啊

  8. sclzwj 于 2010-01-07 14:49:16发表:

    楼主域名服务器启动没有呢?