0

I am setting up an Apache2 webserver and for some reason, it doesn't serve the files so I can access them via the web browser.
The document root is set to correctly and the files are owned by www-data (the same as the apache run as env variable).

If I try to access the file via ... .com/hello.txt, I get:

Not Found

The requested URL /hello.txt was not found on this server.
Apache/2.4.25 (Debian) Server at ....... Port 80

My configuration file (some commented lines removed):

<VirtualHost *:80>

    #serverName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /srv/www/linuxvm232b/public

    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    #Include conf-available/serve-cgi-bin.conf

    <Directory "/srv/www/linuxvm232b/public">
        AllowOverride None
        Require all granted
    </Directory>

</VirtualHost>

Original image

Directory listing:

root@linuxvm232:/etc/apache2/sites-available# ll /srv/www/linuxvm232b/public/
total 14
drwxr-xr-x 2 www-data www-data 6   Mar 4   14:58 assets
-rwxr-xr-x 1 www-data www-data 0   May 11  21:10 hello.txt
-rwxr-xr-x 1 www-data www-data 907 Mar 4   14:58 index.html
drwxr-xr-x 2 www-data www-data 4 Mar 4 14:58 src
root@linuxvm232:/etc/apache2/sites-available#

Original image

  • Please do not post pictures. You can copy & paste the text and use the {} (Code Sample) function instead. Did you enable your site using a2ensite linuxvm232b to symlink sites-available/linuxvm232b.conf in sites-enabled? Was the server restarted? What's in the log files? – Freddy May 12 at 8:50
  • It may be key here what you mean by ... .com/hello.txt. Is that a domain? Is it configured? What makes you think so? – Tomasz May 12 at 8:54
  • Yes the site is enabled and reachable via the domain, I just removed it for privacy reasons – Adem May 12 at 9:01
0

as I can see from your screenshots you are using the /srv directory to serve your files, which is not the default way on Debian as far as I can remember.

Make sure to check in /etc/apache2/apache2.conf that access for the apache server to the /srv directory is allowed as in the standard configuration, access to that directory is prohibited.

It should be a commented entry like this:

#<Directory /srv/>
#   Options Indexes FollowSymLinks
#   AllowOverride None
#   Require all granted
#</Directory>

Just uncomment that block and reload the apache2 via systemctl reload apache2 and directories in /srv should be able to be accessed.

Also be sure to have enabled the site via a2ensite linuxvm232b and systemctl reload apache2

  • Hey, thank you for answering, you were right, the block was commented, after uncommenting and reloading apache the page still doesn't get served. The site is already enabled – Adem May 12 at 8:58
  • Hm, I see that the ServerName entry is commented out. Does anything change if you uncomment that and put in the domain name your are trying to use (and reloading the apache afterwards)? – RoflCopter24 May 12 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.