I'm trying to deploy Django-1.10 on Centos-6.8 using default apache in centos(version 2.2).
I'm using python 3.4.5.I'm not able to compile mod-wsgi without python3-devel. Centos-6.8 repos doesn't have python3-devel packages by default.
I need help in compiling mod-wsgi for python-3.4.5 in centos-6.8.
Asked
Active
Viewed 4,379 times
1

sid
- 11
- 1
- 3
1 Answers
1
This answer was shamelessly copied from stackexchange and then modified by replacing python & wsgi versions for newer ones without any testing. It was tested to work on clean CentOS 6.8. So if it doesn't work for you, then you probably doing something wrong...
First, install EPEL...
yum -y -q install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Then Apache...
yum -y -q install httpd mod_ssl httpd-devel
Then for Python (including some very commonly used pre-reqs):
yum -y -q groupinstall development
yum -y -q install zlib2-devel openssl-devel sqlite-devel bzip2-devel python-devel openssl-devel openssl-perl libjpeg-turbo libjpeg-turbo-devel zlib-devel giflib ncurses-devel gdbm-devel xz-devel tkinter readline-devel tk tk-devel kernel-headers glibc libpng gcc-c++ wget
Install Python 3.6.0:
wget 'http://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz'
tar -xzf 'Python-3.6.0.tgz'
cd ./Python-3.6.0
CXX=g++ ./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/lib64 --with-fpectl --enable-shared --enable-ipv6 --with-threads --infodir=${prefix}/share/info --mandir=${prefix}/share/man --with-computed-gotos --with-dbmliborder=gdbm --with-libc= --with-system-expat --with-system-ffi
make
make install
echo "/usr/lib/python3.6" > /etc/ld.so.conf.d/python36.conf
echo "/usr/lib" >> /etc/ld.so.conf.d/python36.conf
Make and compile mod_wsgi (or look into MOD WSGI Express!):
wget "https://github.com/GrahamDumpleton/mod_wsgi/archive/4.5.14.tar.gz"
tar -xzf '4.5.14.tar.gz'
cd ./mod_wsgi-4.5.14
./configure --with-python=/usr/bin/python3.6
make
make install

Andrew Schulman
- 8,811
- 21
- 32
- 47

Anubioz
- 3,677
- 18
- 23
-
entering the ./configure --with... , I get the python.h not found error. I have installed all the dev-packages, stuck here – hewi Jan 25 '17 at 22:52
-
You should try https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz nowadays – Anubioz Jan 26 '17 at 21:05
-
I would like to ask the question: apache2 - python3.6 - mod_wsgi, do you have a clear tutorial on how to achieve running the wsgi with only python 3.x? I am really lost in all the info and possible solutions that don't work – hewi Jan 27 '17 at 08:26
-
@hewi. Can you tell (confirm) me your OS version (CentOS 6.8) and mod_wsgi version your need. Does Apache 2.2 - Python 3.6 - mod_wsgi 4.5.14 work for you? – Anubioz Jan 27 '17 at 10:03
-
@hewi I've tested my solution to work with clean CentOS 6.8 distro. – Anubioz Jan 27 '17 at 11:05
-
I am on Kubuntu – hewi Jan 27 '17 at 11:21
-
@hewi Kubuntu can't be considered business environment, but i'm sure if you replace yum with apt, those commands will do just what they do on CentOS – Anubioz Jan 27 '17 at 15:38
-
I almost got it working, I am just struggling to point the sys.path to the python35 folder – hewi Jan 30 '17 at 15:41
-
@hewi So I guess you had compiled it successfully after all. If you'd like a help with your sys.path problems please open a separate question. [This guide may also help](http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/) – Anubioz Jan 30 '17 at 15:47
-
no, I used sudo pat-get install apache2-mod-wsgi-py3; this should not be the reason why the actual wsgi script cannot find python3.5, it must have to do with sys.path – hewi Jan 30 '17 at 16:47
-
@hewi this is completely unrelated to the topic. I don't know thy you want to post that here.... – Anubioz Jan 31 '17 at 10:45