FedoraForum.org - Fedora Support Forums and Community
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Jan 2010
    Posts
    6

    public_html: 403 forbidden

    Hi!

    I tried everything, turned off selinux, added (even with selinux=permissive):

    # setsebool -P httpd_enable_homedirs 1
    # semanage fcontext -a -t httpd_sys_content_t '/home/user01/public_html(/.*)?'
    # restorecon -vvFR /home/user01/public_html

    # chmod 711 /home/user01/public_html


    in httpd.conf:

    <IfModule mod_userdir.c>
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #

    #
    # To enable requests to /~user/ to serve the user's public_html
    # directory, remove the "UserDir disabled" line above, and uncomment
    # the following line instead:
    #
    UserDir public_html

    </IfModule>

    <Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch ExecCGI IncludesNoExec
    <Limit GET POST OPTIONS>
    Order allow,deny
    Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
    Order deny,allow
    Deny from all
    </LimitExcept>
    </Directory>



    And this is not working....

    Am I missing something?

    Thanks !!

  2. #2
    Join Date
    Apr 2011
    Location
    Finland
    Posts
    292

    Re: public_html: 403 forbidden

    Try chmod 755 instead of 711.

  3. #3
    Join Date
    Jan 2010
    Posts
    6

    Re: public_html: 403 forbidden

    Thx Miikka!

    Been there, done that

    I tried even 777, not working....

  4. #4
    Join Date
    Sep 2008
    Location
    Arlov, Sweden
    Posts
    42

    Re: public_html: 403 forbidden

    Did you chmod 755 public_html ?
    F17 x86_64 Gnome.

  5. #5
    Join Date
    Jan 2010
    Posts
    6

    Re: public_html: 403 forbidden

    yup

    drwx--x--x. 3 user01 user01 4096 Aug 4 18:18 public_html

    also

    drwxr-xr-x. 3 user01 user01 4096 Aug 4 18:18 public_html/

    none of these worked

  6. #6
    Join Date
    Apr 2011
    Location
    Finland
    Posts
    292

    Re: public_html: 403 forbidden

    You should be using -R option to change permission to both folder and the files inside.

    Code:
    chmod 755 -R ~/public_html/

  7. #7
    Join Date
    Jan 2010
    Posts
    6

    Re: public_html: 403 forbidden

    Yp, everything inside have enough permissions... I have the same config and permissions in CentOS 6 with no issues...

    ---------- Post added at 06:23 PM ---------- Previous post was at 05:38 PM ----------

    solved, you need to change the home directory

    chown 711 /home/user01

    thanks!

  8. #8
    Join Date
    Aug 2009
    Location
    Waldorf, Maryland
    Posts
    7,346

    Re: public_html: 403 forbidden

    Do an "ls -lZ public_html". If you didn't give apache the SELinux permissions to read user home directories, that is what you get.

    Both the SELinux boolean (httpd_enable_homedirs) must be set, AND the users public_html must have the SELinux type (httpd_user_content_t, or httpd_user_rw_content_t if it is to be written to) must be set. Normally httpd_user_content_t is on the directory, but files/subdirectories can have the "httpd_user_rw_content.

  9. #9
    Join Date
    Nov 2008
    Location
    Central NJ
    Posts
    379

    Re: public_html: 403 forbidden

    I think I may be having the same problem. I followed the steps here, but I cannot view any ~username websites, only the default one located in /var/www/html

  10. #10
    Join Date
    Jan 2010
    Posts
    6

    Re: public_html: 403 forbidden

    Checklist:

    httpd.conf?
    semanage fcontext?
    setsebool home dirs?
    chmod 711 ~username ?
    chmod 711 ~username/public_html ?
    chmod -R 755 ~username/public_html/* ?

    Cheers!

  11. #11
    Join Date
    Aug 2009
    Location
    Waldorf, Maryland
    Posts
    7,346

    Re: public_html: 403 forbidden

    And don't forget:

    chcon -R -t httpd_user_content_t ~username/public_html/*

  12. #12
    Join Date
    May 2007
    Location
    Cleveland, spiritual center of the rust belt
    Posts
    34

    Re: public_html: 403 forbidden

    I have not tested it, but you may need to change security context on parent directories. My situation was:
    (1) Works fine out of /var/www/html/
    (2) But wait, I can't have a couple of hundred gig of mundane files under /var, need a symlink. Could change the document root, I guess, but I like having the core files of my web server where they're supposed to be by default.
    (3) Apache documentation is hard to follow, but the f15 httpd.conf file looks OK for this problem, and it turns out that you don't have to touch it.
    (4) memories for the last web server setup tell me to adjust the security context (# chcon), but it's not enough.

    Now, I had a symlink to /srv/share, where /srv is a different hard disk and /srv/share is a collection of user directories intended for others to be able to read. error_log and apache's error message were only a bit helpful. ((apache's message says I can't access /share/blah/blah.css. Note that "share" is also the name of symlink in /var/www/html/ that points to /srv/share, but appache's message makes it look like it thinks there's a directory /share on the file system. Obviously, the message really speaks from the assumption that / is actually /var/www/html/)

    Anyway, when I changed the security context of /srv to httpd_sys_content_t, things started to work. It didn't seem to be enough for just /srv/share to have this context. It didn't matter that I wasn't trying to access /srv itself. My theory is that if you symlink to /a/b/c/d, then you need read permissions and security context to be set for a,b, and c as you would set them for d.

    After that, I still had errors, but these were simply files that didn't have read permissions set for others, and the message in error_log pointed me straight to it.

    Looking at my previous web server setup, I had this virtual host thing going on. I remember grasping at straws, so I must have stumbled on a weird work-around. I didn't want to re-create it. Happy to say I didn't have to change my web server conf at all. (I tried various modifications, but in the end I took them all out).

  13. #13
    Join Date
    Dec 2011
    Location
    San Francisco
    Posts
    7

    Re: public_html: 403 forbidden

    Just ran into this on F26, because SELinux is always the root of all problems on a new install. Had to do:

    setsebool httpd_enable_homedirs true

  14. #14
    Join Date
    Jan 2010
    Posts
    7,168

    Re: public_html: 403 forbidden

    Note that you're replying to a thread from 2011. Which doesn't mean the information is irrelevant, as apparently SELinux still causes issues with apache, but useful to keep in mind.

  15. #15
    Join Date
    Dec 2011
    Location
    San Francisco
    Posts
    7

    Re: public_html: 403 forbidden

    I know, but since this is the thread that came up when I googled for it I thought I'd leave a tip for anyone else searching.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. can't make public_html
    By GalGavu in forum Servers & Networking
    Replies: 2
    Last Post: 12th September 2009, 08:43 AM
  2. VSFTPD+public_html
    By flatproject in forum Servers & Networking
    Replies: 0
    Last Post: 28th February 2006, 06:07 PM
  3. apache and public_html
    By teethlikelions in forum Servers & Networking
    Replies: 4
    Last Post: 20th November 2005, 10:34 PM
  4. Probs with ~/public_html
    By pie in forum Using Fedora
    Replies: 1
    Last Post: 16th May 2005, 11:13 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •