tags:

views:

512

answers:

7

To deploy a site with Python/Django/MySQL I had to do these on the server (RedHat Linux):

  • Install MySQLPython
  • Install ModPython
  • Install Django (using python setup.py install)
  • Add some directives on httpd.conf file (or use .htaccess)

But, when I deployed another site with PHP (using CodeIgniter) I had to do nothing. I faced some problems while deploying a Django project on a shared server. Now, my questions are:

  • Can the deployment process of Django project be made easier?
  • Am I doing too much?
  • Can some of the steps be omitted?
  • What is the best way to deploy django site on a shared server?
+1  A: 

You didn't have to do anything when deploying a PHP site because your hosting provider had already installed it. Web hosts which support Django typically install and configure it for you.

John Millikin
+4  A: 

Can the deployment process of django project be made easier?

No. You can script some of this, if you want. However, you're never going to install MySQL, MySQLPuthon, mod_wsgi (or mod_python), or Django again.

You will, however, tweak your application all the time.

Am I doing too much?

No. Python (and Django) are not part of Apache. PHP is embedded in Apache. PHP is exactly like mod_python (or mod_wsgi). Just one piece of the pie. (Apparently, some hosts handle the PHP installation for you, but don't handle the mod_wsgi or mod_python installation.)

Can some of the steps be omitted?

No. However, you only do it once.

What is the best way to deploy django site on a shared server?

You're doing it correctly.

When I deployed another site with php (using CodeIgniter) I had to do nothing

Certainly an unfair comparison. Apparently, they already installed PHP and the database for you. Nice of them.

Also, PHP is not Python. PHP is a plug-in to Apache. Python is "just" a programming language, that requires a separate plug-in to Apache (i.e., mod_python or mod_wsgi).

See http://stackoverflow.com/questions/1311789/how-nicely-does-python-flow-with-html-as-compared-to-php/1311980#1311980

S.Lott
PHP is, like Python, a separate language which may be embedded into the server via a module. PHP is certainly not part of Apache.
John Millikin
@John Millikin: PHP always seems to be a bit more than "just" a language. It seems to be designed specifically to plug into Apache, where Python does not have a similar expectation.
S.Lott
How do you figure? PHP often sits behind FastCGI, and is fronted by a fast HTTP server such as lighttpd or cherokee. Apache + PHP is the most popular option, but if PHP is part of Apache then so are Python, Perl, Ruby, or any other embeddable language.
John Millikin
@John Millikin: PHP seems to include a template language plus HTTP protocol handling. Python doesn't. PHP can be directly embedded in Apache. Python can't, it requires an additional module (mod_wsgi or mod_python). I just don't see the parallels between PHP -- which does web processing as a first-class feature -- and Python which is just a language.
S.Lott
+2  A: 

Django hosting support is not as widespread as for PHP, but there are some good options. I can recommend WebFaction - they provide an easy-to-use control panel which offers various combinations of Django versions, Python versions, mod_python, mod_wsgi, MySQL, PostgreSQL etc. They're cost-effective, too. If you use their setup, you get SSH access but just about all of the setting up can be done via their control panel, apart from the actual uploading of your project folder.

Disclaimer: apart from being a happy customer I have no other connection with them.

Vinay Sajip
A: 

Most shared hosting sites run the LAMP (Linux, Apache, MySQL, PHP) stack so deployment is just a matter of copying some files over. If you were using one of the PHP frameworks like CakePHP or something the service hasn't installed (like an imaging library) you'd be going through extra deployment steps as well.

With Django (or Rails, or any other complex framework) you have to set up the stack yourself that one time, then you're good to go.

However, you'll also want to think about post-deployment updating. If it's something you're going to do often you may also want to look into Fabric or Capistrano to help automate that.

P.S. I'll second that WebFaction recommendation. It's as close to one-button installation as I've seen. Pretty happy customer although I mostly use them for test-sites and prototyping.

Ramin
+1  A: 

You just install this already made solution if your allowed to run an image on a virtual machine. I can imagine installations will be done this way in future as complicated security configuration can be done automatically.

David Raznick
A: 

You can use Python virtualenv and pip (see also "Tools of the Modern Python Hacker: Virtualenv, Fabric and Pip"). I developed my Django project in the virtual environment. I copy the virtual environment file to the production machine when I deploy my application. I use mod_wsgi. You must write that in the mod_wsig file:

import site  
site.addsitedir('C:\PythonVirtualEnv\IntegralEnv\Lib\site-packages') 
Maplye
+2  A: 
Pierre-Jean Coudert
+1.00000 Fabric
hughdbrown