Last active
May 7, 2016 09:55
-
-
Save ajinkya-bhosale/dd96ecfa62dacc7ca3c4dde464a75cbc to your computer and use it in GitHub Desktop.
Deploying Django 1.8/1.9 ( Python 3.4 ) with Apache and mod_wsgi on Fedora 23 / CentOS / RedHat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
make default python version to python3.4 | |
We have given python3.4 a higher priority 2 which means, | |
if no python alternative is selected the python3.4 will be used as default. | |
#alternatives --install /usr/bin/python python /usr/bin/python3.4 2 | |
#alternatives --install /usr/bin/python python /usr/bin/python2.7 1 | |
$sudo pip3.4 install django | |
$sudo dnf install python3-mod_wsgi | |
$cd /var/www | |
$sudo chown -R user /var/www | |
$django-admin startproject myproject | |
$python manage.py makemigrations | |
$python manage.py migrate | |
$sudo gedit /etc/httpd/conf/httpd.conf | |
Add following content to httpd.conf | |
################################################################ | |
WSGIScriptAlias / /var/www/myproject/myproject/wsgi.py | |
#Using mod_wsgi daemon mode | |
WSGIDaemonProcess myproject python-path=/var/www/myproject:/usr/lib/python3.4/site-packages | |
WSGIProcessGroup myproject | |
Alias /static /var/www/myproject/static | |
<Directory /var/www/myproject/static> | |
Require all granted | |
</Directory> | |
<Directory /var/www/myproject/myproject> | |
<Files wsgi.py> | |
Require all granted | |
</Files> | |
</Directory> | |
<Directory /var/www/myproject> | |
Order deny,allow | |
Allow from all | |
</Directory> | |
############################################################## | |
$sudo service httpd restart | |
References - | |
https://linuxconfig.org/how-to-switch-between-python-versions-on-fedora-linux | |
https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-centos-7 | |
https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment