How to move a local django made site into another machine?

This is called "deployment". There are lots of ways to do this some of which are documented at http://docs.djangoproject.com/en/dev/howto/deployment/. There's also http://djangobook.com/en/2.0/chapter12/ which gives some more general information. Your path will depend on what your actual server supports/provides.

You should use those as starting points and then report back problems here so that we can fix them.

Update: The actual steps you need to deploy your application (i.e. get it running on the live server) depends on your service provider. The steps broadly are to set up your webserver to serve the application, set up your database with the right values and start the webserver. The actual steps on how to do this depend on your server (what front facing webserver they use, how you can edit it's config, is it shared or a VPS, do you have shell access etc.). Here is an example of how you would do it on webfaction (a popular python shared hosting provider).

http://docs.webfaction.com/software/django/getting-started.html


To set up the same Django site on a different machine, you can just copy the code across. When you try and run it, you'll get errors if anything isn't set up correctly which you can resolve one by one. A few errors you are likely to get are:

  1. Make sure Python is installed on the new box
  2. Make sure Django and any other dependencies are installed
  3. You'll need to install MySQL and set up a database on the new machine
    • the details for the database (name, user, password) will be in your project's settings.py file
    • if the database's host isn't localhost or 127.0.0.1, you will need to think about where to put the new database
  4. Make sure you have set up a URL that points at the new box, unless it is just for development (in which case you can use Django's built in dev server via manage.py runserver)
  5. Ensure apache/your server of choice is set up correctly

All these steps should simply be repeating things you did on the old machine.

If you have a 'dev' machine and a 'production' machine, you should consider deployment solutions that automate much of this process. You should also put the code into version control if it isn't already (Git, mercurial, subversion) so that you can manage changes to the source from either location.

If you want to have the same site across both machines (so changes to one appear on the other) you are probably talking about 'load balancing'. You'll need to set up another server that can delegate requests to these two machines and point both at the same database.

Tags:

Python

Django