Apache不识别除root之外的目录

时间:2015-01-16 22:10:40

标签: apache ubuntu laravel

当尝试加载除www.example.com以外的任何内容时(例如,www.example.com / something),我收到来自apache的错误,表明未找到所请求的网址/内容服务器'

关于问题的任何想法? 我在Digital Ocean上运行了一个laravel应用程序 - LAMP / Ubuntu。

我的apache2.conf文件(删除了评论):

Mutex file:${APACHE_LOCK_DIR} default

PidFile ${APACHE_PID_FILE}

Timeout 300


KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 5


User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

Include ports.conf


<Directory />
    Options FollowSymLinks
    AllowOverride All
    Require all denied
    RewriteEngine On
    RewriteBase /var/www/html/scheduleify/app/public
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

#<Directory /srv/>
#   Options Indexes FollowSymLinks
#   AllowOverride None
#   Require all granted
#</Directory>


AccessFileName .htaccess

<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>


LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent



IncludeOptional conf-enabled/*.conf

IncludeOptional sites-enabled/*.conf


Include /etc/phpmyadmin/apache.conf

编辑:也是启用网站的配置文件:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/scheduleify/public

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

1 个答案:

答案 0 :(得分:2)

Apache是​​一个Web服务器 - 它的主要工作是将文件提供给Web。如果它告诉你

没有文件
http://example.com/foo/baz/bar
那时那里没有文件。它正在按原样运作

Laravel是一个运行文件index.php的PHP应用程序。如果

http://example.com/
http://example.com/index.php

通过Laravel正确渲染,这意味着Laravel正在工作。

为了制作像

这样的网址
http://example.com/foo/baz/bar

通过Laravel呈现,Laravel在.htaccess文件夹中包含public文件,该文件将大多数(如果不是全部)所有网址重定向到index.php。这是.htaccess文件负责转动

http://example.com/foo/baz/bar

http://example.com/index.php/foo/baz/bar

在工作系统中,这发生在幕后。即,从用户浏览其浏览器的角度来看,该URL仍为http://example.com/foo/baz/bar

如果第二种形式的网址在您的服务器上呈现,则几乎可以肯定是.htaccess问题。在您正在配置webroot的<Directory节点中,您需要类似这样的

AllowOverride All

这告诉Apache“嘿,让用户使用.htaccess文件重新配置您可以从.htaccess文件配置的所有内容。您可以找到更多信息about AllowOverride on the apache docs site