简体   繁体   中英

Django Internal Server Error when accessing the website

I have hosted my Django website on a Linux machine. I have also granted all the required permissions to my project directory. But when I am trying to access the website from my browser I am getting an error

    Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.29 (Ubuntu) Server at li1988-26.members.linode.com Port 80

on the page.

This is my project structure

/var/www/Intranet/

├── db.sqlite3
├── Intranet
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-36.pyc
│   │   ├── settings.cpython-36.pyc
│   │   ├── urls.cpython-36.pyc
│   │   └── wsgi.cpython-36.pyc
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── mainapp
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       └── __init__.cpython-36.pyc
│   ├── models.py
│   ├── __pycache__
│   │   ├── admin.cpython-36.pyc
│   │   ├── __init__.cpython-36.pyc
│   │   ├── models.cpython-36.pyc
│   │   ├── urls.cpython-36.pyc
│   │   └── views.cpython-36.pyc
│   ├── static
│   │   └── mainapp
│   │       ├── css
│   │       │   └── base.css
│   │       └── js
│   │           └── base.js
│   ├── templates
│   │   └── mainapp
│   │       ├── base.html
│   │       └── homepage.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── manage.py
├── media
│   └── users
│       └── images
│           └── default.jpg
├── static
│   ├── admin
│   └── mainapp
│       ├── css
│       │   └── base.css
│       └── js
│           └── base.js
└── users
    ├── admin.py
    ├── apps.py
    ├── __init__.py
    ├── migrations
    │   ├── 0001_initial.py
    │   ├── __init__.py
    │   └── __pycache__
    │       ├── 0001_initial.cpython-36.pyc
    │       └── __init__.cpython-36.pyc
    ├── models.py
    ├── __pycache__
    │   ├── admin.cpython-36.pyc
    │   ├── __init__.cpython-36.pyc
    │   ├── models.cpython-36.pyc
    │   └── views.cpython-36.pyc
    ├── static
    ├── templates
    │   └── users
    │       ├── change_password.html
    │       ├── login.html
    │       ├── logout.html
    │       ├── password_change_done.html
    │       ├── password_reset_complete.html
    │       ├── password_reset_confirm.html
    │       ├── password_reset_done.html
    │       └── password_reset.html
    ├── tests.py
    └── views.py

This is my /etc/apache2/sites-available/000-default.conf :

<VirtualHost *:80>
ServerName li1988-26.members.linode.com

ErrorLog ${APACHE_LOG_DIR}/mysite-error.log
CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined

WSGIDaemonProcess mysite processes=2 threads=25 python-path=/var/www/Intranet
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/Intranet/Intranet/wsgi.py

Alias /robots.txt /var/www/Intranet/static/robots.txt
Alias /favicon.ico /var/www/Intranet/static/favicon.ico
Alias /static/ /var/www/Intranet/static/
Alias /static/ /var/www/Intranet/media/

<Directory /var/www/Intranet/Intranet>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

<Directory /var/www/Intranet/static>
    Require all granted
</Directory>

<Directory /var/www/Intranet/media>
    Require all granted
</Directory>

And then I issued the commands

a2ensite 000-default.conf
sudo service apache2 restart

The error log nano /var/log/apache2/error.log says

[Fri Oct 25 09:12:51.993097 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Fri Oct 25 09:12:51.993178 2019] [core:notice] [pid 16523:tid 140088200727488] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 25 09:18:42.041782 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00493: SIGUSR1 received.  Doing graceful restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
[Fri Oct 25 09:18:42.063081 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Fri Oct 25 09:18:42.063104 2019] [core:notice] [pid 16523:tid 140088200727488] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 25 09:22:13.165844 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00493: SIGUSR1 received.  Doing graceful restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
[Fri Oct 25 09:22:13.359270 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Fri Oct 25 09:22:13.359309 2019] [core:notice] [pid 16523:tid 140088200727488] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 25 09:22:48.864610 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00493: SIGUSR1 received.  Doing graceful restart

I have tried all the solutions that I was getting as suggestion to this question but none of them worked for me.

EDIT 2: Update Apache error log

   [Sat Oct 26 06:25:02.373002 2019] [mpm_event:notice] [pid 22161:tid 139856591948736] AH00489: Apache/2.4.29 (Ubuntu) mo$[Sat Oct 26 06:25:02.373042 2019] [core:notice] [pid 22161:tid 139856591948736] AH00094: Command line: '/usr/sbin/apach$
   [Sat Oct 26 19:46:25.042037 2019] [mpm_event:notice] [pid 22161:tid 139856591948736] AH00491: caught SIGTERM, shutting $
   [Sat Oct 26 19:46:25.116742 2019] [mpm_event:notice] [pid 25602:tid 140008539728832] AH00489: Apache/2.4.29 (Ubuntu) mo$
   [Sat Oct 26 19:46:25.116818 2019] [core:notice] [pid 25602:tid 140008539728832] AH00094: Command line: '/usr/sbin/apach$

After troubleshooting the issue together, it was the mod_wsgi that wasn't installed properly. just for future references

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM