apache虚拟主机设置不起作用

时间:2014-06-22 07:25:42

标签: apache symfony

我正在尝试在Mac上为apache设置虚拟主机。

这是我在/etc/apache2/extra/httpd-vhosts.conf中的虚拟主机设置

<VirtualHost *:80>
    ServerAdmin localhost
    DocumentRoot "/Users/Ivy/Sites/Symfony"
    ServerName symfony.dev
    ErrorLog "/private/var/log/apache2/symfony.dev-error_log"
    CustomLog "/private/var/log/apache2/symfony.dev-access_log" common

    <Directory "/Users/Ivy/Sites/Symfony">
    options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

</VirtualHost>

此外,在/ etc / hosts

中编辑文件
127.0.0.1       symfony.dev
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
192.168.43.168  matrixdemo.squiz.net

但是当我在网络浏览器中访问symfony.dev时,它无法连接到。有人可以帮助我吗?

注意:尝试多次重启apache

2 个答案:

答案 0 :(得分:0)

试试这个会起作用

NameVirtualHost *:80
#Do not forget to include server name and server alias in host file
<VirtualHost *:80>
    ServerName localhost
    ServerAlias localhost
    DocumentRoot "D:\Local server\htdocs\localhost"
    CustomLog logs/localhost.access.log combined
    ErrorLog logs/localhost.error.log
</VirtualHost>

答案 1 :(得分:0)

你可以成功

<VirtualHost symfony.dev>
  ServerName symfony.dev
  ServerAdmin your.mail@whatever.com

  DocumentRoot "/Users/Ivy/Sites/Symfony/web"
  ErrorLog "/private/var/log/apache2/symfony.dev-error_log"
  CustomLog "/private/var/log/apache2/symfony.dev-access_log" combined

  <Directory "/Users/Ivy/Sites/Symfony/web">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

=&GT; “目录”说明应该是您的root-symfony-directory / web文件夹,作为您的文档根目录 =&GT;您的自定义日志目录背后的“常见”是什么?你的意思是"combined"吗? =&GT;在symfony2中,你需要确保所有的请求都被引导到你的引导程序 - 这就是重写引擎的用武之地。哦,但我看到这一点已经进入了早期版本的symfony中的.htaccess:o所以不需要在这里。请注意,您有apache和symfony2 here

的配置说明

这背后有更多的科学,但这些是我用于设置的参数。有关详细信息,请read the docs