anaconda + django + apache2

2021-06-04 13:02

阅读:687

标签:load   span   python2   min   查看   hub   follow   dom   etc   

0. 环境

系统ubuntu 16.04

python 环境:python2.7, python3.5, anaconda

anaconda 安装在 /home/szh/anaconda3/envs/env_py3.6

django 项目所在路径:/home/szh/django_project/mysite

1. 安装apache2

sudo apt-get update
sudo apt-get install apache2

sudo apt-get install apache2-dev

2. 安装mod_wsgi

  (参照 https://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html)

(1)下载并解压mod_wsgi-X.Y.tar.gz 

  • https://github.com/GrahamDumpleton/mod_wsgi/releases

(2)编译安装

    ./configure --with-python=/home/szh/anaconda3/envs/env_py3.6/bin/python

    make

    make install

3. 配置apache2

  (1) 配置 apache2.conf

  (参考:https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/modwsgi/ )

   在/etc/apache2/apache2.conf 文件最下面添加以下三行(目的是为了让apache2能正确装入mod_wsgi)。

LoadFile /home/szh/anaconda3/envs/env_py3.6/lib/libpython3.6m.so.1.0
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
WSGIPythonHome /home/szh/anaconda3/envs/env_py3.6

   (2) 添加mysite.conf

    在/etc/apache2//etc/apache2/sites-available 文件夹下添加 mysite.conf 文件,内容如下:

80> 

ServerName localhost:80     
ServerAlias otherdomain.com    
ServerAdmin xxx@Email.com    

Alias /media/ /home/szh/django_project/mysite/media/ 
Alias /static/ /home/szh/django_project/mysite/static/ 


     Options FollowSymLinks 
     Require all granted 
static> 
    Options FollowSymLinks 
    Require all granted 


WSGIScriptAlias / /home/szh/django_project/mysite/mysite/wsgi.py
 
        Require all granted 
     

WSGIDaemonProcess mysite python-home=/home/szh/anaconda3/envs/env_py3.6 python-path=/home/szh/django_project/mysite
WSGIProcessGroup mysite

 

4. 运行

   sudo /etc/init.d/apache2 start

  查看/var/log/apache2/error.log,其中有以下行:

  Apache/2.4.18 (Ubuntu) mod_wsgi/4.7.1 Python/3.6 configured  

  在浏览器输入 http://localhost/polls/ 

  

 

anaconda + django + apache2

标签:load   span   python2   min   查看   hub   follow   dom   etc   

原文地址:https://www.cnblogs.com/rabitvision/p/12341591.html


评论


亲,登录后才可以留言!