How to run django python server on your own VPS or Server at PawnHost

BUY LOWEST PRICE DJANGO PYTHON VPS - HERE

We recommend you to install Ubuntu as Operating system. you can see our budget VPS  here and dedicated servers here as per your budget.

 

INSTALLING DJANGO

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:

  1. Log in to your server using SSH.
  2. As the root user, type the following commands appropriate for your Linux distribution:
    • Debian and Ubuntu:
      apt-get install python3
      apt-get install python3-pip
      pip3 install virtualenv
      
    • CentOS and Fedora:

      yum install python34
      yum install python34-pip
      pip3 install virtualenv
      
  3. 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
  4. Django is now installed. To determine which version is installed, type the following command:

    django-admin --version

CONFIGURING DJANGO

Django is now installed, and you can create and configure a Django application. To do this, follow these steps:

  1. As a regular (non-root) user, type the following command:
    cd ~/django-apps
    django-admin startproject mysite
    
  2. Use a text editor to open the /home/username/django-apps/mysite/mysite/settings.py file. Replace username with the account username.
  3. Confirm that debug mode is enabled:

    DEBUG = True
  4. 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']
  5. Save your changes to the settings.py file.
  6. 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
  7. 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!
Configuring the administration interface

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:

  1. At the command prompt, type the following commands:
    cd ~
    python ~/django-apps/mysite/manage.py migrate
    python ~/django-apps/mysite/manage.py createsuperuser
    
  2. At the Username prompt, type the administrator username, and then press Enter.
  3. At the Email address prompt, type the administrator e-mail address, and then press Enter.
  4. At the Password and Password (again) prompts, type the administrator password, and then press Enter.
  5. 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
  6. Use your web browser to visit http://xxx.xxx.xxx.xxx:8000/admin, where xxx.xxx.xxx.xxx is your server IP address.
  7. Log in to the administration interface using the username and password that you specified in steps 2 and 4.

 

BUY LOWEST PRICE DJANGO PYTHON VPS - HERE

 

How To Use & Activate Virtualenv and pip on your VPS

 

This article describes how to use the virtualenv and pip programs. The virtualenv program enables you to create custom Python environments, while the pip program enables you to install Python packages. By using these programs, you can ensure your Python applications have the exact environment setup that they need to function correctly.

 

 

 

USING VIRTUALENV TO CREATE AN ENVIRONMENT

 

Virtualenv allows you to create your own custom Python environments. A custom environment has its own installation directories, Python executables, packages, and modules. This means you can install any specific versions that an application may require. Because the environment is isolated, you do not have to worry about other programs installing incompatible versions or otherwise breaking the application's configuration.

 

To create a custom Python environment:

 

Log in to your account using SSH.

To make sure you are in your home directory, type the following command at the command line:

cd ~

To create the environment, type the following command. You can replace project with any name you want:

 

virtualenv project

Virtualenv sets up the Python environment and installs the pip program.

 

By default, virtualenv installs the system-wide Python version, which is currently version 2.6. To install a specific Python version in the environment, use the -p option. For example, to create an environment that uses Python 3, type the following command:

 

virtualenv -p python3 project

To use the new environment, you must activate it first. To do this, type the following command:

 

source project/bin/activate

When the environment is active, the command prompt begins with (project), where project is the environment name.

When you are done working in the environment, type the following command:

 

deactivate

The command prompt returns to normal.

 

USING PIP TO INSTALL PYTHON PACKAGES

When you set up a custom Python environment with virtualenv, the pip program is installed as well. You can use the pip installer to install a large selection of Python packages into custom environments.

 

To use the pip program, follow these steps:

 

If you have not already activated the environment, do so now. Type the following command, replacing project with the environment name:

source ~/project/bin/activate

After the environment is activated, you can use the pip program to install and manage Python packages:

 

To search for a specific package or set of packages, type the following command. Replace pkgname with the name of the package that you want to search for:

pip search pkgname

For example, to search for all MySQL-related packages, type pip search mysql.

To install a Python package, type the following command. Replace pkgname with the name of the package that you want to install:

 

pip install pkgname

To uninstall a Python package, type the following command. Replace pkgname with the name of the package that you want to uninstall:

 

pip uninstall pkgname

MORE INFORMATION

For more information about virtualenv, please visit http://www.virtualenv.org.

For more information about pip, please visit http://www.pip-installer.org.

 

BUY LOWEST PRICE DJANGO PYTHON VPS - HERE

  • python VPS, django vps, your own django server, your own python server, django server
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Postgresql common commands

BUY LOWEST PRICE PGSQL VPS - HERE   How to grant access to users in PostgreSQL? Here are some...

Open PGSQL to the world

OPEN POSTGRESQL TO THE WORLD In this step, you need to allow remote connections to actually...

change hostname Ubuntu 18

Ubuntu 18.04 LTS change hostname permanently The procedure to change the computer name on...

Unblock all IPs - Allow everything Iptables

!/bin/sh iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -t mangle -F...

Additional Subnet with Hyper-V

Routing & Network PawnHost routes the additional subnet onto the main IP of the server and...

Powered by WHMCompleteSolution