1

I have recently deployed my django application to my Linux CPanel-Shared hosting. After testing all works very well in development but soon after deploying, my application displays 404 Not Found pages every time a user tries to navigate to a URL (including the in-built Django Admin panel).

Here is my deployment website: https://covid19.africansurveyors.net

I contacted my hosting service provider to check for me where the problem could be but unfortunately it was not resolved as they mentioned about code error. So I then took my application to Heroku and managed to deploy.

The URL to the Heroku App which is still the same app is: https://covid19zwe.herokuapp.com/. The application works perfectly fine on Heroku, but fails to run well on CPanel Shared hosting.

I also checked the --tail of my server log files this is what came up.

App 2247037 output: wsgi = imp.load_source('wsgi', 'passenger_wsgi.py')
App 2247037 output:   File "/home/<my_username>/virtualenv/public_html/covid19.africansurveyors.net/3.7/lib64/python3.7/imp.py", line 169, in load_source
App 2247037 output:     
App 2247037 output: module = _exec(spec, sys.modules[name])
App 2247037 output:   File "<frozen importlib._bootstrap>", line 623, in _exec
App 2247037 output:   File "<frozen importlib._bootstrap>", line 568, in _init_module_attrs
App 2247037 output:   File "<frozen importlib._bootstrap>", line 409, in cached
App 2247037 output:   File "<frozen importlib._bootstrap_external>", line 372, in _get_cached
App 2247037 output:   File "<frozen importlib._bootstrap_external>", line 296, in cache_from_source
App 2247037 output: RecursionError
App 2247037 output: : maximum recursion depth exceeded while calling a Python object
App 2388434 output: /opt/passenger-5.3.7-9.el6.cloudlinux/src/helper-scripts/wsgi-loader.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
App 2388434 output:   import sys, os, io, re, imp, threading, signal, traceback, socket, select, struct, logging, errno
App 436449 output: /opt/passenger-5.3.7-9.el6.cloudlinux/src/helper-scripts/wsgi-loader.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
App 436449 output:   import sys, os, io, re, imp, threading, signal, traceback, socket, select, struct, logging, errno
App 439960 output: /opt/passenger-5.3.7-9.el6.cloudlinux/src/helper-scripts/wsgi-loader.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
App 439960 output:   import sys, os, io, re, imp, threading, signal, traceback, socket, select, struct, logging, errno

I have configured the WSGI also in the passenger_wsgi.py file this way

import os
import sys
from covid.wsgi import application

Where my apps name is covid

I am not sure what really is going on. If anyone could assist I would really appreciate.

Surveyor Jr
  • 346
  • 2
  • 12
  • Same problem here, did you find any solution to this issue? – Benjamin Caure Nov 29 '21 at 14:14
  • Hi @BenjaminCaure, I am now deploying much of my Django applications to Heroku and then map the domains to my website. I figured the Heroku logs are much easier to follow and debug than the Cpanel ones. If you are using shared hosting the issue becomes worse. I recommend domain mapping. – Surveyor Jr Nov 30 '21 at 15:05
  • 1
    Thanks Surveyor Jr for your answer! in the meantime I was able to resolve my own problem with a support ticket to activate passenger debug mode. For the ones who read this, my issue was that I was following this answer https://stackoverflow.com/a/8663119/3580357 to include sys path, which involved an infinite recursion only on the hosting server. – Benjamin Caure Nov 30 '21 at 15:51

1 Answers1

0

I encountered the same issue then resolve it like this.

passenger_wsgi.py

from flask_app import app as application

flask_app.py

from flask import Flask
from werkzeug.middleware.proxy_fix import ProxyFix
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app)
app.config.from_pyfile("config/settings.py")
init_app(app)

CPanel config:

  • Application root: <root_app_dir>
  • Application startup file: passenger_wsgi.py
  • Application Entry point: flask_app
  • Passenger log file: <root_dir>/passenger.logs
Benjamin Caure
  • 2,090
  • 20
  • 27