I'm new to Apache2, so bear with me.
I followed this tutorial to get HTTPS working with a Flask server.
I keep getting the same output when I run the apache2
command:
[Wed Nov 28 01:42:32.210442 2018] [core:warn] [pid 1184] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Wed Nov 28 01:42:32.210921 2018] [core:warn] [pid 1184] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Wed Nov 28 01:42:32.211029 2018] [core:warn] [pid 1184] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Wed Nov 28 01:42:32.211138 2018] [core:warn] [pid 1184] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Wed Nov 28 01:42:32.219990 2018] [core:warn] [pid 1184:tid 139772922629056] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
[Wed Nov 28 01:42:32.220662 2018] [core:warn] [pid 1184:tid 139772922629056] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Wed Nov 28 01:42:32.221009 2018] [core:warn] [pid 1184:tid 139772922629056] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Wed Nov 28 01:42:32.221106 2018] [core:warn] [pid 1184:tid 139772922629056] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Wed Nov 28 01:42:32.221304 2018] [core:warn] [pid 1184:tid 139772922629056] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Wed Nov 28 01:42:32.221421 2018] [core:warn] [pid 1184:tid 139772922629056] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Wed Nov 28 01:42:32.221710 2018] [core:warn] [pid 1184:tid 139772922629056] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Wed Nov 28 01:42:32.221808 2018] [core:warn] [pid 1184:tid 139772922629056] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00543: apache2: bad user name ${APACHE_RUN_USER}
I've tried multiple other StackOverflow, AskUbuntu, and ServerFault questions, and none of them have helped. I'm stuck and I don't know what to do. I will edit the question to what is needed from other people (such as code or something from a conf file)
Any and all help is appreciated.
EDIT: I went to the unsecure (not-https) IP and I got the generic Apache "It works!" page. If I go to the secure (https) domain, I get a 500 Internal Server Error.
EDIT2: Here is my current VirtualHost file:
<VirtualHost *:80>
ServerName xerix.me
ServerAlias www.xerix.me
ServerAdmin [email protected]
WSGIScriptAlias / /var/www/cf/cf.wsgi
<Directory /var/www/cf/cf/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/cf/cf/static
<Directory /var/www/cf/cf/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =xerix.me [OR]
RewriteCond %{SERVER_NAME} =www.xerix.me
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
EDIT3:
Nov 28 01:50:34 xerix systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit apache2.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit apache2.service has begun starting up.
Nov 28 01:50:34 xerix systemd[1]: Started The Apache HTTP Server.
-- Subject: Unit apache2.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit apache2.service has finished starting up.
--
-- The start-up result is RESULT.
EDIT4:
[Wed Nov 28 02:43:15.319965 2018] [wsgi:error] [pid 2078:tid 139635571181312] [client :40218] Traceback (most recent call last):, referer: https://xerix.me/
[Wed Nov 28 02:43:15.320002 2018] [wsgi:error] [pid 2078:tid 139635571181312] [client :40218] File "/var/www/cf/cf.wsgi", line 7, in <module>, referer: https://xerix.me/
[Wed Nov 28 02:43:15.320215 2018] [wsgi:error] [pid 2078:tid 139635571181312] [client :40218] from cf import app as application, referer: https://xerix.me/
[Wed Nov 28 02:43:15.320252 2018] [wsgi:error] [pid 2078:tid 139635571181312] [client :40218] ImportError: cannot import name app, referer: https://xerix.me/
Thanks!
It should be started as root using
systemctl
under Debian/Ubuntu.It can also be started (system wide) using
/etc/init.d/apache2
(AKA the olderservice
command) under Debian/Ubuntu, but your best bet is using systemctl / systemd these days:See the systemctl man page for more.
If you insist on running it as a non-root user, >at minimum< you need to source the environment first.
For instance:
Should give you proper output (shows version and MPM running).
Sourcing the Apache variables before running the command allows proper reading/writing/parsing of needed Apache file/dir location data.
NOTE: Most flags such as
apache2 -M
(module list) will parse the Apache configuration file and site file(s). If a file/folder is read restricted to root, then you will get an error running as non-root. You will need to use the Apache variables along with thesudo
command. (-V
does not parse configs - normal user works fine normally). See comments and https://serverfault.com/a/416613/92023NOTE: You must run as root user for web service on port 80/443. Please refer to this answer for the why.
Starting it as a daemon/web service (as root user without init script) using the
apache2
command should also work as long as current running environment is sourced first. I can't think of a good reason to ever do this. Starting it as a background service using systemctl avoids all this.