Publish Django in Apache [closed]

1

Someone could perhaps explain to me how I can put into production a Django project with Apache, I'm a little lost. Official Documentation Production I have read Django's documentation but the truth is not clear about this, I would appreciate any suggestions or help .. !!

    
asked by Diego Avila 12.11.2018 в 20:47
source

1 answer

1

You must install the wsgi module in apache2

sudo apt-get install libapache2-mod-wsgi

Once installed, you must modify your virtualhost and add the following lines:

WSGIDaemonProcess : serves to indicate where your venv is

WSGIProcessGroup : specify what the process is

WSGIScriptAlias : is the equivalent of Alias

Assuming your project is called api and you installed it with the ubuntu user, your virtualhost should look like this:

<VirtualHost *:80>
     ServerAdmin [email protected]
     ServerName ejemplo.com
     ServerAlias www.ejemplo.com

     WSGIDaemonProcess api python-home=/home/ubuntu/api/venv/ python-path=/home/ubuntu/api
     WSGIProcessGroup api
     WSGIPassAuthorization On
     WSGIScriptAlias / /home/ubuntu/api/wsgi.py
     <Directory /home/ubuntu/api>
        <Files wsgi.py>
           Require all granted
        </Files>
     </Directory>
     ErrorLog ${APACHE_LOG_DIR}/error_python.log
     CustomLog ${APACHE_LOG_DIR}/access_python.log combined
</VirtualHost>

The following code is to give permissions to the file

   <Files wsgi.py>
       Require all granted
    </Files>

Finally you must restart apache2 (I'm assuming that the virtualhost was)

    
answered by 13.11.2018 / 12:38
source