I do like working with RedHat / Centos 6 (python 2.6.6) but when it comes to Python, urghh…They just remain old old, its sad. I dont know why. Solution is to use virtualenv and install a second python version.
At least ‘Amazon Linux AMI’ it is based on RedHat but keeps a bit more recent version 2.7.12
And RedHat/Centos 7 has python3 on repository. Anyways I can understand now why python developers like OSx or Debian based, they just integrate much better with Python.
Lets get to it, to Install python 3.5 and Django try running:
INSTALL PYTHON 3.5
wget “http://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz” ./configure –enable-loadable-sqlite-extensions –prefix=/usr/local –enable-shared LDFLAGS=”-Wl,-rpath /usr/local/lib” make && make altinstall

VIRTUAL ENV
virtualenv /var/www/py3.5 –python=/usr/local/bin/python3.5 source py3.5/bin/activate python –version pip install django django-admin –version django-admin.py startproject MyProject . cd /var/www/py3.5/MyProject (py3.5) [root@server MyProject]# tree
├── __init__.py
├── settings.py
├── urls.py
├── views.py
└── wsgi.py

WSGI

(must be compiled with the right version of python)
yum remove mod_wsgi.x86_64
wget https://pypi.python.org/packages/84/65/44a10ac5e117abc40078575a3dcf3256545ba20495b7330ba59045ec3503/mod_wsgi-4.5.9.tar.gz
tar -zxvf mod_wsgi-4.5.9.tar.gz
cd mod_wsgi-4.5.9
./configure –with-python=/var/www/py3.5/bin/python
make
make install

APACHE

touch /var/run/wsgi && chown apache.apache /var/run/wsgi
echo “WSGISocketPrefix /var/run/wsgi” >> /etc/httpd/conf/httpd.conf
echo “LoadModule wsgi_module modules/mod_wsgi.so” >> /etc/httpd/conf/httpd.conf
vi /etc/httpd/conf.d/project.conf

DocumentRoot "/var/www/py3.5/MyProject"
ServerName MyProject.loc
CustomLog "/var/log/httpd/MyProject_access.log" combined
WSGIDaemonProcess MyProject python-path=/var/www/py3.5/MyProject:/var/www/py3.5:/var/www/py3.5/lib/python3.5/site-packages/
WSGIProcessGroup MyProject
WSGIScriptAlias / /var/www/py3.5/MyProject/wsgi.py

Order allow,deny
Allow from all


service httpd restart

Tags: , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *