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

Thread: Problem installing apache webserver: “You don't have permission to access this resour

Hybrid View

  1. #1
    Join Date
    Nov 2019
    Beans
    7

    Problem installing apache webserver: “You don't have permission to access this resour

    When I go in my browser to http://localhost, I get this:

    Forbidden

    You don't have permission to access this resource.

    Apache/2.4.29 (Ubuntu) Server at localhost Port 80


    I installed a new version of Ubuntu on my computer. Ubuntu 18.04.3 LTS



    The files for my website are on another disk. See program tools → disks
    Device: dev/sdb1
    Partition type: Linux Contence: Ext4(versie 1.0) – Mounted on /media/joris/doc


    I did following:

    source: https://tutorials.ubuntu.com/tutoria...igure-apache#1




    sudo apt update
    sudo apt install apache2
    cd /etc/apache2/sites-available/
    sudo cp 000-default.conf gci.conf


    sudo gedit gci.conf
    DocumentRoot media/joris/doc/website


    sudo a2ensite gci.conf
    service apache2 reload
    sudo adduser joris www-data
    sudo chown -R www-data:www-data /media/joris/doc/website
    sudo chmod -R g+rw /media/joris/doc/website




    P.S. I live in Belgium and I speak Dutch. Exist also a dutch forum
    of ubuntu?

  2. #2
    Join Date
    Feb 2010
    Location
    In My Food Forest
    Beans
    9,318

    Re: Problem installing apache webserver: “You don't have permission to access this re

    Moved to Server Platforms sub-forum.
    Cheers & Beers, uRock
    [SIGPIC][/SIGPIC]

  3. #3
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,521
    Distro
    Ubuntu Development Release

    Re: Problem installing apache webserver: “You don't have permission to access this re

    Hi,

    I just pointed you to an answer over on your askubuntu question.
    Now, I'll point you to an answer here: https://ubuntuforums.org/showthread....3#post13884703

    But also copy it below:

    If you want to use a non-stanadard directory, and in addition to all the permissions stuff, you have to tell apache to allow it via the /etc/apache2/apache2.conf file.
    Just copy the /var/www/html stantza stuff to whatever, example:

    Code:
    <Directory /var/www/>
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
    
    <Directory /media/newhd/test_web/>
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
    Last edited by Doug S; November 20th, 2019 at 04:59 PM.
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Problem installing apache webserver: “You don't have permission to access this re

    Code:
    DocumentRoot media/joris/doc/website
    uses a relative path. It must be an absolute path. Also, that directory needs to be open enough for the apache userid, www-data, to read.

    If the storage isn't using a Linux file system, then only storage mount options can control the needed permissions.

  5. #5
    Join Date
    Nov 2019
    Beans
    7

    Re: Problem installing apache webserver: “You don't have permission to access this re

    My contence of etc/apache2/sites-available/gci.conf


    Code:
    <VirtualHost *:80>
         # The ServerName directive sets the request scheme, hostname and port that
         # the server uses to identify itself. This is used when creating
         # redirection URLs. In the context of virtual hosts, the ServerName
         # specifies what hostname must appear in the request's Host: header to
         # match this virtual host. For the default virtual host (this file) this
         # value is not decisive as it is used as a last resort host regardless.
         # However, you must set it for any further virtual host explicitly.
         #ServerName www.example.com
     
     
         ServerAdmin webmaster@localhost
         # DocumentRoot /var/www/html
         DocumentRoot /media/joris/doc/website
         # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
         # error, crit, alert, emerg.
         # It is also possible to configure the loglevel for particular
         # modules, e.g.
         #LogLevel info ssl:warn
     
     
         ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined
     
     
         # For most configuration files from conf-available/, which are
         # enabled or disabled at a global level, it is possible to
         # include a line for only one particular virtual host. For example the
         # following line enables the CGI configuration for this host only
         # after it has been globally disabled with "a2disconf".
         #Include conf-available/serve-cgi-bin.conf
     </VirtualHost>






    Contence of:
    etc/apache2/apache2.conf
    first try: (I forgot to mention it in my first mail)

    Code:
     <Directory />
         Options FollowSymLinks
         AllowOverride None
         Require all denied
     </Directory>
     
     
     <Directory /usr/share>
         AllowOverride None
         Require all granted
     </Directory>
     
     
     #<Directory /var/www/>
     <Directory /media/joris/website/>
         Options Indexes FollowSymLinks
         AllowOverride None
         Require all granted
     </Directory>




    Second try:
    Code:
     <Directory />
         Options FollowSymLinks
         AllowOverride None
         Require all denied
     </Directory>
     
     
     <Directory /usr/share>
         AllowOverride None
         Require all granted
     </Directory>
     
     
     <Directory /var/www/>
     Options Indexes FollowSymLinks
         AllowOverride None
         Require all granted
     </Directory>
     
     
     <Directory /media/joris/website/>
         Options Indexes FollowSymLinks
         AllowOverride None
         Require all granted
     </Directory>

    Now I have the problem that my site is not shown! I get this:
    The default site of Apache!

    Apache2 Ubuntu Default Page


    It works!

  6. #6
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Problem installing apache webserver: “You don't have permission to access this re

    If you want to point the server to non-standard directories, the easiest method to use an Alias directive. E.g.,

    Code:
    <VirtualHost *:80>
    [stuff]
    
    Alias /joris /media/joris/website
     
    <Directory /media/joris/website/>
         Options Indexes FollowSymLinks
         AllowOverride None
         Require all granted
    </Directory>
    
    [stuff]
    </VirtualHost>
    Now, after restarting the server, the URL http://localhost/joris will use the /media/joris/website directory.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  7. #7
    Join Date
    Nov 2019
    Beans
    7

    Re: Problem installing apache webserver: “You don't have permission to access this re

    Quote Originally Posted by SeijiSensei View Post
    If you want to point the server to non-standard directories, the easiest method to use an Alias directive. E.g.,

    Code:
    <VirtualHost *:80>
    [stuff]
    
    Alias /joris /media/joris/website
     
    <Directory /media/joris/website/>
         Options Indexes FollowSymLinks
         AllowOverride None
         Require all granted
    </Directory>
    
    [stuff]
    </VirtualHost>
    Now, after restarting the server, the URL http://localhost/joris will use the /media/joris/website directory.
    I did this in /etc/apache2/sites-available/gci.conf
    Code:
    Alias /joris /media/joris/doc/website
     
    <Directory /media/joris/doc/website/>
         Options Indexes FollowSymLinks
         AllowOverride None
         Require all granted
    </Directory>

    But it doesn't work!

    http://localhost/joris give:

    Not Found

    The requested URL was not found on this server.


    Apache/2.4.29 (Ubuntu) Server at localhost Port 80

  8. #8
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Problem installing apache webserver: “You don't have permission to access this re

    Quote Originally Posted by jorisvh2 View Post
    I did this in /etc/apache2/sites-available/gci.conf

    http://localhost/joris give:

    Not Found

    The requested URL was not found on this server.

    Apache/2.4.29 (Ubuntu) Server at localhost Port 80
    First, try using
    Code:
    Alias /joris/ /media/joris/website/
    Sometimes having both leading and trailing slashes works better.

    I'd also examine the log in /var/log/apache2 to see if they provide more detailed information.

    Did you restart Apache? Did you run "sudo a2ensite gci" to "activate" the site? Check in /etc/apache2/sites-enabled and make sure there is a symbolic link to /etc/apache2/sites-available/gci.conf.

    Earlier you suggested you had copied 000-default.conf to gci.conf. I'd delete or otherwise disable 000-default.conf. Apache parses these files in alphanumeric order which is why 000-default has the name it does.

    If none of that helps, I'd suggest moving the /etc/apache2 directory to /etc/apache2.old, then reinstalling apache2. Rename 000-default.conf to gci.conf if you like, but have just one instance of this configuration. Add the Alias directive and <Directory> stanza to that file and leave apache2.conf alone. Run a2ensite and restart apache2. Any better?

    Here, for example, is part of the configuration file for one of the virtual hosts on a server I manage:

    Code:
    <VirtualHost *:80>
        
    ServerName      www.example.com
    ServerAlias     example.com
    ServerAdmin     admin@example.com
    DocumentRoot    /var/www/html/wordpress
    ErrorLog        logs/error_log-example.com
    TransferLog     logs/access_log-example.com
    CustomLog       logs/referer_log-example.com "%h: %{referer}i -> %U"
    
    Alias /gallery/ /home/web/gallery/
    <Directory "/home/web/gallery">
        Options All
    </Directory>
    
    <Directory /var/www/html/wordpress>
    [etc.]
    </Directory>
    
    </VirtualHost>
    The site runs WordPress from /var/www/html/wordpress, but serves up files from /home/web/gallery/ when using the URI /gallery/.
    Last edited by SeijiSensei; November 20th, 2019 at 09:14 PM.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  9. #9
    Join Date
    Nov 2019
    Beans
    7

    Re: Problem installing apache webserver: “You don't have permission to access this re

    My contence of etc/apache2/sites-available/gci.conf


    Code:
    <VirtualHost *:80>
         # The ServerName directive sets the request scheme, hostname and port that
         # the server uses to identify itself. This is used when creating
         # redirection URLs. In the context of virtual hosts, the ServerName
         # specifies what hostname must appear in the request's Host: header to
         # match this virtual host. For the default virtual host (this file) this
         # value is not decisive as it is used as a last resort host regardless.
         # However, you must set it for any further virtual host explicitly.
         #ServerName www.example.com
     
     
         ServerAdmin webmaster@localhost
         # DocumentRoot /var/www/html
         DocumentRoot /media/joris/doc/website
         # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
         # error, crit, alert, emerg.
         # It is also possible to configure the loglevel for particular
         # modules, e.g.
         #LogLevel info ssl:warn
     
     
         ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined
     
     
         # For most configuration files from conf-available/, which are
         # enabled or disabled at a global level, it is possible to
         # include a line for only one particular virtual host. For example the
         # following line enables the CGI configuration for this host only
         # after it has been globally disabled with "a2disconf".
         #Include conf-available/serve-cgi-bin.conf
     </VirtualHost>






    Contence of:
    etc/apache2/apache2.conf
    first try: (I forgot to mention it in my first mail)

    Code:
     <Directory />
         Options FollowSymLinks
         AllowOverride None
         Require all denied
     </Directory>
     
     
     <Directory /usr/share>
         AllowOverride None
         Require all granted
     </Directory>
     
     
     #<Directory /var/www/>
     <Directory /media/doc/joris/website/>
         Options Indexes FollowSymLinks
         AllowOverride None
         Require all granted
     </Directory>




    Second try:
    Code:
     <Directory />
         Options FollowSymLinks
         AllowOverride None
         Require all denied
     </Directory>
     
     
     <Directory /usr/share>
         AllowOverride None
         Require all granted
     </Directory>
     
     
     <Directory /var/www/>
     Options Indexes FollowSymLinks
         AllowOverride None
         Require all granted
     </Directory>
     
     
     <Directory /media/doc/joris/website/>
         Options Indexes FollowSymLinks
         AllowOverride None
         Require all granted
     </Directory>

    Now I have the problem that my site is not shown! I get this:
    The default site of Apache!

    Apache2 Ubuntu Default Page


    It works!

  10. #10
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Problem installing apache webserver: “You don't have permission to access this re

    On Ubuntu/Debian you never need to edit the apache2.conf file. All your configurations should be in the .conf files in /etc/apache2/sites-available. Have you read this: https://help.ubuntu.com/lts/serverguide/httpd.html? Any Alias directives and associated <Directory> stanzas need to be inside a <VirtualHost> container in a file like gci.conf.
    Last edited by SeijiSensei; November 20th, 2019 at 05:51 PM.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

Page 1 of 2 12 LastLast

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
  •