Skip to content Skip to sidebar Skip to footer

How Can Django Projects Be Deployed With Minimal Installation Work?

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

Solution 1:

To enable easy Django deployement I would to the following:

Fisrt-time server configuration

  • Install mod_wsgi which allow you to run in embedded mode OR in daemon mode.
  • Install python and virtualenv

In your development environment

Every time you want to deploy

  • Copy your virtual environment to the production server
  • Just add an Include directive in your httpd.conf file (or use .htaccess) to your project's apache configuration. As stated in mod_wsgi integration with django documentation, one example of how Apache included file could be configured would be:

Alias /media//usr/local/django/mysite/media/<Directory /usr/local/django/mysite/media>Order deny,allow
  Allow fromall</Directory>

WSGIScriptAlias //usr/local/django/mysite/apache/django.wsgi

<Directory /usr/local/django/mysite/apache>Order deny,allow
  Allow fromall</Directory>

Automating deployement

  • I would consider using Fabric to automate deployement

Solution 2:

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 How nicely does Python 'flow' with HTML as compared to PHP?

Solution 3:

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.

Solution 4:

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.

Solution 5:

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.

Post a Comment for "How Can Django Projects Be Deployed With Minimal Installation Work?"