Cpanel Upload

49 views
Skip to first unread message

Lenny

unread,
Oct 25, 2024, 12:04:46 PM (3 days ago) Oct 25
to django...@googlegroups.com
Hey, any of you ever hosted a website on cpanel? If so what process did you use? I tried uploading the django website code, creating the python app and installing dependencies but the site seems not to run unless Debug is True. I get a server error 500 when Debug is False. I followed this tutorial https://geekydocs.com/blog/deploying-your-django-application-in-cpanel and still get the error. Kindly help.

Aatish G Nair

unread,
Oct 25, 2024, 12:18:20 PM (3 days ago) Oct 25
to django...@googlegroups.com
Yes, I’ve  used cPanel deployments. A 500 error usually happens because of:  

Please check allowed host , collect static

WSGI Path kindly Ensure the WSGI file has the correct Django project path.

Let me know if any of these solve it!

If not please check with debug= true. Possible some error in the code.

On Fri, 25 Oct 2024, 21:34 Lenny, <veryl...@gmail.com> wrote:
Hey, any of you ever hosted a website on cpanel? If so what process did you use? I tried uploading the django website code, creating the python app and installing dependencies but the site seems not to run unless Debug is True. I get a server error 500 when Debug is False. I followed this tutorial https://geekydocs.com/blog/deploying-your-django-application-in-cpanel and still get the error. Kindly help.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/CAE1sx0K%3D3EGGEBN4FyZkb2N8z4eRsd478%3D%2BWSmDs%2Bvg%2BAm90dg%40mail.gmail.com.

Lenny

unread,
Oct 25, 2024, 2:21:28 PM (3 days ago) Oct 25
to django...@googlegroups.com
Yes i tried all that but there seems to be no change. The cpanel is provided by a hosting company so i have very limited access to the machine. When i create a python app it automatically generate a passenger_wsgi in the project folder. I tried following various tutorials online but they are limited and none of them worked for me.

Lenny

unread,
Oct 25, 2024, 2:22:07 PM (3 days ago) Oct 25
to django...@googlegroups.com
Would you have any advice on setting up with passenger_wsgi.py


On Fri, 25 Oct 2024 at 19:17, Aatish G Nair <aatis...@gmail.com> wrote:

Habeeb Lasisi

unread,
Oct 25, 2024, 5:07:02 PM (2 days ago) Oct 25
to django...@googlegroups.com

Aatish G Nair

unread,
Oct 25, 2024, 11:11:36 PM (2 days ago) Oct 25
to django...@googlegroups.com
So have you updated passenger_wsgi please connect to our django project WSGI 

Ryan Nowakowski

unread,
Oct 26, 2024, 12:03:21 PM (2 days ago) Oct 26
to django...@googlegroups.com

maina patrick

unread,
Oct 27, 2024, 2:39:38 PM (14 hours ago) Oct 27
to django...@googlegroups.com

To successfully host a Django website on cPanel and troubleshoot the 500 error occurring when DEBUG is set to False, here’s a comprehensive guide:

Step 1: Prepare Django Project for Deployment

  1. Settings Adjustment:

    • In your settings.py file, set DEBUG = False for production.
    • Add your domain to the ALLOWED_HOSTS list, like this:
      python
      ALLOWED_HOSTS = ['yourdomain.com', 'www.yourdomain.com']
  2. Static Files Configuration:

    • Set up the STATIC_ROOT for static files. For example:
      python
      STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    • Run python manage.py collectstatic to gather all static files into the STATIC_ROOT directory.

Step 2: Compress and Upload Your Project

  1. Compress the Project Folder:
    • Zip your Django project files to simplify the upload.
  2. Upload the Zip File:
    • Go to File Manager in cPanel, navigate to the root of your domain, and upload the zipped project.
    • Extract the zip file.

Step 3: Create a Python App in cPanel

  1. Go to Setup Python App in cPanel.
  2. Set the Python Version (typically Python 3.7 or later).
  3. Select the Project Directory where you uploaded your files.
  4. Configure the Virtual Environment:
    • Set up the virtual environment by pointing to the folder where manage.py is located.
  5. Install Dependencies:
    • Click Enter to the virtual environment.
    • Run pip install -r requirements.txt to install your project dependencies.

Step 4: Configure Environment Variables

  1. Go to the Environment Variables section in your Python App settings.
  2. Set environment variables for DJANGO_SETTINGS_MODULE:
    plaintext
    DJANGO_SETTINGS_MODULE=yourproject.settings
  3. If you’re using a secret key, add it as well:
    plaintext
    SECRET_KEY=your_secret_key

Step 5: Set Up Database Settings

  1. Configure the database in settings.py to use the production database (if not using SQLite).
  2. Ensure that the database credentials are correct and accessible in the cPanel environment.

Step 6: Check Permissions

Ensure that all files and folders have the correct permissions:

  • Files: 644
  • Folders: 755

Step 7: Adjust Allowed Hosts and Error Handling

  1. Test ALLOWED_HOSTS:
    • Make sure your domain is added to ALLOWED_HOSTS.
  2. Configure Logging in settings.py to catch errors:
    python
    LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'file': { 'level': 'ERROR', 'class': 'logging.FileHandler', 'filename': os.path.join(BASE_DIR, 'error.log'), }, }, 'loggers': { 'django': { 'handlers': ['file'], 'level': 'ERROR', 'propagate': True, }, }, }
  3. Check the Error Log:
    • In cPanel, go to Errors under Metrics to see server logs.
    • Look in error.log in your project directory to identify specific errors.

Step 8: Test and Debug

  1. Restart the Python app in cPanel.
  2. Access the site with DEBUG = False and check if it runs smoothly.
  3. If the 500 error persists, inspect logs and address any misconfigurations.

This should help troubleshoot and resolve the issue on cPanel with DEBUG set to False




if the error persists let me know , happy to help
 

Lenny

unread,
Oct 27, 2024, 2:45:36 PM (14 hours ago) Oct 27
to django...@googlegroups.com
Thanks alot for your help devs

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages