Score:0

I get directory listing instead of the website index.php

cn flag

Ubuntu 20.04, Apache 2.4, PHP5.6

I have website with the following vhost config

<VirtualHost *:80>
      ServerAdmin [email protected]
      ServerName website.com
      ServerAlias www.website.com
      DocumentRoot /var/www/html/site_admin/public_html
      # Directory path where code exists
        <Directory /var/www/html/site_admin/public_html>
                Options -Indexes +FollowSymLinks +MultiViews
                DirectoryIndex index.php
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/website.com-error.log
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel error
        CustomLog ${APACHE_LOG_DIR}/website.com.log combined
</VirtualHost>

.htaccess is disabled

/etc/apache2/apache2.conf has the following Directory module

<Directory />
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

This is the website directory:

ll /var/www/html/site_admin/public_html/
total 2120
drwxrwxrwx 10 www-data www-data    6144 Dec  6 15:01  ./
drwxrwxrwx  3 www-data www-data    6144 Dec  6 03:37  ../
-rwxrwxrwx  1 www-data www-data     283 Dec  6 03:45  .gitignore*
-rwxrwxrwx  1 www-data www-data   14016 Dec  6 15:00  .htaccess.bck*
-rwxrwxrwx  1 www-data www-data     305 Dec  6 03:45  .project*
-rwxrwxrwx  1 www-data www-data      23 Dec  6 03:45  HEAD*
-rwxrwxrwx  1 www-data www-data  343872 Dec  6 03:45 'Hi tea menu.pdf'*
drwxrwxrwx 15 www-data www-data    6144 Dec  6 03:35  application/
drwxrwxrwx 13 www-data www-data    6144 Dec  6 03:35  assets/
-rwxrwxrwx  1 www-data www-data     339 Dec  6 03:45  composer.json*
-rwxrwxrwx  1 www-data www-data   65865 Dec  6 03:45  composer.lock*
-rwxrwxrwx  1 www-data www-data 1640731 Dec  6 03:45  composer.phar*
-rwxrwxrwx  1 www-data www-data      66 Dec  6 03:45  config*
-rwxrwxrwx  1 www-data www-data      73 Dec  6 03:45  description*
-rwxrwxrwx  1 www-data www-data      66 Dec  6 03:45  desktop.ini*
-rwxrwxrwx  1 www-data www-data       0 Dec  6 03:45  error.log*
-rwxrwxrwx  1 www-data www-data       0 Dec  6 03:45  git*
drwxrwxrwx  2 www-data www-data    6144 Dec  6 03:35  hooks/
drwxrwxrwx  2 www-data www-data   14336 Dec  6 03:35  images/
-rwxrwxrwx  1 www-data www-data    6461 Dec  6 03:45  index.php*
drwxrwxrwx  2 www-data www-data    6144 Dec  6 03:35  info/
-rwxrwxrwx  1 www-data www-data    2496 Dec  6 03:45  license.txt*
drwxrwxrwx  8 www-data www-data    6144 Dec  6 03:35  system/
drwxrwxrwx  3 www-data www-data    6144 Dec  6 03:35  uploads/
drwxrwxrwx 22 www-data www-data    6144 Dec  6 03:36  vendor/

When I try to browse the website at https://website.com, I get directory structure

instead of the actual website

Please advise

in flag
That Virtualhost is for http. You are accessing the server via https. A different VirtualHost block matches that points to /var/www/html/
igalsc avatar
cn flag
@GeraldSchneider I've added the same block for <VirtualHost *:443> but still get the same
Score:0
cl flag

Is php installed? What does php.info give you? Also It seems all files have full 777 permission which a security risk.

igalsc avatar
cn flag
yes, php is installed.
igalsc avatar
cn flag
https://imgur.com/a/qYYtNkk
igalsc avatar
cn flag
And thank you for reminding regarding the permissions - I updated it
Score:0
cn flag

I figured the issue. In my /etc/apache2/apache2.conf, at the end, I had

# Include the virtual host configurations:
IncludeOptional /mnt/efs/fs1/sites-enabled/*.conf

This was due to Apache2 non-default root directory multiple websites 403 forbidden configuration

Once I changed this part to

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

The site started working

Thanks

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.