0
votes

I am trying to setup the virtual host for apache on Mac.

Here is my virtual host setting in /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>

Additionally, editing the file in /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

But when i go to symfony.dev in the web browser, it cannot connect to. could someone help me on that?

Note: tried to restart the apache several times

2
"Cannot connect" is a bit vague -- do you get hits in your access log/error log? - Ulrich Schwarz
@UlrichSchwarz "Cannot connect" means showing unable to connect in the firefox browser - J.L
Did you solve this ? How did you get it working ? - mika
@mika Hi, I run apachectl configtest to test what's the existing error. - J.L

2 Answers

0
votes

Try this it will work

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>
0
votes

You could make it

<VirtualHost symfony.dev>
  ServerName symfony.dev
  ServerAdmin [email protected]

  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>

=> "Directory" instructions should be for your root-symfony-directory/web folder, as your document root.
=> What's this "common" behind your Custom Log directory ? Did you mean "combined" ?
=> In symfony2, you need to make sure that all the requests are directed to you bootstrap - this is where rewrite engine comes in. Oh, But I see this bit has moved into the .htaccess in earlier versions of symfony :o So no need for it here. Note that you have configuration instructions for apache and symfony2 here

There is much more science behind this, but these are the parameters I use for my setup. For more info, read the docs !