📜 ⬆️ ⬇️

Django on ValueHost servers

Hello, today we will tell you how to install the framework Django on ValueHost servers.

image

Consider installing a Django application on the example of django CMS .
')
Web server and database preparation

The first thing we need to do is access SSH:

Control Panel -> SSH -> Set the password and the On flag. (either limited by IP)

Next, create a base for our application:

Control Panel -> Databases -> MySQL or PgSQL to choose from
We remember the name of the database, password, type, and address of the database server.

Create a virtual server:

Control Panel -> Web Servers -> Create New:
Server Applications -> Python (mod_wsgi)
Root folder -> django_data
Server name -> mydomain.ru
Enable accelerator return static content -> On.
.htaccess -> On
Save

Application installation

While the settings for the new server are applied (it takes no more than
half an hour, you can see the status of the Control Panel ->
Home ), create an application on the server.

Using any SSH client, we go to the server:

ssh my_admin_login@mydomain.ru

Where,

my_admin_login - your admin login
mydomain.ru - Your domain or technical address of the server

After entering the password (we set it at the very beginning), we perform the following
command:

# django-admin.py startproject django_app

Where,

django_app - Django application directory

Copy the django CMS distribution:

#cp -R /usr/local/lib/python2.6/site-packages/django_cms-2.0.2-py2.6.egg/*~/django_app

Or download the latest version and unpack the contents in
~ / django_app directory

Copy the sample CMS configuration from the distribution:

#cp -R ~ / django_app / example / * ~ / django_app /

Configuring the configuration by editing the file
~ / django_app / settings.py :

DATABASE_ENGINE = database type: mysql or postgresql
DATABASE_NAME = Base Name
DATABASE_NAME = Base Name
DATABASE_USER = Password specified during database creation
DATABASE_HOST = Database Server Address
MEDIA_ROOT = os.path.join (PROJECT_DIR, 'cms / media /')
ADMIN_MEDIA_PREFIX = '/ media_admin /'

AT   INSTALLED_APP commenting line:

'south',

It should turn out like this:

# 'south',

Save the file and execute the command from the command line:

#python ~ / django_app / manage.py syncdb

We answer the questions:

You just installed Django's auth system. Would you like to create one now? (yes / no): yes
Username (Leave blank to use 'example'): Admin Login
Email address: admin email
Password: Admin Password
Password (again): Confirm Password

At this point, the web server settings have already been applied in the home
The directory has created the django_data web server directory .

Create the ~ / django_data / index.wsgi handler of the following
content:

import os, sys root_path = os.path.abspath(os.path.split(__file__)[0])
sys.path.append(root_path+'/..') sys.path.append(root_path) os.environ['DJANGO_SETTINGS_MODULE'] = 'django_app.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


Making the handler executable:

#chmod 500 ~ / django_data / index.wsgi

We inform the web server that all requests must be processed by django when
help ~ / django_data / .htaccess

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.wsgi/$1 [L,QSA]


Copy media content for admin panel:

#cp -R
/usr/local/lib/python2.6/site-packages/django/contrib/admin/media
~ / django_data / media_admin

Everything, CMS is installed, go to the address specified in the server name and
log in with administrator login and password.

Installation of additional modules

If you need to install additional python modules - contact Online Support from your Control Panel, and we will do it with pleasure.

Source: https://habr.com/ru/post/104998/


All Articles