How do I install the Xymon server on Centos

How do I install Django on Centos 7? 2021

Django is a free and open source, high-level Python web framework that enables developers to build secure, scalable, and maintainable web applications.

There are several methods you can use to install Django, depending on your needs. It can be installed system-wide or in a virtual Python environment with pip. Django packages are also included in the CentOS repositories and can be installed using the package manager, but are out of date.

In this tutorial, we will install and configure the latest stable version of Django on a CentOS 7 machine in a virtual Python environment.

The main purpose of Python virtual environments is to create an isolated environment for different Python projects. This way you can have several different Django environments on a single computer and install a specific version of a module per project without having to worry about it affecting your other Django installations. If you are installing Django in a global environment, you can only install one version of Django on your computer.

Install Django on CentOS 7

The following sections provide step-by-step instructions for installing Django in a Python virtual environment on CentOS 7.

1. Install Python 3

We will install Python 3.6 from the Software Collections (SCL) repositories.

CentOS 7 ships with Python 2.7.5, which is an important part of the CentOS base system. SCL allows you to install newer versions of Python 3.x alongside the standard Python v2.7.5 to keep system tools like yum working properly.

Start by enabling SCL by installing the CentOS SCL version file contained in the CentOS Extras repository:

Once the repository is enabled, install Python 3.6 using the following command:

Once Python 3.6 is installed, we can create a virtual environment for our Django application.

2. Create a virtual environment

Starting with Python 3.6, it is recommended to create a virtual environment using the module.

Navigate to the directory where you want to save your Python 3 virtual environments. This can be your home directory or any other directory that your user has read and write permissions to.

Create a new directory for your Django application and cd into it:

To access Python 3.6 you need to create a new shell instance with the tool:

Run the following command to create a new virtual environment:

The above command creates a directory named that contains a copy of the Python binary, Pip package manager, standard Python library, and other supporting files. You can use any name for the virtual environment.

To use this virtual environment you need to enable it by doing this:

After activation, the bin directory of the virtual environment is added to the beginning of the variable. Your shell's prompt will also change to show the name of the virtual environment you are currently using. In our case it is.

3. Install Django

After the virtual environment has been activated, you can install Django using the Python package manager:

In the virtual environment, you can use the command instead of and instead of.

To verify the installation, use the following command which will print the Django version:

At the time of this writing, the latest official Django version is 2.1.2

Your Django version may differ from the version shown here.

4. Create a Django project

To use a new Django project named this:

The above command creates a directory in your current directory.

In this directory you will find the main script for managing projects with the name as well as another directory with database configuration and Django settings and application-specific settings.

Let's migrate the database and create an administrator.

Start by going to the directory:

By default, Django uses a SQLite database. For production applications, you can use PostgreSQL, MariaDB, Oracle or MySQL Database.

Run the following command to migrate the database:

The output looks something like this:

After migrating the database, create an administrator so that you can use the Django administration interface:

The command prompts you for a username, email address, and password for your administrator.

5. Testing the development server

Start the development web server using the Option script:

You will see the following output:

If you have Django installed on a virtual machine and you want to access the Django development server, you need to edit the file and add the server IP address to the list.

Open in your web browser and you will get the standard Django landing page:

To stop the development server, enter in your terminal.

6. Deactivate the virtual environment

When you're done with your work, disable the environment by typing disable and you'll be returned to your normal shell.

Conclusion

You learned how to create a Python virtual environment and install Django on your CentOS 7 computer. To create additional Django development environments, repeat the steps outlined in this tutorial.

Python Centos