Python/Django app on CentOS 7 Apache server using mod_wsgi

Python/Django apps can be hosted on Linux Apache web server using the mod_wsgi module. However, the mod_wsgi module has to be compiled with  same version as the one in the virtual environment.

OS: CentOS 7.3

Python: 3.6.2

Get source code

Apache source

$ yum install httpd-deve

Download Python-3.6.2 Gzipped source tarball

Download mod_wsgi Source code (tar.gz)


Compile Python and mod_wsgi

Compile Python with the –enable-shared option

cd Puthon-3.6.*-source
./configure --enable-shared
make altinstall


Post compile add library path /usr/local/lib to ldconfig and check with

# ldconfig –v | grep python


now compile mod_wsgi

./configure --with-python=/usr/local/bin/python3.6
make install


Enable Apache module

Create /etc/httpd/conf.modules.d/10-mod_wsgi.conf

LoadModule wsgi_module modules/


Restart apache

Quick Tip: Delete existing partitions during CentOS 7 installation

Got stuck recently during a remote gig installing CentOS. Vanilla install failed  due to a hardware error and had to be reinstalled but unlike the earlier versions there wasn’t a clearly defined path to delete existing partitions. So here is what we did;

Installation destination:

  1. Custom partitoning, create automatic partitions will prompt that there is not enough free space
  2. Click Done to go back
  3. Select Automatic partition, click Done
  4. Click the recover free space option on the Error prompt window
  5. Delete all exiting partitions (or as needed)
  6. Click preserve to save changes
  7. Click Done to go back
  8. The Disk free space displayed near the bottom has increased

That’s it. You can now proceed with the usual installation steps.