2017-03-20 1 views
0

django 튜토리얼과 mod_wsgi 설치 안내서에 따라 Apache와 mod_wsg를 LinuxMint18.1에서 사용하고 있지만 apache2ctl start를 실행하면 오류가 발생합니다.Linux에서 mod_wsgi를 사용할 때 왜 오류가 발생 했습니까?

Current thread 0x00007f88c10c7780 (most recent call first): 
[Mon Mar 20 21:23:28.781270 2017] [core:notice] [pid 32458:tid 140225331099520] AH00052: child pid 7962 exit signal Aborted (6) 
Fatal Python error: Py_Initialize: can't initialize sys 

나에게 무슨 문제가 있습니까?

나는 다음 단계는 아파치와 mod_wsgi에 설치하기 위해 수행 :

  1. apt-get을 아파치 설치
  2. 있는 apt-get-dev에 아파치를 설치를
  3. apt-get을 설치 python3.5-dev에
  4. wget을 https://github.com/GrahamDumpleton/mod_wsgi/archive/4.5.15.tar.gz
  5. 타르 -zxvf mod_wsgi에-4.5.15.tar.gz
  6. CD mod_wsgi에-4.5.15
  7. ,
  8. ./configure를 --with-파이썬 =는/usr/빈/python3.5
  9. 설치 할 수 있도록

ls /usr/bin/ -aoh |grep python의 출력은 다음과 같습니다

lrwxrwxrwx 1 root 26 3月 18 09:40 dh_pypy -> ../share/dh-python/dh_pypy 
-rwxr-xr-x 1 root 1.1K 12月 10 2015 dh_python2 
lrwxrwxrwx 1 root 29 3月 18 09:40 dh_python3 -> ../share/dh-python/dh_python3 
lrwxrwxrwx 1 root 23 3月 18 09:40 pdb2.7 -> ../lib/python2.7/pdb.py 
lrwxrwxrwx 1 root 23 3月 18 09:40 pdb3.5 -> ../lib/python3.5/pdb.py 
lrwxrwxrwx 1 root 31 3月 18 09:40 py3versions -> ../share/python3/py3versions.py 
lrwxrwxrwx 1 root 26 3月 18 09:40 pybuild -> ../share/dh-python/pybuild 
lrwxrwxrwx 1 root 18 3月 20 18:36 python -> /usr/bin/python2.7 
lrwxrwxrwx 1 root  9 3月 18 09:40 python2 -> python2.7 
-rwxr-xr-x 1 root 3.4M 11月 19 17:35 python2.7 
lrwxrwxrwx 1 root  9 3月 18 09:40 python3 -> python3.5 
-rwxr-xr-x 1 root 4.3M 11月 18 03:23 python3.5 
lrwxrwxrwx 1 root 33 11月 18 03:23 python3.5-config -> x86_64-linux-gnu-python3.5-config 
-rwxr-xr-x 1 root 4.3M 11月 18 03:23 python3.5m 
lrwxrwxrwx 1 root 34 11月 18 03:23 python3.5m-config -> x86_64-linux-gnu-python3.5m-config 
lrwxrwxrwx 1 root 10 3月 18 09:40 python3m -> python3.5m 
lrwxrwxrwx 1 root 29 3月 18 09:40 pyversions -> ../share/python/pyversions.py 
lrwxrwxrwx 1 root 34 11月 18 03:23 x86_64-linux-gnu-python3.5-config -> x86_64-linux-gnu-python3.5m-config 
-rwxr-xr-x 1 root 3.2K 11月 18 03:20 x86_64-linux-gnu-python3.5m-config 

/etc/apache2/apache2.conf :

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so 

WSGIScriptAlias//home/jeffrey/桌面/Workspace/django-env/hello_django/hello_django/wsgi.py 
WSGIPythonHome /home/jeffrey/桌面/Workspace/django-env 
WSGIPythonPath /home/jeffrey/桌面/Workspace/django-env/hello_django 

<Directory /home/jeffrey/桌面/Workspace/django-env/hello_django/hello_django> 
<Files wsgi.py> 
Require all granted 
</Files> 
</Directory> 

프로젝트 파일 구조 :

