Issues with serving 2 django applications with apache in ubuntu server using wsgi
i'm trying to host a second domain in my ubuntu vps (domain2), i read online that is possible to host 2 domains in one vps (with one ip adress) yet i'm having some issues with it.
i have this configuration in apache2 ubuntu under /etc/apache2/sites-enabled/000-default-le-ssl.conf:
Define wsgi_daemon1 "domain1"
Define wsgi_daemon2 "domain2"
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/my_linux_user/myproject/static
<Directory /home/my_linux_user/myproject/static>
Require all granted
</Directory>
<Directory /home/my_linux_user/myproject/myproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<IfDefine !wsgi_init>
WSGIDaemonProcess ${wsgi_daemon1} python-path=/home/my_linux_user/myproject python-home=/home/my_linux_user/myproject/myprojectenv
WSGIProcessGroup ${wsgi_daemon1}
WSGIScriptAlias / /home/my_linux_user/myproject/myproject/wsgi.py
Define wsgi_init 1
</IfDefine>
ServerName domain1.tn
SSLCertificateFile /etc/letsencrypt/live/domain1.tn/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain1.tn/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error_project2.log
CustomLog ${APACHE_LOG_DIR}/access_project2.log combined
Alias /static /home/my_linux_user/project2/static
<Directory /home/my_linux_user/project2/static>
Require all granted
</Directory>
<Directory /home/my_linux_user/project2/django_project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<IfDefine !wsgi_init>
WSGIDaemonProcess ${wsgi_daemon2} python-path=/home/my_linux_user/project2 python-home=/home/my_linux_user/project2/project2ENV
WSGIProcessGroup ${wsgi_daemon2}
WSGIScriptAlias / /home/my_linux_user/project2/django_project/wsgi.py
Define wsgi_init 1
</IfDefine>
ServerName domain2
SSLCertificateFile /etc/letsencrypt/live/domain2/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain2/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
the first domain is served correctly but the second domain (domain2) is not, it actually still pointing to the default apache2 index page
i tried
- restarting apache2 with:
apachectl restart
and with
apachectl graceful
checking the DNS configuration, the domaain in up and working
when i tried to just point the domain with a seperate vhost and a simple web page it works!, yet with wsgi it doesn't
i tried to see what are the enabled sites with
apache2ctl -S
and i something like this:
*:443 is a NameVirtualHost
default server domain1.tn (/etc/apache2/sites-enabled/000-default-le-ssl.conf:5)
port 443 namevhost domain1.tn (/etc/apache2/sites-enabled/000-default-le-ssl.conf:5)
port 443 namevhost domain2.com (/etc/apache2/sites-enabled/000-default-le-ssl.conf:106)
port 443 namevhost mail.domain1.tn
(/etc/apache2/sites-enabled/mail.domain1.tn.conf:3)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: MODSEC_2.5
Define: MODSEC_2.9
Define: wsgi_daemon1=domain1
Define: wsgi_daemon2=domain2
Define: wsgi_init=1
User: name="www-data" id=33
Group: name="www-data" id=33
so my question does it take some time for changes to take effect (it was not the case when i hosted the first domain (domain1)), if not i will appreciate any help :)
ps: i'm replacing the actual domain names