Access forbidden! [Solved]

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Access forbidden! [Solved]

Postby PhdJ » 07. December 2011 09:17

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
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 ?
Posts: 5
Joined: 01. December 2011 10:25
Operating System: Linpus

Re: Access forbidden!

Postby PhdJ » 07. December 2011 11:53

Apparently this was a security problem from copying the files, using chmod on the directory and the files solved the problem.
Posts: 5
Joined: 01. December 2011 10:25
Operating System: Linpus

Re: Access forbidden!

Postby JonB » 07. December 2011 14:03

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:

this one has good examples, but not all the 'bells and whistles' :roll: ... 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
User avatar
AF Moderator
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 3 guests