Hello Graham, et al. First, thank you for being an outstanding contributor to the community. This is my first attempt to set up a VM for a pretty old legacy project, and I am very new to devops in general, so thank you in advance for your patience! I'm working to move an old Django/Apache project off of Vagrant into Docker containers. I was able to get it working when using Python's built-in runserver, but I've been stuck for far too long now trying to get it to work with Apache. From what I can tell from the docs, etc it seems that my mod-wsgi version is struggling with Django 1.7 (I'm making a case with management to upgrade, but so far it's not in the budget). I also think that I'm incorrectly setting my paths, but my multiple attempts to correct this have come up empty. Needless to say, there's where I am now.
I'm running docker on a Mac os Sierra Version 10.12.6 *Container versions: * Django: 1.7.0 Apache: 2.4.7 Python: 2.7.6 mod-wsgi: 3.4 Ubuntu OS: 14.04 ***** Dockerfile ****** * FROM ubuntu:14.04 RUN apt-get update RUN apt-get upgrade -y RUN apt-get install -y apt-utils apache2 apache2-utils RUN apt-get install -y \ pkg-config \ python-pip \ python2.7-dev \ build-essential \ python2.7 \ libmysqlclient-dev \ && apt-get autoremove \ && apt-get clean WORKDIR /var/www/configurator ADD requirements /var/www/configurator/requirements RUN pip install --upgrade pip RUN pip install -r requirements/dev.txt RUN pip install django ENV PYTHONPATH $PYTHONPATH:/var/www/configurator ENV DJANGO_SETTINGS_MODULE scs-configurator.settings.dev ADD ./apache.conf /etc/apache2/sites-available/000-default.conf ADD ./apache.conf /etc/apache2/sites-enabled/000-default.conf EXPOSE 80 3500 CMD ["apache2ctl", "-D", "FOREGROUND"] ------------------------------------------------------------------------- ****** docker-compose.yml ******** version: '2' services: mysql: image: mysql volumes: - "./.data/mysql:/var/lib/mysql" ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: configuratordb restart: always django-apache2: build: . container_name: django-apache2 ports: - '8005:80' volumes: - ".:/var/www/configurator" depends_on: - mysql restart: always --------------------------------------------------------------------------- ****** apache.conf ******** WSGIPythonPath /var/www/configurator <VirtualHost *:80> ServerName configurator DocumentRoot /var/www/configurator/dist <Directory /var/www/configurator> Options -Indexes +FollowSymLinks AllowOverride all Require all granted </Directory> ServerAdmin webmaster@localhost DocumentRoot /var/www/configurator Alias /static /var/www/configurator/dist SetEnv APPLICATION_ENV dev WSGIDaemonProcess scs-configurator python-path=/var/www/configurator/:/usr/local/lib/python2.7/site-packages WSGIProcessGroup scs-configurator WSGIScriptAlias / /var/www/configurator/apache/backend-dev.wsgi </VirtualHost> ------------------------------------------------------------------------------ ****** **backend-dev.wsgi** ******** import os, sys from django.core.wsgi import get_wsgi_application import backend.monitor sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '../../' ) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.dev") print ('sys.version: ') print (sys.version) print ('sys.path: ') print (sys.path) os.environ['APPLICATION_ENV'] = 'dev' os.environ['PGCONNECT_TIMEOUT'] = '20' _application = get_wsgi_application() def application(wsgi_environ, start_response): return _application(wsgi_environ, start_response) backend.monitor.start(interval=1.0) ------------------------------------------------------------------------------ This set up gives me a 500 Internal Server error after the container is built and up. When I investigate the containers Apache error.log file I get the following output: root@95937636bd2f:/var/www/configurator# cat /var/log/apache2/error.log AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.25.0.3. Set the 'ServerName' directive globally to suppress this message [Thu Nov 02 22:37:12.934167 2017] [mpm_event:notice] [pid 6:tid 140568651089792] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations [Thu Nov 02 22:37:12.934299 2017] [core:notice] [pid 6:tid 140568651089792] AH00094: Command line: '/usr/sbin/apache2 -D FOREGROUND' [Thu Nov 02 22:37:31.647113 2017] [:error] [pid 7:tid 140568547739392] sys.version: [Thu Nov 02 22:37:31.647242 2017] [:error] [pid 7:tid 140568547739392] 2.7.6 (default, Oct 26 2016, 20:33:43) [Thu Nov 02 22:37:31.647258 2017] [:error] [pid 7:tid 140568547739392] [GCC 4.8.4] [Thu Nov 02 22:37:31.647270 2017] [:error] [pid 7:tid 140568547739392] sys.path: [Thu Nov 02 22:37:31.647296 2017] [:error] [pid 7:tid 140568547739392] ['/var/www/configurator', '/usr/local/lib/python2.7/site-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/var/www/configurator/apache../../'] [Thu Nov 02 22:37:31.727120 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] mod_wsgi (pid=7): Target WSGI script '/var/www/configurator/apache/backend-dev.wsgi' cannot be loaded as Python module. [Thu Nov 02 22:37:31.727172 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] mod_wsgi (pid=7): Exception occurred processing WSGI script '/var/www/configurator/apache/backend-dev.wsgi'. [Thu Nov 02 22:37:31.727286 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] Traceback (most recent call last): [Thu Nov 02 22:37:31.727324 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/var/www/configurator/apache/backend-dev.wsgi", line 16, in <module> [Thu Nov 02 22:37:31.730468 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] _application = get_wsgi_application() [Thu Nov 02 22:37:31.730515 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application [Thu Nov 02 22:37:31.730595 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] django.setup() [Thu Nov 02 22:37:31.730612 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 20, in setup [Thu Nov 02 22:37:31.730654 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) [Thu Nov 02 22:37:31.730669 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 46, in __getattr__ [Thu Nov 02 22:37:31.730747 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] self._setup(name) [Thu Nov 02 22:37:31.730762 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup [Thu Nov 02 22:37:31.730783 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] self._wrapped = Settings(settings_module) [Thu Nov 02 22:37:31.730795 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 94, in __init__ [Thu Nov 02 22:37:31.730810 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] mod = importlib.import_module(self.SETTINGS_MODULE) [Thu Nov 02 22:37:31.730823 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module [Thu Nov 02 22:37:31.731533 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] __import__(name) [Thu Nov 02 22:37:31.731554 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/var/www/configurator/settings/dev.py", line 46, in <module> [Thu Nov 02 22:37:31.735029 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] GIT_REVISION = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], cwd=DJANGO_ROOT).rstrip() [Thu Nov 02 22:37:31.735087 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/usr/lib/python2.7/subprocess.py", line 566, in check_output [Thu Nov 02 22:37:31.735638 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] process = Popen(stdout=PIPE, *popenargs, **kwargs) [Thu Nov 02 22:37:31.735673 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/usr/lib/python2.7/subprocess.py", line 710, in __init__ [Thu Nov 02 22:37:31.735710 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] errread, errwrite) [Thu Nov 02 22:37:31.735722 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child [Thu Nov 02 22:37:31.735739 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] raise child_exception [Thu Nov 02 22:37:31.735764 2017] [:error] [pid 7:tid 140568547739392] [remote 172.25.0.1:30896] OSError: [Errno 2] No such file or directory Any and all suggestions for how to move forward at this time are most welcome! -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+unsubscr...@googlegroups.com. To post to this group, send email to modwsgi@googlegroups.com. Visit this group at https://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.