简体   繁体   English

虚拟主机不能安装macOS Sierra

[英]Virtual hosts not working with install of macOS Sierra

I recently updated my work machine to macOS Sierra and now none of my virtual host configurations are working. 我最近将我的工作机器更新为macOS Sierra,现在我的虚拟主机配置都没有工作。 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: 我编辑了/etc/apache2/extra/httpd-vhosts.conf来包括:

<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: 而且,我的/etc/hosts文件有:

127.0.0.1 tm-charts.dev

When I navigate to tm-charts.dev in my browser, there is simply a message: "It works!" 当我在浏览器中导航到tm-charts.dev时,只会出现一条消息:“它有效!” Not my project that I originally saw at that URL prior to installing macOS Sierra. 不是我在安装macOS Sierra之前在该URL上看到的项目。

Can you tell me what is going wrong here? 你能告诉我这里出了什么问题吗? Thank you! 谢谢!

When you updated to macOS it overwrote your " httpd.conf " file in the /etc/apache2/ folder. 当您更新到macOS时,它覆盖了/ etc / apache2 /文件夹中的“ httpd.conf ”文件。 It also overwrote your " http-vhost.conf " file as well in the /etc/apache2/extra folder. 它还覆盖了/ etc / apache2 / extra文件夹中的“ http-vhost.conf ”文件。

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/ 您需要查看这些目录中是否有备份文件以取消注释行或使用此作为示例来帮助恢复您的设置: 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 检查“ / etc / apache2 ”和“ / etc / apache2 / extra ”文件夹中的http-conf~previoushttp-vhost.conf~previous文件,将以前的设置恢复

When you are done be sure to run sudo apachectl restart for the new settings to take effect. 完成后,请确保运行sudo apachectl restart以使新设置生效。

Also after you are done with the instructions provided by @chris-holcomb , do the following: 完成@ chris-holcomb提供的说明后,请执行以下操作:

edit the file /etc/apache2/httpd.conf: 编辑文件/etc/apache2/httpd.conf:

uncomment line 160: 取消注释第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: 取消注释第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: 作为预防措施,使用终端使用以下命令清除您的dns缓存:

sudo killall -HUP mDNSResponder

Finally, restart apache: 最后,重启apache:

sudo apachectl restart

Source: Apple Stack Exchange 资料来源: Apple Stack Exchange

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM