我正在尝试在 Fedora 18 安装上设置虚拟主机。这是在 Rackspace 上。
Following is my /etc/httpd/conf/httpd.conf (I deleted all the comment lines for brevity):
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
MIMEMagicFile conf/magic
EnableSendfile on
Include conf.d/*.conf
这是我的 /etc/httpd/conf.d/00-rails.conf
<VirtualHost *:80>
ServerName test.myinstall.com
DocumentRoot /home/test/public
<Directory /home/test/public>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride all
Order deny,allow
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
在我的 /home/test/public 中我添加了一个 index.html 文件,其中包含以下内容:
<h3>This is a test page</h3>
问题是,当我访问 test.myinstall.com 时,我看到的是 Fedora 测试页面,而不是 index.html 中的消息
当我执行 apachectl -S 时,我得到的结果如下:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server test.myinstall.com (/etc/httpd/conf.d/00-rails.conf:1)
port 80 namevhost test.myinstall.com (/etc/httpd/conf.d/00-rails.conf:1)
port 80 namevhost test.myinstall.com (/etc/httpd/conf.d/00-rails.conf:1)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex authn-socache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
附加信息:
这是我的 /etc/hosts 文件:
#this is the IPv6 address
#I used xxx to mask the real address
2001:xxxx:xxxx:xxxx:xxxx:d0a5:ff04:ab82 test.myinstall.com
#this is the externally accessible IP address
64.49.xxx.xx test.myinstall.com
#this is the internal Rackspace IP address
10.xxx.xx.xx test.myinstall.com
有任何想法吗?
Apache 错误日志:
[Tue Apr 23 23:28:25.617954 2013] [suexec:notice] [pid 25527] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[ 2013-04-23 23:28:26.0266 25531/7f638fcdd740 agents/HelperAgent/Main.cpp:554 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.25527/generation-0/request.socket
[ 2013-04-23 23:28:26.0432 25536/7f4251e71800 agents/LoggingAgent/Main.cpp:272 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.25527/generation-0/logging.socket
[Tue Apr 23 23:28:26.084527 2013] [auth_digest:notice] [pid 25527] AH01757: generating secret for digest authentication ...
[ 2013-04-23 23:28:27.0253 25550/7f5362aa7740 agents/HelperAgent/Main.cpp:554 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.25527/generation-1/request.socket
[Tue Apr 23 23:28:27.041518 2013] [lbmethod_heartbeat:notice] [pid 25527] AH02282: No slotmem from mod_heartmonitor
[ 2013-04-23 23:28:27.0498 25555/7f21c5883800 agents/LoggingAgent/Main.cpp:272 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.25527/generation-1/logging.socket
[Tue Apr 23 23:28:27.064938 2013] [mpm_prefork:notice] [pid 25527] AH00163: Apache/2.4.4 (Fedora) Phusion_Passenger/4.0.0.rc6 configured -- resuming normal operations
[Tue Apr 23 23:28:27.065043 2013] [core:notice] [pid 25527] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Tue Apr 23 23:28:33.851049 2013] [authz_core:error] [pid 25565] [client 66.xxx.141.202:2300] AH01630: client denied by server configuration: /home/test/public/
[Tue Apr 23 23:28:35.637170 2013] [authz_core:error] [pid 25565] [client 66.xxx.141.202:2300] AH01630: client denied by server configuration: /home/test/public/
[Tue Apr 23 23:50:49.520907 2013] [authz_core:error] [pid 25567] [client 66.xxx.141.202:56561] AH01630: client denied by server configuration: /home/test/public/
[Tue Apr 23 23:50:49.744630 2013] [authz_core:error] [pid 25567] [client 66.xxx.141.202:56561] AH01630: client denied by server configuration: /home/test/public/favicon.ico
/home/test 的权限:
drwxr-xr-x. 2 test apache 4096 Apr 10 05:17 app
drwxr-xr-x. 2 test apache 4096 Apr 10 20:11 public
答案1
您的错误日志中显示的问题是您没有读取/home/test/public
目录的权限。
[Tue Apr 23 23:28:33.851049 2013] [authz_core:error] [pid 25565] [client 66.xxx.141.202:2300] AH01630: client denied by server configuration: /home/test/public/
原因是您拒绝访问它:
<Directory />
AllowOverride none
Require all denied
</Directory>
虽然您有一个单独的条目,但<Directory /home/test/public>
它不允许访问。它似乎具有旧的 Apache 2.2 样式Order
和指令。这些在 Apache 2.4 中无效,并且已被指令替换。Allow
Deny
Require
要解决此问题,请允许访问目录。删除旧指令并将其替换为新指令:
<Directory /home/test/public>
Require all granted
</Directory>