Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Apache does not have permission to access webpage.

  1. #1
    Join Date
    Dec 2010
    Beans
    136
    Distro
    Ubuntu 14.04 Trusty Tahr

    Apache does not have permission to access webpage.

    Apologies if you think I haven't researched about this issue, but I believe it's to do with file/folder permissions, which I am not capable to do (yet).
    Basically I have a LAMP set up (apache2 and php5) and I tried to change a documentroot folder to one in my home directory and when I try to access a site file, the apache complained I 'do not have permission' to access this site.
    Can anyone help me with this permission issue?
    Thanks
    "If you are in hell, keep going." Winston Churchil
    ubuntucrazygeek.blogspot.com
    http://motivatedsuccess.tumblr.com/
    http://pavelexpertov.tumblr.com/

  2. #2
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Apache does not have permission to access webpage.

    Quote Originally Posted by pavelexpertov View Post
    Apologies if you think I haven't researched about this issue, but I believe it's to do with file/folder permissions, which I am not capable to do (yet).
    Basically I have a LAMP set up (apache2 and php5) and I tried to change a documentroot folder to one in my home directory and when I try to access a site file, the apache complained I 'do not have permission' to access this site.
    Can anyone help me with this permission issue?
    Thanks
    Let's assume for now that the problem is to do with permissions within the filesystem and not within apache configuration. In this case, paste the following into a script file e.g. ~/bin/pathperms.sh
    Code:
    #!/bin/bash
    
    filename="$1"
    if [ "$filename" = "" ] ; then
        echo Usage: pathperms.sh filename
        exit 1
    fi
    
    ls -ld "$filename"
    dir=$( realpath "$filename")
    dir=$( dirname "$dir")
    while [ "$dir" != "/" ]
    do
        ls -ld "$dir"
        dir=$( dirname "$dir")
    done
    exit 0
    Then run e.g.
    Code:
    chmod +x ~/bin/pathperms.sh
    ~/bin/pathperms.sh /path/to/the/site/file
    and post the output.

  3. #3
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Apache does not have permission to access webpage.

    Quote Originally Posted by pavelexpertov View Post
    Apologies if you think I haven't researched about this issue, but I believe it's to do with file/folder permissions, which I am not capable to do (yet).
    Basically I have a LAMP set up (apache2 and php5) and I tried to change a documentroot folder to one in my home directory and when I try to access a site file, the apache complained I 'do not have permission' to access this site.
    Can anyone help me with this permission issue?
    Thanks
    It's probably permissions. You can see the exact error message in Apache's error log and from that know which directory it is trying and exactly why it is failing.

    Code:
    tail -f /var/log/apache2/error.log
    If your DocumentRoot is /home/pavelexpertov/www/htdocs/ then you need to make sure that the web server has read (rx) access to it and lookup access (x) to those above it. The simplest way is to provide that access to Other rather than a specific group or trying with ACLs.

    Code:
    sudo chmod o+x /home/
    sudo chmod o+x /home/pavelexpertov/
    chmod o+rx /home/pavelexpertov/www/
    chmod o+rx /home/pavelexpertov/www/htdocs/

  4. #4
    Join Date
    Dec 2010
    Beans
    136
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Apache does not have permission to access webpage.

    I have created the script and ran it (/home/adminpav/bin/pathperms.sh /home/adminpav/webfolder/index.html) and then I got an error message I believe:
    /home/adminpav/bin/pathperms.sh: line 3: filename: command not found
    Usage: pathperms.sh filename
    "If you are in hell, keep going." Winston Churchil
    ubuntucrazygeek.blogspot.com
    http://motivatedsuccess.tumblr.com/
    http://pavelexpertov.tumblr.com/

  5. #5
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Apache does not have permission to access webpage.

    Quote Originally Posted by pavelexpertov View Post
    I have created the script and ran it (/home/adminpav/bin/pathperms.sh /home/adminpav/webfolder/index.html) and then I got an error message I believe:
    /home/adminpav/bin/pathperms.sh: line 3: filename: command not found
    Usage: pathperms.sh filename
    It would appear that on line 3 of my script you have a space between the filename and the =. I don't know how that could have occurred using copy and paste since it's definitely not there in what I posted.

    The strategy outlined by Lars Noodén should suffice for you. More than likely it is your home directory that is drwx------ or drwxr-x--- but in the absence of information we can only guess.

  6. #6
    Join Date
    Dec 2010
    Beans
    136
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Apache does not have permission to access webpage.

    Lars nooden, I tried your code with chmod and unfortunately that does not solve the problem, should I try to tail down the error message by using tail command.
    spjackson, sorry I used vi to do the thing
    "If you are in hell, keep going." Winston Churchil
    ubuntucrazygeek.blogspot.com
    http://motivatedsuccess.tumblr.com/
    http://pavelexpertov.tumblr.com/

  7. #7
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Apache does not have permission to access webpage.

    Yes, with the exact error message from error.log we can make our guesses more precise.

  8. #8
    Join Date
    Dec 2010
    Beans
    136
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Apache does not have permission to access webpage.

    spjackson: I just copied and pasted the code and I ran the shell script (after applying Lars's code) and the terminal is now printing the same message in a loop:
    drwxr-xr-x 22 adminpav adminpav 4096 Jul 20 15:26 .

    PS I am running lubuntu 14.04
    "If you are in hell, keep going." Winston Churchil
    ubuntucrazygeek.blogspot.com
    http://motivatedsuccess.tumblr.com/
    http://pavelexpertov.tumblr.com/

  9. #9
    Join Date
    Dec 2010
    Beans
    136
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Apache does not have permission to access webpage.

    Right, I ran the tail command and that's what I got ( i believe
    it's two lines at the end):
    1:51316] AH01630: client denied by server configuration: /home/adminpav/webfolder/favicon.ico
    [Mon Jul 20 15:21:59.940874 2015] [authz_core:error] [pid 2317] [client 127.0.0.1:51317] AH01630: client denied by server configuration: /home/adminpav/webfolder/index.html
    [Mon Jul 20 15:22:26.131643 2015] [authz_core:error] [pid 2318] [client 127.0.0.1:51318] AH01630: client denied by server configuration: /home/adminpav/webfolder/index.html
    [Mon Jul 20 15:23:30.209217 2015] [authz_core:error] [pid 2319] [client 127.0.0.1:51319] AH01630: client denied by server configuration: /home/adminpav/webfolder/index.html
    [Mon Jul 20 15:23:31.005270 2015] [authz_core:error] [pid 2319] [client 127.0.0.1:51319] AH01630: client denied by server configuration: /home/adminpav/webfolder/index.html
    [Mon Jul 20 15:26:03.456387 2015] [mpm_prefork:notice] [pid 1204] AH00169: caught SIGTERM, shutting down
    [Mon Jul 20 15:26:15.957460 2015] [mpm_prefork:notice] [pid 1208] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.11 configured -- resuming normal operations
    [Mon Jul 20 15:26:15.958164 2015] [core:notice] [pid 1208] AH00094: Command line: '/usr/sbin/apache2'
    [Mon Jul 20 15:26:36.343288 2015] [authz_core:error] [pid 1220] [client 127.0.0.1:60650] AH01630: client denied by server configuration: /home/adminpav/webfolder/index.html
    [Mon Jul 20 15:26:36.421646 2015] [authz_core:error] [pid 1220] [client 127.0.0.1:60650] AH01630: client denied by server configuration: /home/adminpav/webfolder/favicon.ico
    "If you are in hell, keep going." Winston Churchil
    ubuntucrazygeek.blogspot.com
    http://motivatedsuccess.tumblr.com/
    http://pavelexpertov.tumblr.com/

  10. #10
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Apache does not have permission to access webpage.

    Ok. Do you have a Directory or Location directive set for /home/adminpav/webfolder/ in your Apache2 virtual host's configuration file? You can try copying the stanza for the old document root and using that. In addition to having read access via the filesystem, the virtual host has to be told that it is ok to read the files there.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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