Apache default code in /var/www/html

So i want to display my application in place of default apache web server page and I will place my files from /opt/food directory into /var/ww/html directory which I understood but if i want to first check what already is there in that /var/ww/html directory then i am getting no output from :

thor@host01 ~$ sudo ls /var/www/html
thor@host01 ~$

How then the default page works is what i need some help in understanding?

If ls shows no files, and especially with sudo then there are no files

then how come apache is showing the default page?

Have you checked the apache config file? It may be pointing to a different directory.

Yes, checked

DocumentRoot “/var/www/html”
<Directory “/var/www”>
AllowOverride None
# Allow open access:
Require all granted

and there are no files in that directory

thor@host01 ~$ cd /var/www/html
thor@host01 /var/www/html$ ls
thor@host01 /var/www/html$

little confusing as how the default page is working

Are you using any particular lab (link please), or is this a lodeklud engineer question (in which case it should be asked in KodeKloud Engineer - KodeKloud - DevOps Learning Community)

This is how the magic happens

sudo ls -l /etc/httpd/conf.d

You should see

total 16
-rw-r--r-- 1 root root  400 Aug 17 14:09 README
-rw-r--r-- 1 root root 2926 Aug 17 14:08 autoindex.conf
-rw-r--r-- 1 root root 1252 Aug 17 14:06 userdir.conf
-rw-r--r-- 1 root root  574 Aug 17 14:06 welcome.conf

Now examine welcome.conf

sudo cat /etc/httpd/conf.d/welcome.conf

Notice the Directory and Alias directives. These point to an alternative index.html which is used if there is no content in /var/www/html

1 Like