我正在尝试使用Apache 2.4.18配置我的django应用程序。
我在Ubunu 16.04上使用Django 3.0.5和Python 3.8.2。
在runserver模式下一切工作正常。
Forbidden
You don't have permission to access this resource.这是我的apache配置文件
Listen 80
<VirtualHost *:80>
ServerAdmin xxx@xxx.com
ServerName servername.net
DocumentRoot /srv
Alias /static /srv/tacdb/mysite/static
<Directory "srv/tacdb/mysite/static">
Require all granted
</Directory>
Alias /media /srv/tacdb/mysite/media
<Directory "srv/tacdb/mysite/media">
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/portal_error.log
CustomLog ${APACHE_LOG_DIR}/portal_access.log combined
WSGIDaemonProcess mysite python-home=/srv/tacdb/virtualenvironment/project_1 python-path=/srv/tacdb
WSGIProcessGroup mysite
WSGIScriptAlias / /srv/tacdb/mysite/wsgi.py
<Directory /srv/tacdb/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>configtest正常,服务器状态正常。
root@test-tools:~/srv# systemctl status apache2.service
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Thu 2020-04-02 15:18:20 UTC; 5min ago
Docs: man:systemd-sysv-generator(8)
Process: 26327 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 25036 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
Process: 26356 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/apache2.service
├─26372 /usr/sbin/apache2 -k start
├─26375 /usr/sbin/apache2 -k start
├─26376 /usr/sbin/apache2 -k start
└─26377 /usr/sbin/apache2 -k start
Apr 02 15:18:19 test-tools systemd[1]: Stopped LSB: Apache2 web server.
Apr 02 15:18:19 test-tools systemd[1]: Starting LSB: Apache2 web server...
Apr 02 15:18:19 test-tools apache2[26356]: * Starting Apache httpd web server apache2
Apr 02 15:18:20 test-tools apache2[26356]: *
Apr 02 15:18:20 test-tools systemd[1]: Started LSB: Apache2 web server.我曾尝试更改apache用户"www-data“的目录权限,但没有成功。
根据我的研究,我认为文件夹级权限是根据Apache版本设置的。
有什么想法吗?
非常感谢!如果需要其他信息,一定要让我知道。
发布于 2020-04-03 14:05:24
在我的例子中,它就像授予权限一样简单。我从另一个位置使用了/srv/。我不确定这是不是gand文件夹访问的最佳解决方案。
sudo chmod -R 777 /srv我想我现在好多了,因为它读取了我的配置文件(我遇到了另一个错误)。
https://stackoverflow.com/questions/60995169
复制相似问题