Collapse

Announcement

Collapse
No announcement yet.

How to install Django on cPanel?

Collapse
X
  • 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.

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

    Code:
    cd /usr/local/src/
    wget http://storage.googleapis.com/google-code-attachments/modwsgi/issue-214/comment-0/custom_opt_mod-mod_wsgi.tar.gz
    tar -xvzf custom_opt_mod-mod_wsgi.tar.gz
    tar -xvzf ./Cpanel/Easy/ModWSGI.pm.tar.gz
    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.

    Code:
    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.

    Code:
    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.

    Code:
    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.

    Code:
    python -V
    Python 2.7.5
    Code:
    which python
    /usr/bin/python

    Step 7: Go back and complete mod_wsgi installation.

    Code:
    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.

    Code:
    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
    Code:
    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/mod_wsgi.so)

    ----------------------------------------------------------------------
    Libraries have been installed in:
    /usr/lib64/apache2/modules

    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/ld.so.conf'

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

    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.

    Code:
    LoadModule wsgi_module /usr/lib64/apache2/modules/mod_wsgi.so
    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 https://pypi.python.org/simple/django/

    We installed the latest one.

    Code:
    https://pypi.python.org/simple/django/
    wget https://pypi.python.org/packages/31/b7/8ad017c3e81635bb12c6d41b56fdbf4bb52eb30aea7f45cfeea61607bab8/Django-1.11.9.tar.gz#md5=08ad028fc50ee961dea35e1e1f657b65
    tar -xvzf Django-1.11.9.tar.gz
    cd Django-1.11.9
    python setup.py install
    This will process and install Django on your cPanel server.

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





    Comment


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

      Comment

      Working...
      X