14

I recently updated my work machine to macOS Sierra and now none of my virtual host configurations are working. I need to reconfigure all of these which is a huge pain.

I am wondering - is it normal for this to happen? Is there a way to prevent this from happening in the future when I update my operating system?

Additionally, it appears that my virtual host configuration is not working. Please see below.

I have edited /etc/apache2/extra/httpd-vhosts.conf to include:

<VirtualHost *:80>
ServerAdmin lbanach@splashworldwide.com
DocumentRoot "/Users/splashnw/Sites/tm-charts"
ServerName tm-charts.dev
ErrorLog "/private/var/log/apache2/tm-charts.dev-error_log"
CustomLog "/private/var/log/apache2/tm-charts.dev-access_log" common
</VirtualHost>

And, my /etc/hosts file has:

127.0.0.1 tm-charts.dev

When I navigate to tm-charts.dev in my browser, there is simply a message: "It works!" Not my project that I originally saw at that URL prior to installing macOS Sierra.

Can you tell me what is going wrong here? Thank you!

Liz
  • 1,008
  • 5
  • 19
  • 49
  • What IP do you get if you `ping tm-charts.dev`? – Capsule Sep 23 '16 at 00:11
  • @capsule If I ping, I get this content: `64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.074 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.066 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.088 ms 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.060 ms` etc. – Liz Sep 23 '16 at 00:13
  • I just wanted to make sure it goes to 127.0.01 and the hosts file is actually OK. Could you try adding `::1 localhost` to it? The fact you still get to the default apache vhost proves Apache still listen on IPv4, so the `*` vhost base should be any IP, v4 or v6, but who knows. – Capsule Sep 23 '16 at 01:39

2 Answers2

23

When you updated to macOS it overwrote your "httpd.conf" file in the /etc/apache2/ folder. It also overwrote your "http-vhost.conf" file as well in the /etc/apache2/extra folder.

You need to see if you have a backup file in those directories to uncomment the lines or use this as an example to help restore your settings: http://digitalshore.io/local-web-development-environment-apache-macos-sierra-10-12/

Check both the "/etc/apache2" and "/etc/apache2/extra" folder for the http-conf~previous and http-vhost.conf~previous files to put your previous settings back

When you are done be sure to run sudo apachectl restart for the new settings to take effect.

Chris Holcomb
  • 356
  • 2
  • 4
  • I'm seeing httpd.conf.pre-update and httpd.conf~previous. Should I be copying the entire contents of httpdconf~previous into the main httpd.conf file? If so how can I replace the entire contents of httpd.conf and http-vhost.conf? I tried with an editor without luck. – Corey Bruyere Nov 28 '16 at 01:20
  • I did restarted apachectl and problem solved, thanks! – Shweta Jul 07 '17 at 09:48
12

Also after you are done with the instructions provided by @chris-holcomb , do the following:

edit the file /etc/apache2/httpd.conf:

uncomment line 160:

#LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so

to

LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so

uncomment line 509:

#Include /private/etc/apache2/extra/httpd-vhosts.conf

to

Include /private/etc/apache2/extra/httpd-vhosts.conf

as a precaution, clear your dns cache with the following command using terminal:

sudo killall -HUP mDNSResponder

Finally, restart apache:

sudo apachectl restart

Source: Apple Stack Exchange

Community
  • 1
  • 1
Ahmad Mushtaq
  • 842
  • 6
  • 7