mysql - Mac 上的 2 个虚拟主机

标签 mysql macos virtual host

大家好,我有两个不同的网站,我想要两个不同的主机: 电影.本地 音乐本地

这些是我的文件:

#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost
127.0.0.1   movie.local
127.0.0.1   music.local

还有

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>

    ServerName movie.local

    ServerAlias www.movie.local

    DocumentRoot "/Users/Me/Sites/movie"

    ErrorLog "/private/var/log/apache2/site-error_log"

    CustomLog "/private/var/log/apache2/site-access_log" common

    ServerAdmin neilgee@coolestguidesontheplanet.com

        <Directory "/Users/Me/Sites/movie">

            Options Indexes FollowSymLinks

            AllowOverride All

            Order allow,deny

            Allow from all

        </Directory>

</VirtualHost>

<VirtualHost *:80>

         ServerName music.local

        ServerAlias www.music.local
        DocumentRoot "/Users/Me/Sites/music"

    ErrorLog "/private/var/log/apache2/site-error_log"

   CustomLog "/private/var/log/apache2/site-access_log" common

    ServerAdmin neilgee@coolestguidesontheplanet.com

        <Directory "/Users/Me/Sites/music">

            Options Indexes FollowSymLinks MultiViews

            AllowOverride All

            Order allow,deny

            Allow from all

        </Directory>

</VirtualHost>

但是现在如果我转到 movie.local 就可以了,但是如果我转到 music.local 我的浏览器将加载 movie.local 的内容,为什么?

最佳答案

如果我转到music.local,我的浏览器将加载movie.local的内容,为什么? 您可以像这样在本地主机上创建一个子域。

首先创建一个虚拟主机:

<VirtualHost *:80>
ServerName music.localhost
DocumentRoot "C:/Users/Me/Sites/music"
 <Directory "C:/Users/Me/Sites/music">
/....../
/....../
</Directory>
</VirtualHost>

And in your hosts file add this line:
127.0.0.1      music.localhost

关于mysql - Mac 上的 2 个虚拟主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26022528/

相关文章:

Mysql 修改表日期不为空

php - PDO 在 pgsql 与 mysql 中准备语句

mysql - 通过使用 LIMIT 1 和 WHERE 子句匹配表之外的列值的 SELECT 子查询来连接表

php - 无法为 OS X 10.9.5 安装 Sphinx : '"/lib/cpp"fails sanity check'

php - 使用 MySQL 进行时间计算

macos - 为什么 macOS 会杀死由 clang 创建的静态可执行文件?

c++ - OpenGL glDeleteTextures 导致内存泄漏?

c++ - 返回类型与返回类型 (operator++) 不相同也不协变

c++ - 虚拟继承是如何工作的?

c# - 比较 : interface methods vs virtual methods vs abstract methods