This article demonstrates how to install and configure Django on an unmanaged server.
To install Django, you first create a virtual environment for Python by using the virtualenv tool. After you activate the virtual environment, you can use the pip installer to install Django.
To do this, follow these steps:
apt-get install python3 apt-get install python3-pip pip3 install virtualenv
AlmaLinux and Fedora:
yum install python34 yum install python34-pip pip3 install virtualenv
As a regular (non-root) user, type the following commands:
cd ~ mkdir django-apps cd django-apps virtualenv env source env/bin/activate pip install django
Django is now installed. To determine which version is installed, type the following command:
django-admin --version
Django is now installed, and you can create and configure a Django application. To do this, follow these steps:
cd ~/django-apps django-admin startproject mysite
Confirm that debug mode is enabled:
DEBUG = True
Locate the ALLOWED_HOSTS line, and then modify it as follows. Replace xxx.xxx.xxx.xxx with the IP address of your server:
ALLOWED_HOSTS = ['xxx.xxx.xxx.xxx']
To start the development web server, type the following command. Replace xxx.xxx.xxx.xxx with the IP address of your server:
python ~/django-apps/mysite/manage.py runserver xxx.xxx.xxx.xxx:8000
Use your web browser to visit http://xxx.xxx.xxx.xxx:8000, where xxx.xxx.xxx.xxx is your server IP address. You should see the following message:
The install worked successfully! Congratulations!
Django includes an administration interface that you can use to modify web site applications, manage users and groups, and more. To configure the Django administration interface, follow these steps:
cd ~ python ~/django-apps/mysite/manage.py migrate python ~/django-apps/mysite/manage.py createsuperuser
If the development web server is not running, type the following command. Replace xxx.xxx.xxx.xxx with the IP address of your server:
python ~/django-apps/mysite/manage.py runserver xxx.xxx.xxx.xxx:8000
Now that you have a Django-enabled web site up and running, you can start the real work of developing your own applications. The following resources can help:
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.