AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 32367
In Process
Ashfame
Ashfame
Asked: 2011-03-29 02:52:21 +0800 CST2011-03-29 02:52:21 +0800 CST 2011-03-29 02:52:21 +0800 CST

在本地绑定 example.com

  • 772

我如何绑定 example.com 以由 apache 提供服务,我已经在机器上本地运行以用于开发目的?

我尝试在我的 /etc/hosts 文件中添加它 127.0.0.1 example.com

并重新加载了apache2 sudo /etc/init.d/apache2 reload,但这没有用。

我已经添加了虚拟主机example.com并通过以下方式启用了它a2ensite

编辑:

Apache错误日志(据我所知没有相关)

[Mon Mar 28 15:21:01 2011] [notice] Apache/2.2.16 (Ubuntu) configured -- resuming normal operations
[Mon Mar 28 15:21:03 2011] [notice] Graceful restart requested, doing restart
[Mon Mar 28 15:21:03 2011] [notice] Apache/2.2.16 (Ubuntu) configured -- resuming normal operations
[Mon Mar 28 15:21:23 2011] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico
[Mon Mar 28 15:21:23 2011] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico
[Mon Mar 28 15:35:34 2011] [error] [client 127.0.0.1] File does not exist: /var/www/phpmyadmin
[Mon Mar 28 15:36:48 2011] [notice] caught SIGTERM, shutting down
[Mon Mar 28 15:36:49 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.3 with Suhosin-Patch configured -- resuming normal operations
[Mon Mar 28 15:49:13 2011] [notice] Graceful restart requested, doing restart
[Mon Mar 28 15:49:13 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.3 with Suhosin-Patch configured -- resuming normal operations
[Mon Mar 28 15:49:17 2011] [notice] caught SIGTERM, shutting down
[Mon Mar 28 15:49:18 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.3 with Suhosin-Patch configured -- resuming normal operations
[Mon Mar 28 15:50:24 2011] [notice] Graceful restart requested, doing restart
[Mon Mar 28 15:50:24 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.3 with Suhosin-Patch configured -- resuming normal operations
[Mon Mar 28 16:15:09 2011] [notice] Graceful restart requested, doing restart
Warning: DocumentRoot [/home/ashfame/www/example.com/] does not exist
(2)No such file or directory: apache2: could not open error log file /home/ashfame/www/example.com/error.log.
Unable to open logs
[Mon Mar 28 16:46:18 2011] [warn] pid file /var/run/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Mon Mar 28 16:46:18 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.3 with Suhosin-Patch configured -- resuming normal operations
[Mon Mar 28 16:46:25 2011] [error] [client 127.0.0.1] File does not exist: /var/www/example.com
[Mon Mar 28 16:46:38 2011] [error] [client 127.0.0.1] File does not exist: /var/www/www
[Mon Mar 28 16:55:48 2011] [error] [client 127.0.0.1] File does not exist: /var/www/phpbb/phpbb
[Mon Mar 28 17:17:40 2011] [notice] caught SIGTERM, shutting down
[Mon Mar 28 17:17:41 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.3 with Suhosin-Patch configured -- resuming normal operations
[Mon Mar 28 17:19:29 2011] [error] [client 127.0.0.1] File does not exist: /var/www/example.com

我也尝试这样做,显示主机文件正在工作,但在浏览器中打开http://www.iana.org/domains/example/wget --spider http://example.com

ashfame@ashfame-desktop:/usr/sbin$ wget --spider http://example.com
Spider mode enabled. Check if remote file exists.
--2011-03-28 17:20:57--  http://example.com/
Resolving example.com... 127.0.0.1
Connecting to example.com|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.

虚拟主机配置文件:

# Place any notes or comments you have here
# It will make any customization easier to understand in the weeks to come

<VirtualHost *:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin [email protected]
  ServerName  www.example.com
  ServerAlias example.com


  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html
  DocumentRoot /home/ashfame/www/example.com/


  # Custom log file locations
  LogLevel warn
  ErrorLog  /home/ashfame/www/example.com/error.log
  CustomLog /home/ashfame/www/example.com/access.log combined

</VirtualHost>
configuration
  • 2 2 个回答
  • 845 Views

2 个回答

  • Voted
  1. Emmet Hikory
    2011-07-11T10:34:35+08:002011-07-11T10:34:35+08:00

    如果它与 wget 一起工作,那么您的服务器配置正确且正确。出于某种原因,您的浏览器很可能会优先从其他来源获取名称信息,而不是 /etc/hosts。

    • 首先,检查/etc/nsswitch.conf并确认“文件”列在“主机”下。

    • 其次,检查您的浏览器配置,并确保您没有使用代理,并且浏览器没有单独的方法来解析与系统方法分开的名称(或者如果有,它被配置为/etc/hosts在 DNS 之前使用)。

    • 第三,您可以设置一个不同的 RFC 2606 虚拟主机(例如 mysite.example),它已知在 DNS 中不存在(.example 被明确禁止),这可能会消除一些命名混淆的原因。

    • 1
  2. sagarchalise
    2011-03-29T04:22:09+08:002011-03-29T04:22:09+08:00

    这是我的虚拟主机

    <VirtualHost *:80>
        ServerName sagar.localhost
        ServerAdmin sagar@local
        DocumentRoot /home/sagar/www/
        <Directory /home/sagar/www>
            Options Indexes FollowSymlinks MultiViews
            AllowOverride All //for mod_rewrite
            Order allow,deny
            Allow from all
        </Directory>
       ErrorLog ${APACHE_LOG_DIR}/sagar_error.log
    </VirtualHost>
    

    所以基本上这适用于简单的 php 和 html 脚本,如果您需要 cgi 以及您需要添加到选项 AFAIK。所以你需要做的第一件事是创建 $HOME/www/example.com 目录。我认为<Directory></Directory>规范很重要,而您没有。

    • 0

相关问题

  • 声音,在多个程序之间停止

  • 如何为公共计算机配置 Ubuntu?

  • 如何设置默认启用网络?

  • 如何在键盘上映射未映射的键?[关闭]

  • 保持多个工作站同步

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    我需要什么命令来解压缩/提取 .tar.gz 文件?

    • 8 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Marko Smith

    如何使用命令行将用户添加为新的 sudoer?

    • 7 个回答
  • Marko Smith

    更改文件夹权限和所有权

    • 9 个回答
  • Martin Hope
    EmmyS 我需要什么命令来解压缩/提取 .tar.gz 文件? 2011-02-09 14:50:41 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve