i can NOT open php local file

Hi every body,


when i try to open a Local php file from safari or any other browser, i get the following message :


Forbidden

You don't have permission to access /~user/Forkan.org/index.html on this server.


Please note that i already enable apache and php server as in the Photo..


Thanks for any clear and useful help...


(i am running OS 10.8.2)


User uploaded file

Posted on Oct 27, 2012 10:01 AM

Reply
17 replies

Oct 27, 2012 12:03 PM in response to Ahmad Issawi

Ahmad Issawi wrote:


when i try to open a Local php file from safari or any other browser, i get the following message :


Forbidden

You don't have permission to access /~user/Forkan.org/index.html on this server.

First of all, index.html is not a PHP file, just a regular HTML file. What are the permissions on ~/Sites/Forkan.org? You need world read and execute access like everything else in the Sites folder.

Oct 27, 2012 12:58 PM in response to etresoft

thanks,

in the attached photo, the file index.html is one of many files Unreadable with the ext .html and .php also...


in fact, after i update to 10.8.2 i read the following article :


http://coolestguyplanettech.com/downtown/install-and-configure-apache-mysql-php- and-phpmyadmin-osx-108-mountain-lion


and i did all the instructions inside...


Please note that when i put : localhost

in my browser, i really get :

It works!

But each time i put :


http://localhost/~user/Forkan.org/index.html

http://localhost/~user/Forkan.org/Movies.php

http://localhost/~user/Sample.php


and also :


http://localhost/~user/phpinfo.php (like the file in the article after i made that file and put it correctly of course)


each time i put that i get :


Forbidden

You don't have permission to access /~user/phpinfo.php on this server.


Many thanks for any Help...

Oct 28, 2012 12:59 AM in response to BobTheFisherman

Thanks Bob...

YES, my user name is "user" and i am sure (i cheked it by Terminal : i put the command line : "whoami" then i receive : "user", and the folder inside "Users" folder is also named "user")


whatever the permissions for the folder Forkan.org... When i try :


http://localhost/~user/phpinfo.php


i get the message :


Forbidden

You don't have permission to access /~user/phpinfo.php on this server.


so the problem is independant of Forkan folder...

hmmmmm... it is really ubnormal !

Oct 28, 2012 8:05 AM in response to Ahmad Issawi

Sorry, that is not a solution, but a crude hack.


If you are going to do web development, you must learn how to use the Terminal and standard UNIX commands like ls and chmod. Your home directory permissions are seriously wrong.


This is what I have for /Users/jdaniel:

drwxr-xr-x@ 59 jdaniel staff 2006 26 Oct 21:47 jdaniel


This is /Users/jdaniel/Sites:

drwxr-xr-x@ 49 jdaniel staff 1666 24 Oct 21:10 Sites


To fix your home directory, you can do the following two commands in the Terminal:

chmod 0755 ~

chmod 0755 ~/Sites

Oct 28, 2012 8:23 AM in response to etresoft

To fix your home directory, you can do the following two commands in the Terminal:

chmod 0755 ~

chmod 0755 ~/Sites

What exactly these 2 commands do ??


(Please note that, as in the last attached photo, normally the permissions of my user folder are NOT as in the photo... i just did that temporary to check if that solve the problem ....)

The problem was in the Apache document root ... i changed the setting from the default setting (witch is : /Library/WebServer/Documents) to my desired folder : Users/user/Sites

and this was done by BbEdit with the file : /etc/apache2/httpd.conf 🙂


Oct 28, 2012 9:01 AM in response to Ahmad Issawi

Ahmad Issawi wrote:


To fix your home directory, you can do the following two commands in the Terminal:

chmod 0755 ~

chmod 0755 ~/Sites

What exactly these 2 commands do ??


They set the permissions to your home folder and Sites folder to correct values.


(Please note that, as in the last attached photo, normally the permissions of my user folder are NOT as in the photo... i just did that temporary to check if that solve the problem ....)


Then don't post things like that because they are misleading.


The problem was in the Apache document root ...


No, it wasn't. All you have done is change your document root to be inside a user directory.


I think that what you need to do is create a user config directory. Mountain Lion no longer creates those by default.


Create a file at path /etc/apache2/users/user.conf with the following content:


DocumentRoot /Users/user/Sites


<Directory "/Users/user/Sites/">

Options Indexes MultiViews FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all

</Directory>


Change your main document root back to the way it was. Then restart apache.




This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

i can NOT open php local file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.