Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to configure Apache to work with Symfony in my Macbook Pro. I Have installed Lion OSX.

  1. I uncommented the line Include /private/etc/apache2/extra/httpd-vhosts.conf on /etc/apache2/httpd.conf.
  2. I configured Apache by editing the /private/etc/apache2/extra/httpd-vhosts.conf. and adding the following:

::

NameVirtualHost *:80

<VirtualHost *.80>
  ServerName localhost
  DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "/Users/luiscberrocal/Documents/dev/lion_test/web"
  ServerName lion.localhost
<Directory "/Users/luiscberrocal/Documents/dev/lion_test/web">
   Options Indexes FollowSymlinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
</VirtualHost>

3. Added the following to /private/etc/hosts 127.0.0.1 lion.localhost

Now when I access http://localhost/test.php I get the following message

Forbidden

You don't have permission to access /test.php on this server.

Apache/2.2.20 (Unix) DAV/2 PHP/5.3.6 with Suhosin-Patch Server at localhost Port 80

I already tried:

chmod 777 test.php

chmod +x test.php 

I get the same message if I try to access http://lion.localhost/

I opened the /var/log/apache2/error_log and this is what I found relevant:

[Sat Dec 31 09:37:49 2011] [notice] Apache/2.2.20 (Unix) DAV/2 PHP/5.3.6 with Suhosin-Patch configured -- resuming normal operations
[Sat Dec 31 09:37:53 2011] [error] [client ::1] (13)Permission denied: access to /test.php denied
[Sat Dec 31 09:37:55 2011] [error] [client ::1] (13)Permission denied: access to /test.php denied
[Sat Dec 31 09:38:13 2011] [notice] caught SIGTERM, shutting down
[Sat Dec 31 09:38:13 2011] [error] (EAI 8)nodename nor servname provided, or not known: Could not resolve host name *.80 -- ignoring! httpd: Could not reliably determine the server's fully qualified domain name, using Luis-Berrocals-MacBook-Pro.local for ServerName
[Sat Dec 31 09:38:14 2011] [warn] mod_bonjour: Cannot stat template index file '/System/Library/User Template/English.lproj/Sites/index.html'.
[Sat Dec 31 09:38:14 2011] [warn] mod_bonjour: Cannot stat template index file '/System/Library/User Template/English.lproj/Sites/index.html'.
[Sat Dec 31 09:38:14 2011] [notice] Digest: generating secret for digest authentication ...
[Sat Dec 31 09:38:14 2011] [notice] Digest: done
[Sat Dec 31 09:38:14 2011] [notice] Apache/2.2.20 (Unix) DAV/2 PHP/5.3.6 with Suhosin-Patch configured -- resuming normal operations
[Sat Dec 31 09:38:18 2011] [error] [client ::1] (13)Permission denied: access to /test.php denied
[Sat Dec 31 09:38:19 2011] [error] [client ::1] (13)Permission denied: access to /test.php denied
[Sat Dec 31 10:18:09 2011] [error] [client 127.0.0.1] (13)Permission denied: access to /test.php denied
[Sat Dec 31 10:18:15 2011] [error] [client 127.0.0.1] (13)Permission denied: access to / denied

I can't figure out what I'm doing wrong.

share|improve this question
    
Have you made sure all folders in the file path are executable (+x) for all users? –  Daniel Beck Jan 1 '12 at 15:49
    
Checked the path and it is executable. I'm inclined to think that it is a problem with my content of the httpd-vhosts.conf because if I delete what I added I can access localhost/test.php. –  Luis Berrocal Jan 2 '12 at 14:37
    
Why did you define the same virtual host (for port 80) twice? Have you tried removing the default entry? I know, different name, but still..? –  Daniel Beck Jan 21 '12 at 16:33
add comment

5 Answers

Put

<Directory "your/custom/directory">
  Options Indexes FollowSymLinks
  Order allow,deny
  Allow from all
</Directory>

at the end of /opt/local/apache2/conf/httpd.conf

take a look at line 180 to 225 to see what's going on.

share|improve this answer
    
This makes it work!! –  RubyDev May 14 '13 at 9:33
add comment

In /etc/apache2/httpd.conf just comment the lines

User _www
Group _www

and make the User as the user you are logged in. That should work.

share|improve this answer
1  
This has the likely side effect of having a web server run with near-administrative, or administrative, privileges on your machine. –  Tom Lianza Jul 9 '12 at 3:47
add comment

Looks like your Apache config file is not written correctly.

I would take the directory stuff and move it above the VirtualHost, also you cannot access the second virtual host you created because your trying to access it with the wrong hostname. You would need to use http://lion.localhost instead of localhost.

I would also just remove the first virtual host setting and than change the lion.localhost to localhost for simplicity.

Hope that helps,

Nick

<Directory "/Users/luiscberrocal/Documents/dev/lion_test/web">
   Options Indexes FollowSymlinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot "/Users/luiscberrocal/Documents/dev/lion_test/web"
   ServerName lion.localhost
</VirtualHost>
share|improve this answer
    
The error is a configuration / permissions issue. You'll have to debug it. Wish the correct answer would be promoted on SU. –  JRM Nov 15 '12 at 15:51
add comment

I couldn't work out it to work with port 80. What finally worked for me was using this on my /private/etc/apache2/extra/httpd-vhosts.conf

NameVirtualHost 127.0.0.1:8080

Listen 127.0.0.1:8080

<VirtualHost 127.0.0.1:8080>
        DocumentRoot "/Users/luiscberrocal/NetBeansProjects/mroute_rest_service/web"
        DirectoryIndex index.php
        <Directory "/Users/luiscberrocal/NetBeansProjects/mroute_rest_service/web">
    AllowOverride All
    Allow from All
        </Directory>
</VirtualHost>

Then run sudo chmod 777 cache and sudo chmod 777 logs/

share|improve this answer
add comment

I had the same issue. In my case the directory didn't have the proper permissions.

I changed them to 755 and solved the problem.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.