简体   繁体   中英

Django Apache Python3.5 Vesta panel

I use a bunch of Ubuntu 16.04 + Apache 2.4 + Django 1.10 + Python3.5 + wsgi + virtualenv.

The apache configuration ordered following

WSGIDaemonProcess myproject python-path/home/admin/web/domen.com/private/myprojectenv:/home/admin/web/domen.com/private/myprojectenv/lib/python3.5/site-packages
WSGIProcessGroup myproject
WSGIScriptAlias / /home/admin/web/domen.com/private/myproject/wsgi.py

wsgi.py standard

import os

from django.core.wsgi import get_wsgi_application



os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

application = get_wsgi_application()

Reinstall everything. Fat, you see the error 500. log: from django.core.wsgi import get_wsgi_application ImportError: No module named 'django'

I had the same problem and solved it installing the propper version of mod_wsgi to use with specific python version (I have 3.4). Check info here in the modwsgi readthedocs

If you want to use the compiled version, you'll need to compile mod_wsgi against the Python version you want to run on. Point to the version of Python you want to use with the --with-python parameter. Here's an example.

wget "https://github.com/GrahamDumpleton/mod_wsgi/archive/4.x.y.tar.gz"
tar -xzf '4.x.y.tar.gz'
cd ./mod_wsgi-4.x.y
./configure --with-python=/usr/local/bin/python3.5
make
make install

Good luck!

I managed razobratsya a problem below will describe its solution.

My system Ununtu 16.04, Vesta panel 0.9.8-17 (including all blew nginx + apache).

Since I needed python3 for him, and I will describe, if you have nothing to pothon2 all except Similar Containers installed packages.

Install the package, and the environment itself Jango took from here https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-16-04

What has changed: wsgi.py

import os, sys

sys.path.append ( '/ home / admin / web / domen.com / private') # The path to the folder with Django project
from django.core.wsgi import get_wsgi_application

os.environ.setdefault ( "DJANGO_SETTINGS_MODULE", "myproject.settings")

application = get_wsgi_application ()

Apache Configuration for West Side:

<VirtualHost 172.11.11.11:8080>

    ServerName domen.com
    ServerAlias ​​www.domen.com
    ServerAdmin info@domen.com
    DocumentRoot /home/admin/web/domen.com/public_html
    ScriptAlias ​​/ cgi-bin / /home/admin/web/domen.com/cgi-bin/
    Alias ​​/ vstats / /home/admin/web/domen.com/stats/
    Alias ​​/ error / /home/admin/web/domen.com/document_errors/
    #SuexecUserGroup Admin admin
    CustomLog /var/log/apache2/domains/domen.com.bytes bytes
    CustomLog /var/log/apache2/domains/domen.com.log combined
    ErrorLog /var/log/apache2/domains/domen.com.error.log
    <Directory /home/admin/web/domen.com/public_html>
        AllowOverride All
        Options + Includes -Indexes + ExecCGI
        php_admin_value open_basedir /home/admin/web/domen.com/public_html:/home/admin/tmp
        php_admin_value upload_tmp_dir / home / admin / tmp
        php_admin_value session.save_path / home / admin / tmp
    </ Directory>
    <Directory /home/admin/web/domen.com/stats>
        AllowOverride All
    </ Directory>
  
<IfModule mod_ruid2.c>
        RMode config
        RGroups www-data
    </ IfModule>
    <IfModule itk.c>
        AssignUserID admin admin
    </ IfModule>

  Alias ​​/ static /home/admin/web/domen.com/private/static
<Directory /home/admin/web/domen.com/private/static>
        Require all granted
   </ Directory>


    <Directory /home/admin/web/domen.com/private/myproject>
        <Files wsgi.py>
           Require all granted
       </ Files>
      </ Directory>
     
    WSGIScriptAlias ​​/ /home/admin/web/domen.com/private/myproject/wsgi.py
    WSGIDaemonProcess myproject user = admin group = admin python-path = / home / admin / web / domen.com / private / env / lib / python3.5 / site-packages
    WSGIProcessGroup myproject
    
    IncludeOptional /home/admin/conf/web/apache2domen.com.conf*

</ VirtualHost>

I am satisfied by all of the admin. In WSGIDaemonProcess necessarily need to specify Ucero and Korhogo GROUP from all handled differently is a problem with access to the database

Initially block <IfModule mod_ruid2.c> looks like this:

<IfModule mod_ruid2.c>
        RMode config
        RUidGid admin admin
        RGroups www-data
    </ IfModule>

But I removed vnem RUidGid admin group admin, as it blocked the start and gave a 503 error (if anyone knows of such a feature then write in the comments)

This server is ready to run.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM