I am deploying two Django projects with Apache and mod_wsgi according to How to use Django with Apache and mod_wsgi | Django documentation | Django.
I added two configure files in /etc/conf.d/.
For project1.conf
<VirtualHost *:9000>
ServerName www.example.com
WSGIDaemonProcess project1 python-path=/home/project1:/home/venv/lib/python3.6/site-packages
WSGIScriptAlias /project1 "/home/project1/project1/wsgi.py" process-group=project1
<Directory "/home/project1/project1">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ /home/project1/static/
<Directory "/home/project1/static">
Require all granted
</Directory>
Alias /static/admin /home/venv/lib/python3.6/site-packages/django/contrib/admin/static/
<Directory "home/venv/lib/python3.6/site-packages/django/contrib/admin/static/">
Require all granted
</Directory>
</VirtualHost>
For project2.conf
<VirtualHost *:6001>
ServerName www.example.com
WSGIDaemonProcess project2 python-home=/home/project2_env python-path=/home/project2
WSGIProcessGroup project2
WSGIScriptAlias /project2 /home/project2/project2/wsgi.py process-group=project2
<Directory "/home/project2/project2">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ /home/project2/static/
<Directory "/home/project2/static">
Require all granted
</Directory>
#Alias /static/admin /home/venv/lib/python3.6/site-packages/django/contrib/admin/static/
#<Directory "home/venv/lib/python3.6/site-packages/django/contrib/admin/static/">
#Require all granted
#</Directory>
</VirtualHost>
And add two ports in /etc/httpd/conf/httpd.conf
Listen 9000
Listen 6001
Then the project1 works fine but when I try to access www.example.com/project2, it shows “Forbidden.You don’t have permission to access /project2/ on this server.”
The /etc/httpd/logs/error_log file reported that [autoindex:error] [pid 24020] [client 127.0.0.1:43644] AH01276: Cannot serve directory /home/project2/
: No matching DirectoryIndex (index.php,index.html,index.php) found, and server-generated directory index forbidden by Options directive.
When I put a index.html in the directory of project2, it didn’t show this error. I guess there may be some errors when delploying django with wsgi, but I cann’t figure it. Did I miss some important step?
Any hint would be helpful! Thanks.