我已经浏览了所有相关问题,但似乎我尝试的所有方法均无效。如果我访问服务器(根)IP地址,则会出现禁止错误。但是,如果我访问{my_ip_address} / static,那确实可行。
我在/ root / myproject中有一个项目文件夹,在/ var / www / static中有我的静态文件。我想要实现的目的是将django应用程序部署到生产环境中,因此可以通过apache提供静态文件
在/etc/apache2/apache2.conf中,我尝试过:
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /root/myproject/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
在/etc/apache2/sites-available/myproject.conf中,我尝试过:
<VirtualHost *:80>
ServerAdmin admin@myproject.com
ServerName {placeholder for ip address}
DocumentRoot /root/myproject
Alias /static /var/www/static
<Directory /var/www/static>
Require all granted
</Directory>
WSGIDaemonProcess {placeholder for ip address} processes=2 threads=15 display-name=%{GROUP} python-home=/root/myproject/env/lib/python3.5
WSGIProcessGroup {placeholder for ip address}
WSGIScriptAlias / /root/myproject/app/app/wsgi.py
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /root/myproject/app/app>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /root/myproject>
Require all granted
</Directory>
</VirtualHost>
我尝试了以下命令来授予权限:
chgrp -R www-data /root/myproject
chmod -R 2750 /root/myproject
显然,使用以下命令重新加载了Apache:
service apache2 reload
不幸的是,似乎没有任何作用。