LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-12-2013, 06:08 AM   #1
mkvakic
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Rep: Reputation: Disabled
Apache 403 file permission error when accesing a symlink file (CentOS 6.3)


Hello,

When trying to access a file outside the server document root directory, i get the 403 permission error.
It is a plain text file which i link with:

ln -s /home/blah/blah.txt /var/www/html/.

Since this is a lack of understanding(thus very common on Google) on my part, i have tried the following:

1) Checking the FollowSymLinks option in the httpd.conf file for the document root directory (already there)

2) Changing the permission (755) to the whole path leading to the file.

3) Adding the username "apache" to the group "users"

4) Initialising httpd.conf file as one of the members of the group "users"

5) Turning off SELinux

6) Praying


I know this is a fairly common question(embarassingly), but i've yet to find a solution.
Any help is much appreciated.

Regards,
Marko
 
Old 02-12-2013, 06:22 AM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
I guess your purpose is to create a soft link named /home/blah/blah.txt for /var/www/html/, which you done as,
Code:
~$ ln -s /home/blah/blah.txt /var/www/html/.
But it's not correct.
Link command has following syntax (see more here),
Code:
ln [OPTION]... [-T] TARGET LINK_NAME
So you should try like,
Code:
~$ ln -s /var/www/html /home/blah/blah.txt
Where, /var/www/html is your target directory and /home/blah/blah.txt is link name. You can further verify the soft link as,
Code:
~$ ls -li /home/blah/blah.txt
lrwx ......... /home/blah/blah.txt -> /var/www/html
 
Old 02-12-2013, 06:32 AM   #3
mkvakic
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Sorry i don't want to be rude, but i think you've got it the other way around.

The way you did it is created a blah.txt link to the folder /var/www/html.
I want the link to point to the blah.txt ( in my case folders with images ):

# ll /var/www/html/blah.txt

lrwxrwxrwx. 1 root root 29 2013-02-12 10:38 blah.txt -> /home/blah/blah.txt
 
Old 02-12-2013, 08:27 AM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
My purpose was to point out the correct syntax. In your first case, it was not correct. You could have done it like,
Code:
~$ ln -s /home/blah/blah.txt /var/www/html/linkname
~$ ls -li /var/www/html/blah.txt
lrwxrwxrwx  1 root root  29 2013-02-12 10:38 /var/www/html/linkname -> /home/blah/blah.txt
BTW, has it solved your problem?

Last edited by shivaa; 02-12-2013 at 08:28 AM.
 
1 members found this post helpful.
Old 02-12-2013, 10:03 AM   #5
mkvakic
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Hmm, im not sure how my first post was different from your last one...

But no, it is still not working.
 
Old 02-12-2013, 11:30 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Depending on distribution, the usual problem is that /home/blah/blah.txt that is pointed to by the symbolic link is not accessible by apache. The file (and the directory path it is in) must be accessable (rx for directories, and r for the file) in either group or world. The file must be in the apache group for group access (the directory path may be rx for group, IF the group is also apache, or world).

On RH systems with active SELinux controls the file must also be labeled with the SELinux labels (either httpd_sys_content/httpd_sys_rw_content, or httpd_user_content/httpd_user_rw_content) types.
 
1 members found this post helpful.
Old 02-13-2013, 03:46 AM   #7
mkvakic
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thank you for your time shivaa and jpollard.

I solved the problem by actually reading an Apache/SElinux manual...

The first step was to enable reading of the home directories:

Code:
setsebool -P httpd_enable_homedirs 1
Then assign a proper type to the directory where the files reside:

Code:
chcon -R -t httpd_sys_content_t ~user/public_html
Finally linking the files which are to be used.

Thank you once more for your time.
 
Old 02-13-2013, 04:25 AM   #8
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Happy to hear that

Please Mark the thread as solved (option is under Thread Tools on top menu), if you think it has so.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[CentOS 5.8] 403 Error when accessing vhost directive (permission problems) Ortix Linux - Server 8 10-22-2012 01:04 AM
apache 403 forbidden permission to access error windows agentfitz Linux - Server 2 01-19-2011 01:45 PM
Apache Error 403 - CentOS 5.2 with Apache 2.2.3 gordymann Linux - Newbie 2 04-08-2009 09:57 AM
Apache 403 Forbidden Error On Every File agtlewis Linux - Software 5 09-02-2006 12:25 AM
Errot 403 on 666 permission file baosheng Linux - Software 4 10-10-2005 06:00 AM


All times are GMT -5. The time now is 02:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration