FedoraForum.org - Fedora Support Forums and Community
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    Jun 2009
    Location
    India
    Posts
    27

    User directory and 403 Forbidden error problem for apache server

    Hi,


    i am writing a simple web application in php.I am using Fedora 14.I have installed apache web server and php on my machine.

    i want to change the default directory,I made changes from the information i had after after searching on internet.but i was unsuccessful at my attempt.

    Now i am using the default directory /var/www/html..
    I copied all my website file to this location .

    Now when i am starting server i am getting error in browser saying 404 Forbidden".

    I am totally new so can any one help me in this.

    I also tried changing permission of the folder.but didnt work.

    Can anyone give step by step solution to both the problems mentioned

  2. #2
    Join Date
    Jul 2011
    Posts
    19

    Re: User directory and 403 Forbidden error problem for apache server

    Hi,
    try change DocumentRoot in your httpd.conf file to "/var/www/html" or what ever you want
    then run: chmod 7777 /var/www/html
    I will work!

  3. #3
    Join Date
    Jun 2009
    Location
    India
    Posts
    27

    Re: User directory and 403 Forbidden error problem for apache server

    thanks qwert,

    server is getting started.now problem is i am facing forbidden 403 error.how do i fix it.


    i have changes the permission for DocumentRoot to 777.

    Any help on this

  4. #4
    Join Date
    Oct 2006
    Location
    新加坡
    Posts
    997

    Re: User directory and 403 Forbidden error problem for apache server

    This looks like a SELINUX issue. Did you use "cp" or "mv" command? The "cp" command copies the files over in the /var/www/html with the correct SELINUX context, while the "mv" command does not. In any case, you may use the following command to verify the files.
    Code:
    $ ls -Z
    And use this to fix them
    Code:
    # chcon -R -t httpd_sys_content_t /var/www/html
    I would not suggest 777 for file permission. Unless you have specific reason, 644 for normal files is sufficient.
    YaoWT - Leave no window unbroken ♪ (^。^) 

  5. #5
    Join Date
    Jun 2009
    Location
    India
    Posts
    27

    Re: User directory and 403 Forbidden error problem for apache server

    No i didnt copy any files from /var/www/html folder.

    But i tried to did it but it is giving error "/var/www/html ommitted"

    i use chcon command .command was executed properly.

    what should i do now.

  6. #6
    Join Date
    Oct 2006
    Location
    新加坡
    Posts
    997

    Re: User directory and 403 Forbidden error problem for apache server

    You have misunderstood me. I was asking how did you do this copying?
    Now i am using the default directory /var/www/html..
    I copied all my website file to this location .
    Can you provide the output of this command.
    Code:
    $ cd /var/www/html
    $ ls -Z
    The correct SELINUX context of the file in this folder should looks something like this.
    unconfined_u:object_r:httpd_sys_content_t:s0 index.html
    YaoWT - Leave no window unbroken ♪ (^。^) 

  7. #7
    Join Date
    Jun 2009
    Location
    India
    Posts
    27

    Re: User directory and 403 Forbidden error problem for apache server

    i have executed the above command i got this output

    Code:
    drwxrwxr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 mp3
    -rw-r--r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 music.html
    -rw-rw-r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 music.php
    -rwxrwxrwx. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 play.htm
    -rw-rw-r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 play.php
    -rwxrwxrwx. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 Roshni Se - Asoka 03.mp3
    -rw-r--r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 test.php
    but my default directory is /home/user101/public_html

    the output of ls -Z on /home/user101/public_html is

    Code:
    -rwxr-xr-x. user101 user101 unconfined_u:object_r:httpd_user_content_t:s0 index.html
    -rwxr-xr-x. user101 user101 unconfined_u:object_r:httpd_user_content_t:s0 index.php
    -rwxr-xr-x. user101 user101 unconfined_u:object_r:httpd_user_content_t:s0 music.html
    -rwxr-xr-x. user101 user101 unconfined_u:object_r:httpd_user_content_t:s0 test.php

  8. #8
    Join Date
    Oct 2006
    Location
    新加坡
    Posts
    997

    Re: User directory and 403 Forbidden error problem for apache server

    So, where is exactly your DocumentRoot?
    YaoWT - Leave no window unbroken ♪ (^。^) 

  9. #9
    Join Date
    Jun 2009
    Location
    India
    Posts
    27

    Re: User directory and 403 Forbidden error problem for apache server

    My document root is
    Code:
     /home/user101/public_html

  10. #10
    Join Date
    Feb 2009
    Posts
    72

    Re: User directory and 403 Forbidden error problem for apache server

    The document root is the directory from which you want to serve your web pages. Set that by editing /etc/httpd/conf/httpd.conf

    Assuming that you intend for /var/www/html to be your document root, the file ownership and permissions and selinux contexts appear to be set reasonably (for some php functions it's necessary to use the httpd_rw_sys_content_t context and set the corresponding boolean in selinux, but mostly the httpd_sys_content_t should work). If /home/user101/public_html is your root directory, you should probably change file ownership to apache, unless httpd.conf is set up for user directories:

    Code:
    chown -R apache:apache /home/user101/public_html
    The other thing you need to check: make sure that port 80 is open on any firewalls! You can access the firewall in your Fedora installation from the Administration menu. If you are using a wireless router, there is probably another firewall there you need to have open.

    Donald

  11. #11
    Join Date
    Jun 2009
    Location
    India
    Posts
    27

    Re: User directory and 403 Forbidden error problem for apache server

    I have checked the firewall setting, change the owner of directory ,but still same problem

    Sharing my httpd.conf file in attachment. Is something wrong in it ?

    i trying this from week..and still its not working ?
    Attached Files Attached Files

  12. #12
    Join Date
    Oct 2006
    Location
    新加坡
    Posts
    997

    Re: User directory and 403 Forbidden error problem for apache server

    You are not doing it correctly. Now I understand what you are trying to do. You want to have a "user dir". For that, you don't have to modify the DocumentRoot in the httpd.conf, so revert it back to "/var/www/html". Instead, what you need to do is to uncomment and comment the below the userdir section in the httpd.conf as so.

    <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).
    #
    #UserDir disabled

    #
    # 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>


    ---------- Post added at 12:23 AM ---------- Previous post was at 12:16 AM ----------

    After that, you still have to deal with SELINUX and file permission setup in order to allow "apache" to access your files.

    One way to do this is:
    1. set your home folder "/home/user101" permission to 711.
    2. set your "public_html" folder permission to 755.
    3. set your files in the "public_html" folder permission to 644.
    4. chcon -t httpd_sys_content_t /home/user101.
    5. chcon -R -t httpd_sys_content_t /home/user101/public_html.
    YaoWT - Leave no window unbroken ♪ (^。^) 

  13. #13
    Join Date
    Jun 2009
    Location
    India
    Posts
    27

    Re: User directory and 403 Forbidden error problem for apache server

    oh thanks...i did what u said and after typing www.myapp.com in adress it gives default page.


    But what i want is to store all my html and php files under /home/user101/public_html directory.

    i have index.html in /home/user101/public_html but now when i am trying to access it it gives 404 error

  14. #14
    Join Date
    Oct 2006
    Location
    新加坡
    Posts
    997

    Re: User directory and 403 Forbidden error problem for apache server

    sigh. Have you tried http://localhost/~user101?
    YaoWT - Leave no window unbroken ♪ (^。^) 

  15. #15
    Join Date
    Jun 2009
    Location
    India
    Posts
    27

    Re: User directory and 403 Forbidden error problem for apache server

    Finally it worked...yeppie....thanks ...thank you so much...

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Forbidden Error - Apache, Fedora11
    By singhspk in forum Using Fedora
    Replies: 12
    Last Post: 21st December 2009, 12:25 AM
  2. F11 Apache 403 Forbidden using alias directory
    By douglazb in forum Using Fedora
    Replies: 1
    Last Post: 20th November 2009, 10:58 AM
  3. Apache Server: Access forbidden...
    By InKo in forum Servers & Networking
    Replies: 4
    Last Post: 23rd March 2007, 10:18 AM
  4. ~user/folder/ forbidden apache
    By root in forum Using Fedora
    Replies: 2
    Last Post: 12th September 2005, 10:38 PM
  5. [FC3]Apache - Forbidden when accessin virtual server
    By komi in forum Servers & Networking
    Replies: 1
    Last Post: 18th August 2005, 09:06 PM

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
  •