0

This on a Raspberry Pi 2. When I add a second virtual host to the 000-default.conf file, and restart apache2, it gives me this error:

[....] Restarting apache2 (via systemctl): apache2.serviceJob for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details.
failed!

When I run systemctl status apache2.service, it gives me

● apache2.service - LSB: Apache2 web server
  Loaded: loaded (/etc/init.d/apache2)
  Active: failed (Result: exit-code) since Mon 2016-09-05 22:52:11 MDT; 2min 34s ago
Process: 584 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

My 000-default.conf file (first virtual host works just fine by-itself):

<VirtualHost *:80>
         ServerAdmin webmaster@localhost
         DocumentRoot /home/pi/public_html
         #LogLevel info ssl:warn                                                                                          

         ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
         ServerName alexspi2.local
         ServerAdmin (email address, not shown for privacy)
         DocumentRoot /home/pi/public_html
         ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined
         SSLEngine on
         SSLCertificateFile /etc/apache2/ss1/ca.crt
         SSLCertificateKeyFile /etc/apache2/ssl/ca.key
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

I don't know what is wrong with the second part.

  • 1
    Can you add more details from /var/log/apache/error.log – Varad A G Sep 6 '16 at 6:40
  • 1
    I think this question is better off in ServerFault – Gene Sep 6 '16 at 15:05
3

Create a different conf file for the second virtualhost and put it in /etc/apache2/sites-available

and run

$ sudo a2ensite
$ sudo a2enmod rewrite
$ sudo service apache2 restart
  1. will enable the new conf file
  2. will enable rewrite module to allow filepath access
  3. restart apache

Also

apachectl -t

to check for config syntax

  • The last part was useful. Turns out that the virtual host pointed to a directory for the keys that didn't exist. (Accidentally put a 1 where there should be a L). – user3273814 Sep 9 '16 at 3:16
0

Firstly you should troubleshot the the problem by analyzing the:

  • output of journalctl -xn
  • output of journalctl _SYSTEMD_UNIT=apache2.service
  • the log file as @Varad A.G. suggested

Your second <virtualhost>section which matches for 443 Port should be supported by a global Listen [IP:]443directive too. In default, apache already has Listen 80 global directive within main configuration, that is why the first one works.

And also as @Cunningham's Lawyer stated, that question should be asked to Server Fault

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.