Django on ValueHost Servers

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

    image

    Consider installing a Django application using the django CMS example .

    Web server and database preparation

    The first thing we need to do is get access to SSH:

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

    Next, we create a database for our application:

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

    Create a virtual server:

        Control Panel -> Web Servers -> Create New:
            Applications on the Server -> Python (mod_wsgi)
            Root Folder -> django_data
            Server Name -> mydomain.ru
            Turn on Accelerator for Static Content Delivery -> On.
            .htaccess -> On
        Save

    Application installation

    While the settings for the new server are applied (this takes no more than
    half an hour, the status can be viewed in 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 administrator login
        mydomain.ru - your domain or server technical address

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

        #django -admin.py startproject django_app

    Where,

        django_app - Django application directory

    Copy the django CMS distribution kit:

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

    Either download the latest version and unpack the contents into
    the ~ / django_app directory

    Copy the configuration example CMS from the distribution kit:

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

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

         DATABASE_ENGINE = database type: mysql or postgresql
         DATABASE_NAME = Database name
         DATABASE_NAME = Database name
         DATABASE_USER = Password specified when creating the database
         DATABASE_HOST = Address of the database server
         MEDIA_ROOT= os.path.join (PROJECT_DIR, 'cms / media /')
        ADMIN_MEDIA_PREFIX  = '/ media_admin /'

    In  INSTALLED_APP we comment on the line:

        'south',

    It should look like this:

        # 'south',

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

        #python ~ / django_app / manage.py syncdb

    Answering the questions:

        You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes / no): yes
        Username (Leave blank to use 'example'): Admin login
        E-mail address: Admin email
        Password: Admin
        password Password (again):

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

    We create the ~ / django_data / index.wsgi handler with the following
    contents: We make the handler executable: #chmod 500 ~ / django_data / index.wsgi We inform the web server that all requests should be processed by django using ~ / django_data / .htaccess Copy the 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

    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()




        




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




        

     


    log in with the administrator username and password.

    Installation of additional modules

    If you need to install additional python modules, please contact Online Support from your Control Panel, and we will be happy to do so.

    Also popular now: