0

I'v followed this tutorial which is recommended by various tutorial to deploy Django.

https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04

This is the content of my 000-default.conf file ..

UPDATED ".conf" file

<VirtualHost *:80>

 Alias /static /home/myproject/static
<Directory /home/myproject/static>
    Require all granted
</Directory>

<Directory /home/myproject/myproject>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess myproject python-home=/home/myproject/myprojectenv python-path=/home/myproject/myprojectenv/lib/python2.7/site-packages
WSGIProcessGroup myproject
WSGIScriptAlias / /home/myproject/myproject/wsgi.py

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html



    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

This is my first experience to deploy Django web-app on VPS which is equipped with "ubuntu-16.04-64bit".

I am able to fetch "myproject" Django app while virtualenv is activated and with Django default server like this:

./manage.py runserver 0.0.0.0:8000

and able to successfully open myproject app with my_ip, which is represented by "xx.xxx.xxx.xx" and port 8000.

http://xx.xxx.xxx.xx:8000

While, after deactivating the virtualenv and configuring the apache2 server as described by given tutorial its not working.

As tutorial says, after successful installation and configuring your Django app on server it should work only with your IP like this:

http://xx.xxx.xxx.xx 

Which is not working in my case rather its showing "Waiting for xx.xxx.xxx.xx...." for infinity on browser.. and page shows error like this..

This site can’t be reached

xx.xxx.xxx.63 refused to connect.
Search Google for 188 167 8000
ERR_CONNECTION_REFUSED

And also its not producing any log for apache2

ErrorLog /home/error.log
CustomLog /home/access.log combined

I am struggling since morning but not succeeded please help...

UPDATE

Apache2 error log:

   [Thu Nov 09 03:38:23.800566 2017] [core:warn] [pid 8823:tid 140238720010112] AH00045: child process 8827 still did not exit, sending a SIGTERM
[Thu Nov 09 03:38:25.802552 2017] [core:warn] [pid 8823:tid 140238720010112] AH00045: child process 8827 still did not exit, sending a SIGTERM
[Thu Nov 09 03:38:27.804431 2017] [core:warn] [pid 8823:tid 140238720010112] AH00045: child process 8827 still did not exit, sending a SIGTERM
[Thu Nov 09 03:38:29.805890 2017] [core:error] [pid 8823:tid 140238720010112] AH00046: child process 8827 still did not exit, sending a SIGKILL
[Thu Nov 09 03:38:30.806571 2017] [mpm_event:notice] [pid 8823:tid 140238720010112] AH00491: caught SIGTERM, shutting down
[Thu Nov 09 03:38:31.551724 2017] [mpm_event:notice] [pid 8960:tid 140082895366016] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Thu Nov 09 03:38:31.551837 2017] [core:notice] [pid 8960:tid 140082895366016] AH00094: Command line: '/usr/sbin/apache2'
ImportError: No module named site
ImportError: No module named site
ImportError: No module named site
ImportError: No module named site


ImportError: No module named site

this is my "wsgi.py" content

"""
WSGI config for myproject project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

application = get_wsgi_application()
jax
  • 3,927
  • 7
  • 41
  • 70

1 Answers1

0

For how to setup mod_wsgi with a virtual environment correctly, see:

Your problem with ImportError: No module named site looks like you mod_wsgi may not be compiled for the same Python version you want to use. See:

as it is a variation on that problem.

Go through all the installation checks in:

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • thanks there is one problem that I have found with this documents is that "sys.prefix" says install python path is '/usr' instead of '/usr/local' – jax Nov 09 '17 at 05:24
  • The value of ``sys.prefix`` will be different depending on whether you are using system Python, Python you installed yourself, or want to link it to a virtual environment. Set ``WSGIPythonHome`` or ``python-home`` based on ``sys.prefix`` as your Python shows, not what the docs give as an example. – Graham Dumpleton Nov 09 '17 at 06:05
  • I really don't get it what you want to say.. You mn to say I have to set python-home as python-home=/usr, because this is what sys.prefix command tell me about the system python installation path – jax Nov 09 '17 at 06:21
  • Your comment wasn't clear to begin with so didn't know what you are asking or trying to point out. I could only restate what the documentation effectively says. The case of ``sys.prefix`` being ``/usr`` is a special case as it indicates it is the system Python version. In that case, you can usually skip setting it because the Python interpreter initialisation will find the system Python first usually, but it is still recommended if you have multiple Python installations of the same version installed in different locations. – Graham Dumpleton Nov 09 '17 at 07:02
  • Can you explain better what you were saying is a problem. Are you saying you think the documentation is wrong? – Graham Dumpleton Nov 09 '17 at 07:03
  • Hahahahaha @Graham, l I am not saying that document is incorrect. I don't have this much knowledge to declare these documents wrong. I just said I'din't get your point in earlier comment so just trying to clarify. – jax Nov 09 '17 at 07:13