I implemented a Django project with MySQL backend. It runs well using python manage.py runserver
.
Apache seems installed well with no errors. I can access the default apache server. However, I couldn't make the apache web server and Django work together.
I followed this guide: https://studygyaan.com/django/how-to-setup-django-applications-with-apache-and-mod-wsgi-on-ubuntu
I edited 000-default.conf
and djangoproject.conf
on the server.
Could you give me some advice where I should look into?
Version information: Python: 3.8.5 Django: 3.0 Ubnutu: 20.04
When I run sudo systemctl status apache2
:
● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2021-04-14 17:18:03 UTC; 6 days ago Docs: https://httpd.apache.org/docs/2.4/ Main PID: ****(apache2) Tasks: ** (limit: **) Memory: M CGroup: /system.slice/apache2.service ├─ **** /usr/sbin/apache2 -k start ├─ /usr/sbin/apache2 -k start └─ /usr/sbin/apache2 -k start
coopstudent1@margaret:/etc/apache2/sites-available$ sudo journalctl |tail
Apr 21 13:28:40 margaret wekan.wekan[3687675]: MONGO_URL=mongodb://127.0.0.1:27019/wekan
Apr 21 13:28:40 margaret audit[595227]: AVC apparmor="DENIED" operation="open" profile="snap.rocketchat-server.rocketchat-mongo" name="/proc/595227/net/netstat" pid=595227 comm="ftdc" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr 21 13:28:40 margaret audit[595227]: AVC apparmor="DENIED" operation="open" profile="snap.rocketchat-server.rocketchat-mongo" name="/proc/595227/net/snmp" pid=595227 comm="ftdc" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr 21 13:28:41 margaret sshd[3687660]: Connection closed by invalid user administrator 49.37.211.157 port 59445 [preauth]
Apr 21 13:28:41 margaret wekan.wekan[3688505]: (node:3688505) [DEP0131] DeprecationWarning: The legacy HTTP parser is deprecated.
Apr 21 13:28:41 margaret audit[595227]: AVC apparmor="DENIED" operation="open" profile="snap.rocketchat-server.rocketchat-mongo" name="/proc/595227/net/netstat" pid=595227 comm="ftdc" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr 21 13:28:41 margaret audit[595227]: AVC apparmor="DENIED" operation="open" profile="snap.rocketchat-server.rocketchat-mongo" name="/proc/595227/net/snmp" pid=595227 comm="ftdc" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr 21 13:28:42 margaret kernel: kauditd_printk_skb: 2 callbacks suppressed
Apr 21 13:28:42 margaret kernel: audit: type=1400 audit(1619011721.997:1184939): apparmor="DENIED" operation="open" profile="snap.rocketchat-server.rocketchat-mongo" name="/proc/595227/net/netstat" pid=595227 comm="ftdc" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr 21 13:28:42 margaret kernel: audit: type=1400 audit(1619011721.997:1184940): apparmor="DENIED" operation="open" profile="snap.rocketchat-server.rocketchat-mongo" name="/proc/595227/net/snmp" pid=595227 comm="ftdc" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
When I run the following, I got some warnings as below. I will work on it and get back here:
$ python manage.py check --deploy
System check identified some issues:
WARNINGS:
?: (security.W004) You have not set a value for the SECURE_HSTS_SECONDS setting. If your entire site is served only over SSL, you may want to consider setting a value and enabling HTTP Strict Transport Security. Be sure to read the documentation first; enabling HSTS carelessly can cause serious, irreversible problems.
?: (security.W008) Your SECURE_SSL_REDIRECT setting is not set to True. Unless your site should be available over both SSL and non-SSL connections, you may want to either set this setting True or configure a load balancer or reverse-proxy server to redirect all connections to HTTPS.
?: (security.W012) SESSION_COOKIE_SECURE is not set to True. Using a secure-only session cookie makes it more difficult for network traffic sniffers to hijack user sessions.
?: (security.W016) You have 'django.middleware.csrf.CsrfViewMiddleware' in your MIDDLEWARE, but you have not set CSRF_COOKIE_SECURE to True. Using a secure-only CSRF cookie makes it more difficult for network traffic sniffers to steal the CSRF token.
?: (security.W018) You should not have DEBUG set to True in deployment.
?: (security.W022) You have not set the SECURE_REFERRER_POLICY setting. Without this, your site will not send a Referrer-Policy header. You should consider enabling this header to protect user privacy.
Adding more contents. Now, the issue seems not in Django/Apache but in something else such as rocket.chat. Any advice?
coopstudent1@margaret:/etc/apache2/sites-enabled$ sudo journalctl | tail
Apr 22 03:41:19 margaret wekan.wekan[935586]: ORACLE_OIM_ENABLED=false (default value)
Apr 22 03:41:19 margaret wekan.wekan[935586]: RESULTS_PER_PAGE= (default value)
Apr 22 03:41:19 margaret wekan.wekan[935586]: MONGO_URL=mongodb://127.0.0.1:27019/wekan
Apr 22 03:41:19 margaret audit[595227]: AVC apparmor="DENIED" operation="open" profile="snap.rocketchat-server.rocketchat-mongo" name="/proc/595227/net/netstat" pid=595227 comm="ftdc" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr 22 03:41:20 margaret kernel: audit: type=1400 audit(1619062879.997:1287870): apparmor="DENIED" operation="open" profile="snap.rocketchat-server.rocketchat-mongo" name="/proc/595227/net/netstat" pid=595227 comm="ftdc" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr 22 03:41:20 margaret kernel: audit: type=1400 audit(1619062879.997:1287871):
apparmor="DENIED" operation="open" profile="snap.rocketchat-server.rocketchat-mongo" name="/proc/595227/net/snmp" pid=595227 comm="ftdc" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr 22 03:41:19 margaret audit[595227]: AVC apparmor="DENIED" operation="open" profile="snap.rocketchat-server.rocketchat-mongo" name="/proc/595227/net/snmp" pid=595227 comm="ftdc" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr 22 03:41:20 margaret wekan.wekan[936421]: (node:936421) [DEP0131] DeprecationWarning: The legacy HTTP parser is deprecated.
Apr 22 03:41:20 margaret sshd[936147]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=221.181.185.135 user=root
Apr 22 03:41:20 margaret wekan.wekan[936421]: Presence started serverId=RkY3MG5YjGkkwZbSw