apache 403/404错误页面

uwopmtnx  于 2023-06-24  发布在  Apache
关注(0)|答案(2)|浏览(168)

我在Ubuntu 18.10中运行Apache Server 2.4.34。我不明白为什么我不能从我的服务器目录(/var/www/http/)的根目录中的icons/目录访问资源。文件给予404,目录显示403禁止
此服务器是新设置的,所有文件/目录都归www-data所有。我有其他的目录(例如。images/),它们具有相同的权限(目录上的771,文件上的644),我可以访问其中的索引和所有文件。
我已经搜索了一吨左右,我可以找到一堆的东西,不能得到子文件夹,但没有关于一个特定的文件夹与其他人相同的设置。如果有什么不同的话,这个文件夹应该有更宽松的权限,因为我已经在我的apache2.conf文件中添加了关于它的特定部分。
下面是我的apache2.conf和default.conf文件,在顶部减去一些注解apache2.conf

  1. DefaultRuntimeDir ${APACHE_RUN_DIR}
  2. #
  3. # PidFile: The file in which the server should record its process
  4. # identification number when it starts.
  5. # This needs to be set in /etc/apache2/envvars
  6. #
  7. PidFile ${APACHE_PID_FILE}
  8. #
  9. # Timeout: The number of seconds before receives and sends time out.
  10. #
  11. Timeout 300
  12. #
  13. # KeepAlive: Whether or not to allow persistent connections (more than
  14. # one request per connection). Set to "Off" to deactivate.
  15. #
  16. KeepAlive On
  17. #
  18. # MaxKeepAliveRequests: The maximum number of requests to allow
  19. # during a persistent connection. Set to 0 to allow an unlimited amount.
  20. # We recommend you leave this number high, for maximum performance.
  21. #
  22. MaxKeepAliveRequests 100
  23. #
  24. # KeepAliveTimeout: Number of seconds to wait for the next request from the
  25. # same client on the same connection.
  26. #
  27. KeepAliveTimeout 5
  28. # These need to be set in /etc/apache2/envvars
  29. User ${APACHE_RUN_USER}
  30. Group ${APACHE_RUN_GROUP}
  31. #
  32. # HostnameLookups: Log the names of clients or just their IP addresses
  33. # e.g., www.apache.org (on) or 204.62.129.132 (off).
  34. # The default is off because it'd be overall better for the net if people
  35. # had to knowingly turn this feature on, since enabling it means that
  36. # each client request will result in AT LEAST one lookup request to the
  37. # nameserver.
  38. #
  39. HostnameLookups Off
  40. # ErrorLog: The location of the error log file.
  41. # If you do not specify an ErrorLog directive within a <VirtualHost>
  42. # container, error messages relating to that virtual host will be
  43. # logged here. If you *do* define an error logfile for a <VirtualHost>
  44. # container, that host's errors will be logged there and not here.
  45. #
  46. ErrorLog ${APACHE_LOG_DIR}/error.log
  47. #
  48. # LogLevel: Control the severity of messages logged to the error_log.
  49. # Available values: trace8, ..., trace1, debug, info, notice, warn,
  50. # error, crit, alert, emerg.
  51. # It is also possible to configure the log level for particular modules, e.g.
  52. # "LogLevel info ssl:warn"
  53. #
  54. LogLevel warn
  55. # Include module configuration:
  56. IncludeOptional mods-enabled/*.load
  57. IncludeOptional mods-enabled/*.conf
  58. # Include list of ports to listen on
  59. Include ports.conf
  60. # Sets the default security model of the Apache2 HTTPD server. It does
  61. # not allow access to the root filesystem outside of /usr/share and /var/www.
  62. # The former is used by web applications packaged in Debian,
  63. # the latter may be used for local directories served by the web server. If
  64. # your system is serving content from a sub-directory in /srv you must allow
  65. # access here, or in any related virtual host.
  66. <Directory />
  67. Options FollowSymLinks
  68. AllowOverride None
  69. Require all denied
  70. </Directory>
  71. <Directory /usr/share>
  72. AllowOverride None
  73. Require all granted
  74. </Directory>
  75. <Directory /var/www>
  76. Options Indexes FollowSymLinks
  77. AllowOverride all
  78. Require all granted
  79. </Directory>
  80. # Testing to see if adding this manually works
  81. <Directory /var/www/html/icons>
  82. options Indexes FollowSymLinks
  83. AllowOverride all
  84. require all granted
  85. </Directory>
  86. #<Directory /srv/>
  87. # Options Indexes FollowSymLinks
  88. # AllowOverride None
  89. # Require all granted
  90. #</Directory>
  91. # AccessFileName: The name of the file to look for in each directory
  92. # for additional configuration directives. See also the AllowOverride
  93. # directive.
  94. #
  95. AccessFileName .htaccess
  96. #
  97. # The following lines prevent .htaccess and .htpasswd files from being
  98. # viewed by Web clients.
  99. #
  100. <FilesMatch "^\.ht">
  101. Require all denied
  102. </FilesMatch>
  103. #
  104. # The following directives define some format nicknames for use with
  105. # a CustomLog directive.
  106. #
  107. # These deviate from the Common Log Format definitions in that they use %O
  108. # (the actual bytes sent including headers) instead of %b (the size of the
  109. # requested file), because the latter makes it impossible to detect partial
  110. # requests.
  111. #
  112. # Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
  113. # Use mod_remoteip instead.
  114. #
  115. LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
  116. LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
  117. LogFormat "%h %l %u %t \"%r\" %>s %O" common
  118. LogFormat "%{Referer}i -> %U" referer
  119. LogFormat "%{User-agent}i" agent
  120. # Include of directories ignores editors' and dpkg's backup files,
  121. # see README.Debian for details.
  122. # Include generic snippets of statements
  123. IncludeOptional conf-enabled/*.conf
  124. # Include the virtual host configurations:
  125. IncludeOptional sites-enabled/*.conf

default.conf

  1. ServerAdmin webmaster@localhost
  2. DocumentRoot /var/www/html
  3. # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
  4. # error, crit, alert, emerg.
  5. # It is also possible to configure the loglevel for particular
  6. # modules, e.g.
  7. #LogLevel info ssl:warn
  8. ErrorLog ${APACHE_LOG_DIR}/error.log
  9. CustomLog ${APACHE_LOG_DIR}/access.log combined
  10. # For most configuration files from conf-available/, which are
  11. # enabled or disabled at a global level, it is possible to
  12. # include a line for only one particular virtual host. For example the
  13. # following line enables the CGI configuration for this host only
  14. # after it has been globally disabled with "a2disconf".
  15. #Include conf-available/serve-cgi-bin.conf
  16. </VirtualHost>
  17. <Directory /var/www/html>
  18. Options Indexes FollowSymLinks MultiViews
  19. AllowOverride All
  20. allow from all
  21. </Directory>
  22. <IfModule mod_negotiation.c>
  23. Options -MultiViews
  24. </IfModule>

感谢你的指导。

8dtrkrch

8dtrkrch1#

我找到答案了!我不知道icons/目录有什么不同,所以我在/etc/apache 2目录中的所有文件中搜索icons,你知道吗,一堆我不认识的文件出现了。我在谷歌上搜索了“Apache图标目录”,发现了this article,它描述了图标目录如何别名为/usr/share/apache2/icons/,并且不能被覆盖。
我最终将所需的文件移动到该目录,因为我没有构建我正在使用的站点,并且不想更改所有图标路径。

a8jjtwal

a8jjtwal2#

我在开发一个项目时也遇到了同样的问题。当我在任何img标签中设置这些图标时,我无法从/icons访问这些图标。
但是在通过注解解决了这个问题之后,将#放在这个文件/etc/apache2/mods-available/alias.conf中的Alias /icons/ "/usr/share/apache2/icons/"之前,我不得不重新启动Apache服务器。我用的是Ubuntu。我用下面的命令重新启动了Apache。

  1. sudo service apache2 restart

在此之后,图标显示在/icons文件夹的img标记中。

相关问题