简体   繁体   中英

Wagtail deployment on Centos7

I could really use some help here. I am in the process of setting up a test deployment of wagtail on a CentOS7 box and it seems as though the wsgi daemon is not getting access to the necessary python modules. I have checked permissions on all of the directories in the virtual environment and made sure that the owner was apache as well as the group owner was apache (recursively). SELinux is also in permissive mode while I'm trying to figure this out. It's a fresh install of wagtail, no modifications have been made after running the start command from wagtail.

My virtual host config file is as follows:

<VirtualHost *:80>
ServerName <server.name>
ServerAdmin <server.admin>
Alias /static /var/www/<virtual.env>/<project.name>/static
<Directory /var/www/<virtual.env>/<project.name>/static>
    Require all granted
</Directory>
<Directory /var/www/<virtual.env>/<project.name>/wsgi.py>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>
WSGIDaemonProcess <project> python-path=/var/www/<virtual.env>/<project.name>/<project.name>:/var/www/<virtual.env/lib/python3.4/site-packages
WSGIProcessGroup <project>
WSGIScriptAlias / /var/www/<project.env>/<project.name>/<project.name>/wsgi.py

ErrorLog /var/log/httpd/<project.name>_error.log
CustomLog /var/log/httpd/<project.name>_access.log combined

My project_error.log file contains the following:

[Thu May 04 18:50:35.596691 2017] [:error] [pid 13101] [remote 10.30.112.49:52] mod_wsgi (pid=13101): Exception occurred processing WSGI script '/var/www/<project.name>_env/<project.name>/<project.name>/wsgi.py'.
[Thu May 04 18:50:35.596712 2017] [:error] [pid 13101] [remote 10.30.112.49:52] Traceback (most recent call last):
[Thu May 04 18:50:35.596733 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/<project.name>/<project.name>/wsgi.py", line 18, in <module>
[Thu May 04 18:50:35.596785 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     application = get_wsgi_application()
[Thu May 04 18:50:35.596797 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Thu May 04 18:50:35.596836 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     django.setup(set_prefix=False)
[Thu May 04 18:50:35.596846 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/django/__init__.py", line 27, in setup
[Thu May 04 18:50:35.596887 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     apps.populate(settings.INSTALLED_APPS)
[Thu May 04 18:50:35.596898 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
[Thu May 04 18:50:35.597029 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     app_config.import_models(all_models)
[Thu May 04 18:50:35.597039 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/django/apps/config.py", line 199, in import_models
[Thu May 04 18:50:35.597118 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     self.models_module = import_module(models_module_name)
[Thu May 04 18:50:35.597131 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Thu May 04 18:50:35.597177 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     __import__(name)
[Thu May 04 18:50:35.597187 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/wagtail/wagtailforms/models.py", line 16, in <module>
[Thu May 04 18:50:35.597283 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     from wagtail.wagtailadmin.edit_handlers import FieldPanel
[Thu May 04 18:50:35.597292 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 19, in <module>
[Thu May 04 18:50:35.597493 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     from wagtail.wagtailadmin import compare, widgets
[Thu May 04 18:50:35.597503 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/wagtail/wagtailadmin/compare.py", line 5, in <module>
[Thu May 04 18:50:35.597660 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     from bs4 import BeautifulSoup
[Thu May 04 18:50:35.597673 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/bs4/__init__.py", line 35, in <module>
[Thu May 04 18:50:35.597822 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     from .builder import builder_registry, ParserRejectedMarkup
[Thu May 04 18:50:35.597832 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/bs4/builder/__init__.py", line 7, in <module>
[Thu May 04 18:50:35.597933 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     from bs4.element import (
[Thu May 04 18:50:35.597943 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/bs4/element.py", line 10, in <module>
[Thu May 04 18:50:35.598337 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     from bs4.dammit import EntitySubstitution
[Thu May 04 18:50:35.598347 2017] [:error] [pid 13101] [remote 10.30.112.49:52]   File "/var/www/<project.name>_env/lib/python3.4/site-packages/bs4/dammit.py", line 14, in <module>
[Thu May 04 18:50:35.598548 2017] [:error] [pid 13101] [remote 10.30.112.49:52]     from html.entities import codepoint2name
[Thu May 04 18:50:35.598565 2017] [:error] [pid 13101] [remote 10.30.112.49:52] ImportError: No module named html.entities

Huge thanks in advance.

Two things I noticed. <Directory /var/www/<virtual.env>/<project.name>/wsgi.py> should point to the directory <Directory /var/www/<virtual.env>/<project.name>/ , not the file itself. Also, mod_wsgi needs to be compiled against the same version of Python you developed against, as @gasman mentioned.

If you want to upgrade to Python 3.5 and install mod_wsgi from the IUS repository:

sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
sudo yum install python35u python35u-pip python35u-devel python35u-mod_wsgi

Good luck!

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