在我之前的问题中 ,SSL证书不适合我,直到我使用相对path而不是绝对path工作。
问题:为什么我的VirtualHost / httpd不接受绝对path? 有一些configuration什么的?
我的VirtualHost(非工作);
<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>
错误日志:
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(工作):
<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>
我不得不将包含证书的文件夹移动到httpd文件夹(相对),以便它的工作? 任何人都知道为什么以及如何让它接受绝对path? 谢谢!
不,你可以从任何地方指定绝对path,只要httpd可以到达它们(用root)
有关configuration的唯一适用于httpd的规则是相对path相对于ServerRootpath,但是如果指定了绝对path,则它们可以指向您指定的文件系统中的任何位置。
所以仔细检查前面的path,并确认文件在那里,或者SELinux或类似的东西没有阻碍。