Aller au contenu

Installing and configuring Django on unmanaged servers

Ce contenu n’est pas encore disponible dans votre langue.

This guide explains how to install and configure Django on an unmanaged server.

  1. Create a virtual environment for Python using virtualenv and install Django.
  2. Log in to your server using SSH.
  3. Install Python, pip, and virtualenv (as root):

Debian / Ubuntu:

apt-get install python3
apt-get install python3-pip
pip3 install virtualenv

AlmaLinux / Fedora:

yum install python34
yum install python34-pip
pip3 install virtualenv
  1. Create and activate a virtual environment as a regular user:
cd ~
mkdir django-apps
cd django-apps
virtualenv env
source env/bin/activate
pip install django
django-admin --version
cd ~/django-apps
django-admin startproject mysite
  1. Edit the settings file /home/username/django-apps/mysite/mysite/settings.py:
  • Ensure debug mode is enabled:
DEBUG = True
  • Set allowed hosts (replace with your server’s IP address):
ALLOWED_HOSTS = ['xxx.xxx.xxx.xxx']
  1. Start the development web server (replace with your server IP):
python ~/django-apps/mysite/manage.py runserver xxx.xxx.xxx.xxx:8000
  1. Visit the site in your browser: http://xxx.xxx.xxx.xxx:8000
    You should see: “The install worked successfully! Congratulations!”
cd ~
python ~/django-apps/mysite/manage.py migrate
python ~/django-apps/mysite/manage.py createsuperuser
  1. Provide the admin username, e-mail, and password when prompted.
  2. If the development server is not running, start it

    Section titled “If the development server is not running, start it”
python ~/django-apps/mysite/manage.py runserver xxx.xxx.xxx.xxx:8000
  1. Access the admin interface at http://xxx.xxx.xxx.xxx:8000/admin
    Log in with the username and password you created.

Cette page vous a-t-elle aidé ?