No announcement yet.

How to install Django on cPanel?

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to install Django on cPanel?

    How can I install Django on cPanel. Please provide me the correct steps.

  • #2
    We tried to install Django on a test cPanel server with no accounts on it.

    We faced multiple issues but had a work around to fix it.

    Step 1: Start by installing cPanel on the server.

    cd /home && curl -o latest -L && sh latest
    Step 2: In order to run Django websites you will need mod_wsgi Apache module.

    cd /usr/local/src/
    tar -xvzf custom_opt_mod-mod_wsgi.tar.gz
    tar -xvzf ./Cpanel/Easy/
    cd mod_wsgi-3.3
    make && make install
    You may end up with an error message " apxs command not found ".

    The reason for this is you are running latest Apache version 2.4.29 with EA4.

    Step 3 : To check the dependencies for aspx you must run following command on the server.

    yum provides apxs
    The output will be similar to the below result.

    ea-apache24-devel-2.4.29-6.6.1.cpanel.x86_64 : Development interfaces for the Apache HTTP server
    Repo : EA4
    Matched from:
    Filename : /usr/bin/apxs

    Step 4: check the one that matches your Apache version and run the command as below.

    yum install ea-apache24-devel-2.4.29-6.6.1.cpanel.x86_64
    Step 5: This will install apxs and can be verified as.

    ls -la /usr/bin/apxs
    -rwxr-xr-x 1 root root 19379 Jan 17 14:01 /usr/bin/apxs
    Step 6: Thereafter, check the python version and its binary location.

    python -V
    Python 2.7.5
    which python

    Step 7: Go back and complete mod_wsgi installation.

    cd /usr/local/src/
    cd mod_wsgi-3.3
    ./configure --with-apxs=/usr/bin/apxs       --with-python=/usr/bin/python
    make && make install
    Step 8: Unfortunately, ended up with another error "conn_rec' has no member named 'remote_ip'' and "conn_rec' has no member named 'remote_addr''. To fix this, we modified the code as below.

    cp mod_wsgi.c mod_wsgi.c_bk
    sed s/remote_ip/client_ip/g -i mod_wsgi.c
    sed s/remote_addr/client_addr/g -i mod_wsgi.c
    make && make install
    Success !!!

    You will see the output on the screen as below which will give you the location of the libraries installed for the module mod_wsgi (It is installed at /usr/lib64/apache2/modules/

    Libraries have been installed in:

    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
    - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
    during execution
    - add LIBDIR to the `LD_RUN_PATH' environment variable
    during linking
    - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
    - have your system administrator add LIBDIR to `/etc/'

    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and manual pages.
    chmod 755 /usr/lib64/apache2/modules/

    You will now have to include it in the Apache configuration.

    Step 9 : Login to WHM Home >> Service Configuration >> Apache Configuration>> Include Editor >> edit Pre Main Include and update with below code.

    LoadModule wsgi_module /usr/lib64/apache2/modules/
    AddHandler wsgi-script .wsgi
    Restarting Apache Web Server
    Apache successfully restarted. Signaled successfully. This is a sign that you have everything in place.

    Step 10: Lastly, Install Django.

    Django softwares are available at

    We installed the latest one.

    tar -xvzf Django-1.11.9.tar.gz
    cd Django-1.11.9
    python install
    This will process and install Django on your cPanel server.

    Now you may go ahead and test you Django application !!!


    • #3
      Great Information. Thanks for detailed step by step process.