amazon-web-servicesserverlampbitnamivhosts

Unable to Configure Virtual Hosts on Bitnami LAMP (AWS Lightsail) – Domains Not Pointing to Specific Directories


I'm running a Bitnami LAMP stack on an AWS Lightsail instance and trying to set up Virtual Hosts so that two domains point to different directories within htdocs. Specifically, I want:

domain1.fr to point to /opt/bitnami/apache/htdocs/domain1 domain2.fr to point to /opt/bitnami/apache/htdocs/domain2

First, I configured Route53 to add DNS Routes. I also used bitnami/bncert-tool to enable HTTPS on both domain

Then, following tutorials, I created a configuration file /opt/bitnami/conf/vhost/myapp-vhosts.conf that now looks like this :

<VirtualHost *:80>
   ServerName domaine1.fr
   DocumentRoot "/opt/bitnami/apache/htdocs/domain1"
   <Directory "/opt/bitnami/apache/htdocs/domain1">
      AllowOverride All
      Require all granted
   </Directory>
</VirtualHost>

<VirtualHost *:80>
   ServerName domaine2.fr
   DocumentRoot "/opt/bitnami/apache/htdocs/domain2"
   <Directory "/opt/bitnami/apache/htdocs/domain2">
      AllowOverride All
      Require all granted
   </Directory>
</VirtualHost>

I also updated this file /opt/bitnami/conf/httpd.conf :

<Directory />
    AllowOverride all
    Require all denied
</Directory>
<Directory "/opt/bitnami/apache/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride all
    Require all granted
</Directory>

Both AllowOverride were changed from none to all

I also added the following line Include "/opt/bitnami/apache/conf/vhosts/myapp-vhosts.conf"

Finaly, I restarted apache sudo /opt/bitnami/ctlscript.sh restart apache

Result is that nothing changed. When I reach https://domain1.fr, the default index page appears (/opt/bitnami/apache/htdocs/index.php)

Do you have any idea on how to fix my issue ?

Thanks :)


Solution

  • Ok I find how to do it. I'm sharing it for anyone in need :

    In the /opt/bitnami/conf/httpd.conf, no need for include

    Include should be added at the end of the following file /opt/bitnami/apache/conf/bitnami/bitnami.conf

    For https redirection, I created a other vhost configuration file : myapp-https-vhosts.conf with the SSL Certificate ans de 443 port as explained here : https://docs.bitnami.com/general/infrastructure/lamp/configuration/configure-custom-application/

    This file should also be included in bitnami.conf