我在\var\www\html
我的/etc/apache2/sites-available/000-default.conf是:
<VirtualHost *:80>
Servername <redacted>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log
<Directory /var/www/html>
AllowOverride All
</Directory>
<Location /alpha>
AuthType Basic
AuthName "Restricted Access - Authenticate"
AuthUserFile /etc/httpd/htpasswd.users
Require valid-user
</Location>
<Location /UserControl>
AuthType Basic
AuthName "Restricted Access - Authenticate"
AuthUserFile /etc/httpd/htpasswd.users
Require valid-user
</Location>
Redirect /alpha /alpha/
ProxyPass /alpha/ http://127.0.0.1:3838/alpha/
ProxyPassReverse /alpha/ http://127.0.0.1:3838/alpha/
WSGIDaemonProcess UserControl user=ubuntu group=ubuntu threads=5
WSGIScriptAlias / /home/ubuntu/FlaskApps/UserControl/UserControl.wsgi
<Directory /home/ubuntu/FlaskApps/UserControl>
WSGIProcessGroup UserControl
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Order deny,allow
#Allow from all
Require all Granted
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
但是,当我转到http://servername时,我得到的是404错误。找不到该页面。我已经开始了一段时间了,并且不知道为什么。
对于它的价值,http://myservername/alpha和http://myservername/UserControl都有效,因此apache正常工作。
非常感谢任何帮助。
答案 0 :(得分:3)
尝试:
<Directory /var/www/html>
AllowOverride All
Require all granted # required in Apache 2.4
</Directory>
index.html
实际上是否已在某处指定为DirectoryIndex
?将其添加到您的vhost配置中以确保。
如果这些都没有帮助,那就安全起来并开始简单。删除所有与即时问题无关的内容,并使用非常基本的配置。
<VirtualHost *:80>
Servername <redacted>
ServerAdmin webmaster@localhost
DocumentRoot "/var/www/html" # try quoting
DirectoryIndex index.html # just in case
ErrorLog /full/path/to/error.log # fully specified
CustomLog /full/path/to/access.log # fully specified
<Directory "/var/www/html"> # quoted
AllowOverride All
Require all granted # required in Apache 2.4
</Directory>
</VirtualHost>
另外,我注意到你有这个:
Order deny,allow
#Allow from all
Require all Granted
首先,the docs建议不要混合旧格式和新格式的访问控制,因此您可能希望摆脱Order deny,allow
。其次,我认为Granted
应为小写,granted
。
答案 1 :(得分:1)
将您的文件与我的文件进行比较,并忽略您的身份验证位和代理后,您似乎错过了与文档根相关的节...
以下是我的工作配置中的相关部分 - 将/var/www-example.com目录更改为您要用于http://site/根目录的任何内容...
DocumentRoot /var/www-example.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www-example.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>