Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install Python 3.4.2 + mod_wsgi on CentOS
docker build --tag="jmorton/apache-python3-wsgi"
docker run -it jmorton/python /bin/bash
FROM centos:centos6
# Apache
RUN yum install -y httpd httpd-devel
RUN chkconfig httpd on
RUN apachectl start
# Dependencies
RUN yum groupinstall -y "Development tools"
RUN yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline
RUN yum install -y tar
# Python 3.4.2
WORKDIR /usr/local/src
RUN curl -O
RUN tar -xvzf Python-3.4.2.tgz
WORKDIR /usr/local/src/Python-3.4.2
RUN ./configure --enable-shared --prefix=/usr/local LDFLAGS="-Wl,-rpath /usr/local/lib"
RUN make
RUN make altinstall
RUN apachectl restart
# mod_wsgi python package
RUN pip3.4 install mod_wsgi
RUN mod_wsgi-express install-module
RUN pyvenv-3.4 /var/www/venv
RUN mkdir -p /var/www/apps
ADD wsgi.conf /etc/httpd/conf.d/
ADD apps /var/www/apps
# Deployment
RUN yum -y install openssh-server openssh-clients
RUN chkconfig sshd on
RUN service sshd start
RUN useradd deploy
RUN chown -R deploy:deploy /var/www/
RUN find /var/www/apps -type f -exec chmod 640 {} \;
RUN find /var/www/apps -type d -exec chmod 750 {} \;
EXPOSE 22 80 443
LoadModule wsgi_module /etc/httpd/modules/
WSGIPythonHome /var/www/venv
WSGIDaemonProcess flask user=deploy group=deploy
WSGIProcessGroup flask
WSGISocketPrefix /var/run/wsgi
Alias /apps /var/www/apps/
<Directory /var/www/apps/>
Options ExecCGI MultiViews Indexes
MultiViewsMatch Handlers
AddHandler wsgi-script .py
AddHandler wsgi-script .wsgi
DirectoryIndex index.html index.php app.wsgi
Order allow,deny
Allow from all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.