Page 1 of 1

Access forbidden! [Solved]

PostPosted: 07. December 2011 09:17
by PhdJ
I successfully installed Xampp under Ubuntu, the welcome page works fine.

Now I copied my PHP scripts under the htdocs directory, but when I try to execute the script I get the following :

Code: Select all
Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.
Error 403
localhost
Wed 07 Dec 2011 09:07:34 AM CET
Apache/2.2.21 (Unix) DAV/2 mod_ssl/2.2.21 OpenSSL/1.0.0c PHP/5.3.8 mod_apreq2-20090110/2.7.1 mod_perl/2.0.5 Perl/v5.10.1


What am I missing ?

Re: Access forbidden!

PostPosted: 07. December 2011 11:53
by PhdJ
Apparently this was a security problem from copying the files, using chmod on the directory and the files solved the problem.

Re: Access forbidden!

PostPosted: 07. December 2011 14:03
by JonB
Good answer! - glad you found it.

(I'll put in 2ยข here, for an explanation)

When you copy files (in most cases) the new files will 'belong'/be owned by the linux 'user' that copied them.
There are two cures for this:

Before the fact, using the cp command with the -p / --preserve parameter as root (only works on the command line)

Code: Select all
cp - p /opt/lampp/htdocs/folder-original/* /opt/lampp/htdocs/folder-new


-- will copy all the files in folder-original to folder-new and preserve their ownership, timestamp, and mode (permissions/chmod)
This is very useful for copying within LAMPP, as the ownership is usually right.

I was 'shocked' to just find about half the Google references on Linux 'cp' don't contain all the possible arguments - this is a good one:
http://linux.about.com/od/commands/l/blcmdl1_cp.htm

this one has good examples, but not all the 'bells and whistles' :roll:
http://www.basicconfig.com/linux/how_to ... tory_linux

Ex post facto, use the 'chown' command in Term - in most cases in LAMMP, you should to apply this command to the folder that contains the files:
Code: Select all
chown -R nobody:root /opt/lampp/htdocs/foldername


The '-R' is for recursive.

Good Luck and thanks
8)