django-env 
├── hello_django 
│   ├── hello_django 
│   │   └── wsgi.py 
+0

virtualenv를 사용하고 있습니까? httpd.conf와 wsgi 파일의 적절한 부분은 무엇입니까? –

+0

이것은 일반적으로 비표준 위치에 파이썬 설치를 사용하여 소스 코드에서 mod_wsgi를 빌드했지만 동일한 메이저/마이너 버전으로 시스템 전체에 설치된 파이썬 버전이 있고 잘못된 파이썬 공유 라이브러리를 선택하고 있음을 나타냅니다. 사용중인 Python 버전과 설치 위치를 상세하게 설명합니다. –

+0

@GrahamDumpleton 질문에 자세히 설명했습니다. 한번보세요. – Jeffery

답변

0

비슷한 문제가 발생하여이를 해결하는 데 많은 시간을 보냈습니다. 결국 RHEL7에서 작업하기 위해 다음 지침을 작성했습니다. 아마도 우분투를 사용하고 있으므로 아래의 제조법을 읽고 적절하게 변경하십시오. 도움이 될 수도 있습니다.

Setup: RHEL 7, Apache 2.4, Python3.5 
------------------------------------------------------------------------- 
1. mod_wsgi-------------------------------------------------------------- 
------------------------------------------------------------------------- 
See how I used my python3.5 interpreter to install mod_wsgi. 
wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.5.14.tar.gz 
tar -zxvf 4.5.14.tar.gz 
cd mod_wsgi-4.5.14 
./configure --with-python=/usr/bin/python3.5 
make 
make install 
chmod 755 /usr/lib64/httpd/modules/mod_wsgi.so 

------------------------------------------------------------------------- 
2. conf file------------------------------------------------------------- 
------------------------------------------------------------------------- 
My website conf file in /etc/httpd/conf.d dir 
portal.conf 

LoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so 
<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName portal 
    ServerAlias portal.com 
    DocumentRoot /var/www/html/portal/src/ 

    WSGIDaemonProcess portal python-path=/var/www/html/portal/src:/var/www/html/portal/venv/lib/python3.5/site-packages 
    WSGIApplicationGroup portal 
    WSGIScriptAlias//var/www/html/portal/src/portal/wsgi.py process-group=portal 

    <Directory /var/www/html/portal/src> 
    Require all granted 
    </Directory> 

    <Directory /var/www/html/portal/src/portal> 
    <Files wsgi.py> 
     Require all granted 
    </Files> 
    </Directory> 

    Alias /static /var/www/html/portal/src/static 
    <Directory /var/www/html/portal/src/static> 
    Require all granted 
    </Directory> 

    Alias /static /var/www/html/portal/src/templates 
    <Directory /var/www/html/portal/src/templates> 
    Require all granted 
    </Directory> 

    Alias /static /var/www/html/portal/src/media 
    <Directory /var/www/html/portal/src/media> 
    Require all granted 
    </Directory> 

</VirtualHost> 
------------------------------------------------------------------------- 
Correct permissions on /var/www/html/------------------------------------ 
------------------------------------------------------------------------- 
chgrp -R apache /var/www/html 
find /var/www/html -type d -exec chmod g+rx {} + 
find /var/www/html -type f -exec chmod g+r {} + 

chown -R user1 /var/www/html/ 
find /var/www/html -type d -exec chmod u+rwx {} + 
find /var/www/html -type f -exec chmod u+rw {} + 

find /var/www/html -type d -exec chmod g+s {} + 
+0

데몬 모드 프로세스와 함께 사용할 가상 환경을 지정할 때''python-path''를 사용하여''site-packages''를 참조하지 말고''python-home'' 옵션을 사용하여 가상 환경의 루트. mod_wsgi를 사용하여 가상 환경 설정에 대한 설명서를 읽으십시오. http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html –

+0

''WSGIApplicationGroup % {GLOBAL}''을 사용할 것을 권장합니다. 가능한 경우 사용중인 응용 프로그램 그룹의 하위 해석기를 사용하지 마십시오. –

+0

@GrahamDumpleton 입력 해 주셔서 감사합니다. – nomad

관련 문제