VirtualHost / httpd not accepting absolute paths
In my previous question, SSL certificates weren't working for me, until I got it to work using relative paths rather than absolute.
Question: Why won't my VirtualHost/httpd not accept absolute paths? Is there some configuration or something?
My VirtualHost (non-working);
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
RewriteEngine on
RewriteRule ^/?(.*) https://example.com/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
DocumentRoot /var/www/msdfw
ErrorLog /var/iwww/logs/e-msdfw
CustomLog /var/iwww/logs/c-msdfw combined
DirectoryIndex index.php
SSLEngine on
SSLCertificateFile /var/iwww/certs/msdfw/c.pem
SSLCertificateKeyFile /var/iwww/certs/msdfw/p.key
SSLCertificateChainFile /var/iwww/certs/msdfw/b.pem
<Directory /var/www/msdfw/>
Require all granted
</Directory>
</VirtualHost>
Error Log:
Sep 26 17:00:11 localhost systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
Sep 26 17:00:11 localhost httpd[5579]: AH00526: Syntax error on line 15 of
/etc/httpd/enabled/msdfw.conf:
Sep 26 17:00:11 localhost httpd[5579]: SSLCertificateFile: file
'/var/iwww/certs/msdfw/c.pem' does not exist or is empty
Sep 26 17:00:11 localhost systemd[1]: httpd.service: main process exited,
code=exited, status=1/FAILURE
Sep 26 17:00:11 localhost kill[5581]: kill: cannot find process ""
Sep 26 17:00:11 localhost systemd[1]: httpd.service: control process exited,
code=exited status=1
Sep 26 17:00:11 localhost systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Sep 26 17:00:11 localhost systemd[1]: Unit httpd.service entered failed state.
Sep 26 17:00:11 localhost systemd[1]: httpd.service failed.
VirtualHost (working):
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
RewriteEngine on
RewriteRule ^/?(.*) https://example.com/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
DocumentRoot /var/www/msdfw
ErrorLog /var/iwww/logs/e-msdfw
CustomLog /var/iwww/logs/c-msdfw combined
DirectoryIndex index.php
SSLEngine on
SSLCertificateFile /etc/httpd/certs/msdfw/c.pem
SSLCertificateKeyFile /etc/httpd/certs/msdfw/p.key
SSLCertificateChainFile /etc/httpd/certs/msdfw/b.pem
<Directory /var/www/msdfw/>
Require all granted
</Directory>
</VirtualHost>
I had to move the folder containing the certificates to the httpd
folder (relative) in order for it to work? Anyone know why and how I can make it accept absolute paths? Thanks!
No, you can specify absolute paths from anywhere as long as httpd can reach them (with root)
The only rule that applies to httpd regarding configuration is relative paths are relative to ServerRoot path, but if you specify absolute paths they can point anywhere in the filesystem you specify.
So double-check the previous paths and that the files were there, or that SELinux or similar is not getting in the way.