Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In attempting to enable mod_rewrite on the Apache2 web server installed with Mac OSX 10.7.4. Following these instruction, ultimately using the configuration to host CakePHP applications, I run into permissions issues accessing the site via a web browser when I set the directory block associated with cakephp site

/etc/apache2/users/username.conf from:

<Directory "/Users/username/Sites/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride none
    Order allow,deny
    Allow from all
</Directory>

/etc/apache2/users/username.conf to:

<Directory "/Users/username/Sites/">
    Options Indexes MultiViews
    AllowOverride none
    Order allow,deny
    Allow from all
</Directory>
<Directory "/Users/username/Sites/cakephp_app/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>

The .htaccess files are the CakePHP 2.2.2 default as follows:

/Users/username/Sites/cakephp_app/.htaccess

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

/Users/username/Sites/cakephp_app/app/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

/Users/username/Sites/cakephp_app/app/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

When performing the request via a web browser at to http://0.0.0.0/~username/cakephp_app/index.php the content of the response is

Not Found

The requested URL /Users/username/Sites/cakephp_app/app/webroot/ was not found on this server.

Apache/2.2.21 (Unix) DAV/2 PHP/5.3.10 with Suhosin-Patch Server at 0.0.0.0 Port 80

Upon a request to http://0.0.0.0/~username/ and http://0.0.0.0/~username/cakephp_app/, added to /var/log/apache2/error_log accordingly are the following:

[Tue Sep 04 22:53:26 2012] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/Users, referer: http://0.0.0.0/~username/
[Tue Sep 04 22:53:26 2012] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/favicon.ico

What is causing the issue? Is there server program, ideally available via a homebrew script, which would make hosting CakePHP applications for testing purposes more effective and efficient?

share|improve this question
    
a vague mention of "permissions issues" isn't enough information. please show a representative sample of your apache error.log - that should show which file(s) apache is unable to access. –  cas Sep 5 '12 at 2:29
    
@CraigSanders is the added content sufficient? –  rudolph9 Sep 5 '12 at 3:59
    
that doesn't look like a a permissions problem. it looks like file not found. Is 'username' the literal string username, or have you changed it from the actual username? Does /Library/WebServer/Documents/Users/username/Sites/cakephp_app/app/webroot/ actually exist? Does it contain 'index.php'? are all directories in that path both readable and executable by the _www user? –  cas Sep 5 '12 at 5:06
    
@CraigSanders Yes, I have changed it from the actual username, To allocate access to the directory I used sudo chown -R /Users/username/Sites/cakephp_app/. Why is it looking in /Library/WebServer/Documents/Users/ this does not exist. /Library/WebServer/Documents/ is the root (i.e. http://0.0.0.0) but how is defining access to /Users/username/Sites/ when I access a users home page (i.e. http://0.0.0.0/~username)? –  rudolph9 Sep 5 '12 at 7:02
    
i'd guess it's looking under /Library/WebServer/Documents/ because that's the (configured) default DocumentRoot. –  cas Sep 5 '12 at 7:28
add comment

migrated from unix.stackexchange.com Sep 5 '12 at 6:40

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems..

2 Answers

Given that the difference between AllowOverride none and AllowOverride All is whether the .htaccess file is used or not, it seems likely that the problem is in your .htaccess file.

Most likely it is referring to files (e.g. included html, css, php, or image files) or directories that aren't acessible by the web-server user (typically apache runs as user 'httpd' or 'apache' or 'www-data' or some other username created just for that purpose).

Check the permissions on all files and directories used by your cakephp application, including those in the application's top-level directory and any additional files/directories referred to by the .htaccess or application (if any). Files should be at least readable by the webserver user, and directories should be at least readable and executable.

Also, any parent directories (i.e. above your application's files) need to be at least readable and executable by the webserver user - if they're not, then apache won't be able to get to them.

share|improve this answer
    
I used _www as the user, I have set the permissions for each of the directories my cakephp application is using, but I'm still having issues? –  rudolph9 Sep 5 '12 at 1:38
add comment

In order to use your .htaccess file you should set AllowOverride FileInfo (or ALL) for the folder where the htaccess file is located.

share|improve this answer
    
he's already done this. –  booyaa Jul 25 '13 at 8:11
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.