jeudi 13 mai 2021

Why Django app doesn't work on production server?

I'm trying to get django up and running on my production server but it's not working. Btw, the OS is ubuntu.

I will describe everything that i did step by step, so no details are lost.

So, I installed mod_wsgi:

apt-get install libapache2-mod-wsgi-py3

Installed venv:

apt-get install python3-venv

Created venv in my django directory:

sudo python3 -m venv venv

Installed Django:

pip install Django

Then i created copy of 000-default.conf named dj.conf and populated it with the following code:

<VirtualHost *:80>

    WSGIScriptAlias / /home/path/mysite/mysite/wsgi.py
    WSGIPythonHome /home/path/mysite/venv
    WSGIPythonPath /home/path/mysite

    <Directory /home/path/mysite>
    <Files wsgi.py>
    Require all granted
    </Files>
    </Directory>

</VirtualHost>

Then I enabled new config and disabled old and restared server:

sudo a2ensite dj
sudo a2dissite 000-default.conf
systemctl reload apache2
sudo service apache2 restart

Then I typed ip of my server in browser address bar and I saw the default page! The same that i saw when just bought a VPS, it says "Your new web server is ready to use.". This is not even a default apache page. So, nothing has changed and all my settings have no effect for some reason!

I also typed netstat -tulpen |grep 80 in console and it gave me this:

tcp   0   0 VPS_IP:8080          0.0.0.0:*         LISTEN      0       164979     88786/apache2
tcp   0   0 VPS_IP:80            0.0.0.0:*         LISTEN      0       22066      773/nginx: master p
tcp   0   0 127.0.0.1:8081       0.0.0.0:*         LISTEN      0       164975     88786/apache2
tcp   0   0 127.0.0.1:8084       0.0.0.0:*         LISTEN      0       22068      773/nginx: master p

I hope it says something useful and that it can help solve the issue.

Please help! I really appreciate any help!

Aucun commentaire:

Enregistrer un commentaire