The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Django / Python with cPanel ?

Discussion in 'General Discussion' started by boughtonp, Sep 18, 2007.

  1. boughtonp

    boughtonp Member

    Joined:
    Sep 1, 2007
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    there
    cPanel Access Level:
    Root Administrator
    Is it possible to do Python via cPanel?

    And if so, would there be any potential issues (security / performance)?
     
  2. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    I think it relies upon mod_python, which you would need to install manually. Once that is done, setup is rather easy using the Python setup tools. Performance issues will like be the same as any other dynamic language (PHP, Perl, etc). If you don't have any experience with Python specific services, you might want to do some research on Python-specific sites.
     
  3. boughtonp

    boughtonp Member

    Joined:
    Sep 1, 2007
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    there
    cPanel Access Level:
    Root Administrator
    Thanks. I've only dabbled a bit with Python scripts, so I'll look for some sites about Python services.
     
  4. phred_02

    phred_02 Member

    Joined:
    Jan 25, 2004
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    I have also been looking into running Django with Cpanel. If you choose to go the mod_python route you will need to be running apache 2.

    From what I have been reading, it is also possible to run Django with FastCGI, but I am still unclear if this also requires apache 2.
     
  5. boughtonp

    boughtonp Member

    Joined:
    Sep 1, 2007
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    there
    cPanel Access Level:
    Root Administrator
    Thanks for the info, I am on Apache 2. :)

    I'll post anything useful I find back in this thread.
    (Nothing yet; I've been busy all today.)
     
  6. phred_02

    phred_02 Member

    Joined:
    Jan 25, 2004
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    I managed to get django running on Apache 1.3 using mod_wsgi. Mod_wsgi will also work with apache 2. I would be happy to help if necessary.
     
  7. darren.nolan

    darren.nolan Well-Known Member

    Joined:
    Oct 4, 2007
    Messages:
    259
    Likes Received:
    0
    Trophy Points:
    16
    Howdy everyone. Yay for my first post.

    I've been trolling on these forums for a little while now, everyone seems really switched on - a nice change from the rest of the internet and forums out there.

    I updated Apache from 1.3 to 2.2 in preparation to install Django (not interested in using FastCGI) - everything went pretty smoothly when switched over to EDGE.

    I have Python 2.4.4 and mod_python installed, now it's just time for Django. I've never used Django, nor do I really want to learn what it's about. When reading the install guide, it gives several branches to setup for either MySQL, PostgreSQL, SQLite - can't I use all depending on the end user/programmer?

    I'm about to have a little stab at it and will write back if I have any troubles - any heads up would be awesome.

    Cheers Guys.
    Dazz
     
  8. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    As long as you have the Python interfaces for PostgreSQL, MySQL and SQLite, DJango will work with them. It then depends upon the configuration of the Django application. There may be more to it, as I've only progressed to the point of installing Django, not actually using it.
     
  9. rsferreira

    rsferreira Member

    Joined:
    May 20, 2003
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    It would be nice to be able to easily run Django applications on cPanel servers.

    We'd prefer to use Django for many web applications we're developing, but we had to choose a PHP framework just because running Django on a cPanel shared hosting would be - AFAIK - a nightmare.

    Regards,
    Rodrigo
     
  10. darren.nolan

    darren.nolan Well-Known Member

    Joined:
    Oct 4, 2007
    Messages:
    259
    Likes Received:
    0
    Trophy Points:
    16
    Not sure I follow this. You'd have to explain. Django works fine on a shared host for me, you can setup inside <virtualhost></virtualhost> your site's settings etc, so I'd love a clarification on this.

    I'm in the same boat as cpanelkenneth mostly, I've installed everything, everything appears to work and I have two-three people using it at the moment. They just open a support ticket and ask me nicely to change the apache conf file for settings as needed.
     
  11. hbouma

    hbouma Well-Known Member

    Joined:
    Jun 8, 2002
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    6
    Leaning towards fcgi for django

    I've had a client ask to install this on a VPS and I'm leaning towards using fcgi over mod_python for the simple reason that with mod_python they have to restart apache to see their changes. Whereas with the fastcgi method, it will load the new changes without any restarts. Which simplifies things as its a production server. Since he's also using Ruby, that will be two services using fastcgi as well.

    Hal
     
  12. shacker23

    shacker23 Well-Known Member

    Joined:
    Feb 20, 2005
    Messages:
    263
    Likes Received:
    1
    Trophy Points:
    16
    I'm getting a number of Django requests lately as well. cPanel did such a nice job with the Rails integration, sure would be nice to see parallel support for Django.
     
  13. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Currently, no one has requested Django support in our official feature request system: http://bugzilla.cpanel.net
     
  14. shacker23

    shacker23 Well-Known Member

    Joined:
    Feb 20, 2005
    Messages:
    263
    Likes Received:
    1
    Trophy Points:
    16
  15. esolutions

    esolutions Member

    Joined:
    Aug 16, 2006
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Any updates on this? I'm thinking of setting up Django on my WHM server but I'd rather not do it by hand. If anything could we get a How-To from either cPanel or the community?
     
  16. shacker23

    shacker23 Well-Known Member

    Joined:
    Feb 20, 2005
    Messages:
    263
    Likes Received:
    1
    Trophy Points:
    16
    esolutions - I don't think you have a choice beyond setting up Django by hand at this point. If cPanel adopts Django it'll rock my world, but for now it's a fully manual process.

    We recently did a big Django rollout on cPanel at work and one of our developers wrote a really nice step-by-step guide to the setup:

    http://m.andric.us/post/43754517/django-python-with-cpanel

    Comments welcome. HTH!
     
  17. djbob2

    djbob2 Well-Known Member

    Joined:
    May 14, 2005
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    16
    Thanks a lot for the tutorial! I am actually currently working on installing Django on my cPanel box and this should help. I will get back to you on this.

    Question: is there any way to enable Django without having to individually modify every virtualhost to enable Django on a per-account basis? Are WSGI directives able to execute in .htaccess files? And if not, how hard would it be to add the required directives by default on new cPanel accounts? The django.wsgi file and a folder for django apps can easily be auto-created using cPanel/WHM's Skeleton Directory feature.
     
  18. shacker23

    shacker23 Well-Known Member

    Joined:
    Feb 20, 2005
    Messages:
    263
    Likes Received:
    1
    Trophy Points:
    16
    djbob2 - I haven't tried this, but I believe that you can modify

    Code:
    /var/cpanel/templates/apache2/vhost.conf
    Then when you create new vhosts their configurations will be based on that. So think of it as a companion to the skeleton system. I'm not sure whether cpanel updates would overwrite your changes to that file.
     
  19. djbob2

    djbob2 Well-Known Member

    Joined:
    May 14, 2005
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    16
    Thanks shacker! I will try this either today or tommorow and let you know how it went.
     
  20. mandric

    mandric Registered

    Joined:
    May 30, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    using .htaccess

    Sure you can use .htaccess, that works too. But from my experiments it only works with embedded mode. So you may lose some benefits of the daemon mode. But that's a good question and if you ask the list or search around a bit you'll surely come up with something.

    According to the docs WSGIScriptAlias directive only works in a vhost container or server wide (globally).
    http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIScriptAlias

    To do mod_wsgi in embedded mode using .htaccess you can use something like this.

    RewriteEngine On
    RewriteBase /
    # Skip the media dirs
    RewriteRule ^(media/.*)$ - [L]
    RewriteRule ^(admin_media/.*)$ - [L]

    # Rewrite everything else to disptach.wsgi
    RewriteRule ^(dispatch\.wsgi/.*)$ - [L]
    RewriteRule ^(.*)$ dispatch.wsgi/$1 [QSA,PT,L]

    Of course you need to tell apache what to do with .wsgi as well by adding these globally:
    LoadModule wsgi_module /usr/local/apache/modules/mod_wsgi.so
    AddHandler wsgi-script .wsgi
     
    #20 mandric, Jul 29, 2008
    Last edited: Jul 29, 2008
Loading...

Share This Page