Search code examples
djangoapachemod-wsgiubuntu-server

Deployment Django using Apache and mod_wsgi on Remote Ubuntu Server


I'm trying to deploy my Django Project on Remote Ubuntu server with IP address: my.rm.ip.ad. And project on the Server is located at path /path/to/project. I have configured ports.conf, hosts, wsgi.py (of my Django Project) and added a website called "mywebsite" under sites-available directory and enabled it as follows.

However, I'm getting "connection refused error" when I try to connect to my.rm.ip.ad:80 . Since the port 80 looks like open, I want to ask that, where am I wrong?

Thanks in advance.

Here is my /etc/apache2/ports.conf file:

Listen 80

<IfModule ssl_module>
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
 </IfModule>

And my /etc/apache2/sites-available/mysite.conf file:

<VirtualHost my.rm.ip.ad:80>
ServerAdmin [email protected]
ServerName  my.rm.ip.ad
ServerAlias http://my.rm.ip.ad
<Directory /path/to/project/ >
        Order deny,allow
        Allow from all
</Directory>
WSGIScriptAlias /  /path/to/project/foo/foo/wsgi.py
WSGIDaemonProcess  my.rm.ip.ad user=www-data group=www-data threads=25 python-path=/path/to/project/foo/foo/:/usr
WSGIProcessGroup my.rm.ip.ad
ErrorLog /path/to/project/foo/foo/error.log
</VirtualHost>

And I've added following line to /etc/hosts file:

my.rm.ip.ad my.rm.ip.ad

Lastly, here is wsgi.py file of my Django Project:

import os
import sys

sys.path.append('/path/to/project')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Where am I wrong?

Thanks again.


Solution

  • For ones who faced with same problem, even if it looks like listening 80th port, I suggest to ask service provider whether the port is open to worldwide or not.

    My port was closed. Thus, I've faced with that kind of problem.