I have an apache2 web server for testing only (not a production server). It is running on Ubuntu 18.04. I have configured it with TLS. I want to add a header. So I navigated to this file: /etc/apache2/sites-available/default-ssl.conf
The file content now is:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin hi@myownsite.com
ServerName myownsite.com
DocumentRoot /var/www/myownsite.com/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# SSL Engine Switch:
SSLEngine on
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
Header always set Expect-CT: max-age=86400, enforce, report-uri="https://myownserver.com/report"
</VirtualHost>
</IfModule>
As you can see, at the end I added the header which I want to see in the server's response when the client open the site in https://
However, after I add the header in the .conf file, and want to reload apache to make the change effective, using:
sudo systemctl reload apache2
I get this error:
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
Can anyone identify what is wrong in my configurations? How to fix the issue?
EDIT 1:
After executing: systemctl status apache2.service
This is what I get, but I do not know what should I do.
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) (Result: exit-code) since Mon 2019-08-19 12:26:44 BST; 47min ago
Process: 2632 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=1/FAILURE)
Process: 660 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 757 (apache2)
Tasks: 55 (limit: 3548)
CGroup: /system.slice/apache2.service
├─ 757 /usr/sbin/apache2 -k start
├─2369 /usr/sbin/apache2 -k start
└─2370 /usr/sbin/apache2 -k start
Aug 19 12:59:04 e-VirtualBox apachectl[2502]: The Apache error log may have more information.
Aug 19 12:59:04 e-VirtualBox systemd[1]: apache2.service: Control process exited, code=exited stat
Aug 19 12:59:04 e-VirtualBox systemd[1]: Reload failed for The Apache HTTP Server.
Aug 19 13:08:16 e-VirtualBox systemd[1]: Reloading The Apache HTTP Server.
Aug 19 13:08:16 e-VirtualBox apachectl[2632]: AH00526: Syntax error on line 132 of /etc/apache2/si
Aug 19 13:08:16 e-VirtualBox apachectl[2632]: Too many arguments to directive
Aug 19 13:08:16 e-VirtualBox apachectl[2632]: Action 'graceful' failed.
Aug 19 13:08:16 e-VirtualBox apachectl[2632]: The Apache error log may have more information.
Aug 19 13:08:16 e-VirtualBox systemd[1]: apache2.service: Control process exited, code=exited stat
Aug 19 13:08:16 e-VirtualBox systemd[1]: Reload failed for The Apache HTTP Server.
lines 1-24/24 (END)
EDIT 2:
By executing journalctl -xe
I get this output:
--
-- Unit apache2.service has finished reloading its configuration
--
-- The result is RESULT.
Aug 19 13:19:54 e-VirtualBox sudo[2933]: pam_unix(sudo:session): session closed for user root
Aug 19 13:20:46 e-VirtualBox nautilus[2130]: Attempting to read the recently used resources file a
Aug 19 13:20:50 e-VirtualBox sudo[2960]: e : TTY=pts/1 ; PWD=/etc/apache2/sites-available ;
Aug 19 13:20:50 e-VirtualBox sudo[2960]: pam_unix(sudo:session): session opened for user root by (
Aug 19 13:20:50 e-VirtualBox systemd[1]: Reloading The Apache HTTP Server.
-- Subject: Unit apache2.service has begun reloading its configuration
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit apache2.service has begun reloading its configuration
Aug 19 13:20:50 e-VirtualBox apachectl[2963]: AH00526: Syntax error on line 132 of /etc/apache2/si
Aug 19 13:20:50 e-VirtualBox apachectl[2963]: Too many arguments to directive
Aug 19 13:20:50 e-VirtualBox apachectl[2963]: Action 'graceful' failed.
Aug 19 13:20:50 e-VirtualBox apachectl[2963]: The Apache error log may have more information.
Aug 19 13:20:50 e-VirtualBox systemd[1]: apache2.service: Control process exited, code=exited stat
Aug 19 13:20:50 e-VirtualBox systemd[1]: Reload failed for The Apache HTTP Server.
-- Subject: Unit apache2.service has finished reloading its configuration
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit apache2.service has finished reloading its configuration
--
-- The result is RESULT.
Aug 19 13:20:50 e-VirtualBox sudo[2960]: pam_unix(sudo:session): session closed for user root
lines 1835-1862/1862 (END)