我安装了 Fedora 24,并尝试为虚拟主机设置 Apache。
尝试通过浏览器访问时,我收到“404 未找到”消息。
下面是我的配置文件和错误输出httpd -S
(此时文件可能太多)。
SElinux 已被禁用。
httpd -S
输出:
AH00112: Warning: DocumentRoot [/home/www/apecenergy.co.uk/public_html] does not exist
AH00112: Warning: DocumentRoot [/home/www/rangayoga.co.uk/public_html] does not exist
VirtualHost configuration:
*:80 is a NameVirtualHost
default server www.apecenergy.co.uk (/etc/httpd/conf.d/httpd-vhosts.conf:23)
port 80 namevhost www.apecenergy.co.uk (/etc/httpd/conf.d/httpd-vhosts.conf:23)
alias www.apecenergy.co.uk
port 80 namevhost rangayoga.co.uk (/etc/httpd/conf.d/httpd-vhosts.conf:32)
alias www.rangayoga.co.uk
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/home/david/www"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex cache-socache: using_defaults
Mutex authdigest-opaque: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
!!!!(((如果文档根目录应该由“apache”而不是“david”拥有,现在刚刚从最后两行中注意到这一点)))!!!!
等/主机文件:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 rangayoga.co.uk www.rangayoga.co.uk
127.0.0.1 apecenergy.co.uk www.apecenergy.co.uk
等/httpd/conf.d/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin admin@apecenergy
DocumentRoot /home/www/apecenergy.co.uk/public_html
ServerName www.apecenergy.co.uk
ServerAlias www.apecenergy.co.uk
ErrorLog "/var/log/httpd/apecenergy-error_log"
CustomLog "/var/log/httpd/apecenergy-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/home/www/rangayoga.co.uk/public_html"
ServerName rangayoga.co.uk
ServerAlias www.rangayoga.co.uk
ErrorLog "/var/log/httpd/rangayoga.co.uk-error_log"
CustomLog "/var/log/httpd/rangayoga.co.uk-access_log" common
</VirtualHost>
ServerName 127.0.0.1
等/httpd/conf/httpd.conf (选定的数据,如果您需要完整的文件,请询问)
ServerRoot "/etc/httpd"
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache
# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. [email protected]
#
ServerAdmin root@localhost
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all granted
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/home/david/www"
#
# Relax access to content within /var/www.
#
<Directory "/home/david/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/home/david/www">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
Require all denied
</Files>
答案1
的前两行httpd -S output
非常明确地表明您没有为 (/home/www/apecenergy.co.uk/public_html
和/home/www/rangayoga.co.uk/public_html
) 创建正确的目录结构。
仅此一项就足以导致 HTTP 404 错误。