Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

django

I have tried hard searching for the solution to my query but with no luck. I have made a website using django in my local machine. Now i want to install the same django made website in another machine. MySQL is the database i am using. How do i move the local django made website into another machine? If this question has been already put under discussion, my apologies.

like image 490
consumer Avatar asked Jan 31 '11 11:01

consumer


People also ask

How do I copy and paste a Django project?

You can easily just copy and paste the Root project folder and name it whatever you wish (here, in case which is Client2). The main changes you have to do is in inner project folder, just go through each file like settings.py,wsgi.py and all of them in it and replace Client1 to Client2.


2 Answers

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.

like image 183
adamnfish Avatar answered Oct 18 '22 12:10

adamnfish


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

like image 22
Noufal Ibrahim Avatar answered Oct 18 '22 11:10

Noufal Ibrahim