I've just set up a testbed for migrating our site from managed, shared hosting to Digital Ocean. I built the service up, because I wanted to get what was going on. Currently, the django system works, and I can run the devserver mapped to 0.0.0.0:8000 and it serves content,but that's clearly not going to cut it for production though, and I want to make apache work. Currently working out of a virtualenv called 'env', imaginatively enough.
I've followed the Digital Ocean quick start for this, but suspect I'm falling foul of the need to know a bit more than it provides. Apache is there and installed, and operating correctly (at least initially) - when I access the root IP for the droplet, I get the 'It works!' message. So, both bits work, but when I come to modify nano /etc/apache2/sites-enabled/000-default
and restart, I get the message that:
Syntax error on line 2 of /etc/apache2/sites-enabled/000-default:
Invalid command 'WSGIDaemonProcess', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
failed!
So it's failing at the first line of the following config(both paths are correct):
WSGIDaemonProcess processname python-path=/var/www/path/tosite:/var/www/env/lib/python2.7/site-packages
WSGIProcessGroup processname
WSGIScriptAlias / /var/www/path/to/project/wsgi.py
The Traceback that I was getting originally was this:
[Tue Dec 02 13:47:48 2014] [notice] Apache/2.2.22 (Debian) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Tue Dec 02 13:47:50 2014] [error] [clientIP] mod_wsgi (pid=18936): Target WSGI script '/var/www/project/projectv2/projectv2/wsgi.py' cannot be loaded as Python module.
[Tue Dec 02 13:47:50 2014] [error] [clientIP] mod_wsgi (pid=18936): Exception occurred processing WSGI script '/var/www/project/projectv2/projectv2/wsgi.py'.
[Tue Dec 02 13:47:50 2014] [error] [clientIP] Traceback (most recent call last):
[Tue Dec 02 13:47:50 2014] [error] [clientIP] File "/var/www/project/projectv2/projectv2/wsgi.py", line 15, in <module>
[Tue Dec 02 13:47:50 2014] [error] [clientIP] from django.core.wsgi import get_wsgi_application
[Tue Dec 02 13:47:50 2014] [error] [clientIP] ImportError: No module named django.core.wsgi
[Tue Dec 02 13:47:51 2014] [error] [clientIP] mod_wsgi (pid=18936): Target WSGI script '/var/www/project/projectv2/projectv2/wsgi.py' cannot be loaded as Python module.
[Tue Dec 02 13:47:51 2014] [error] [clientIP] mod_wsgi (pid=18936): Exception occurred processing WSGI script '/var/www/project/projectv2/projectv2/wsgi.py'.
[Tue Dec 02 13:47:51 2014] [error] [clientIP] Traceback (most recent call last):
[Tue Dec 02 13:47:51 2014] [error] [clientIP] File "/var/www/project/projectv2/projectv2/wsgi.py", line 15, in <module>
[Tue Dec 02 13:47:51 2014] [error] [clientIP] from django.core.wsgi import get_wsgi_application
[Tue Dec 02 13:47:51 2014] [error] [clientIP] ImportError: No module named django.core.wsgi
[Tue Dec 02 13:47:51 2014] [error] [clientIP] mod_wsgi (pid=18936): Target WSGI script '/var/www/project/projectv2/projectv2/wsgi.py' cannot be loaded as Python module.
[Tue Dec 02 13:47:51 2014] [error] [clientIP] mod_wsgi (pid=18936): Exception occurred processing WSGI script '/var/www/project/projectv2/projectv2/wsgi.py'.
[Tue Dec 02 13:47:51 2014] [error] [clientIP] Traceback (most recent call last):
[Tue Dec 02 13:47:51 2014] [error] [clientIP] File "/var/www/project/projectv2/projectv2/wsgi.py", line 15, in <module>
[Tue Dec 02 13:47:51 2014] [error] [clientIP] from django.core.wsgi import get_wsgi_application
[Tue Dec 02 13:47:51 2014] [error] [clientIP] ImportError: No module named django.core.wsgi
I tried this very helpful answer, but it didn't seem to make any difference; one key thing is that I now can't reset the apache server as I normally would, as it won't start - so I'm uncertain if my changes are taking effect.
I also removed and reinstalled mod_wsgi to see if that was the problem, reinstalling with apt-get install libapache2-mod-wsgi
, and tried chmod 755 the wsgi.py file.
As an aside - all of the versions of apache i've used before have had an httpd.conf file, but this doesn't seem to have one - running ps -ef | grep apache just shows the error log and the 000-default mentioned above.
Full default-000 is:
<VirtualHost *:80>
WSGIDaemonProcess project python-path=/var/www/project/projectv2:/var/www/env/lib/python2.7/site$
WSGIProcessGroup project
WSGIScriptAlias / /var/www/project/projectv2/projectv2/wsgi.py
ServerAdmin system@project.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Similarly, i'm not using mod_python (as per Graeme's comment on the main question, and I can import django.core.wsgi manually in the shell.