Run multiple Laravel applications on single AWS Lightsail instance

Keywords: LAMP/MAMP/WAMP - AWS - Technical issue - Services (Apache, MariaDB, MySQL…)

bndiagnostic ID: cbd2cb24-3f99-386f-f5a2-76acc2a679dd

bndiagnostic output:

? Apache: Found possible issues
? Resources: Found possible issues
https://docs.bitnami.com/general/apps/wordpress/troubleshooting/debug-errors-apache/

bndiagnostic failure reason: The tool could not find any issue

Description:
I have the following two directories each having separate Laravel applications

/opt/bitnami/projects/kd-app-1
/opt/bitnami/projects/kd-app-2

My vhost files in /opt/bitnami/apache2/conf/vhosts look like so:

kd-app-1-https-vhost.conf

<VirtualHost 127.0.0.1:80 _default_:80>
  #  ServerAlias *
    DocumentRoot /opt/bitnami/projects/karma-daily-timing/public
  # BEGIN: Configuration for letsencrypt
  Include "/opt/bitnami/apps/letsencrypt/conf/httpd-prefix.conf"
  # END: Configuration for letsencrypt
  # BEGIN: Support domain renewal when using mod_proxy without Location
  <IfModule mod_proxy.c>
    ProxyPass /.well-known !
  </IfModule>
  # END: Support domain renewal when using mod_proxy without Location
  # BEGIN: Enable HTTP to HTTPS redirection
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^localhost
  RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
  RewriteCond %{REQUEST_URI} !^/\.well-known
  RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
  # END: Enable HTTP to HTTPS redirection
    <Directory "/opt/bitnami/projects/karma-daily-timing/public">
      Options -Indexes +FollowSymLinks -MultiViews
      AllowOverride All
      Require all granted
    </Directory>
  # BEGIN: Support domain renewal when using mod_proxy within Location
  <Location /.well-known>
    <IfModule mod_proxy.c>
      ProxyPass !
    </IfModule>
  </Location>
  # END: Support domain renewal when using mod_proxy within Location
</VirtualHost>

kd-app-2-https-vhost.conf

<VirtualHost 127.0.0.1:8888 _default_:8888>
#    ServerAlias *
    DocumentRoot /opt/bitnami/projects/kd-timer-DEV/public
    <Directory "/opt/bitnami/projects/kd-timer-DEV/public">
      Options -Indexes +FollowSymLinks -MultiViews
      AllowOverride All
      Require all granted
    </Directory>
  </VirtualHost>

As the vhosts show, I
expect app-1 to listen at the default 80 port and app-2 to listen at port 8888 something like http://server-ip:8888

The app-1 is listening properly but the app-2 is not listening.

What could be the issue?

Hi @burfbari,

You need to tell Apache to listen on that port, it’s configured in /opt/bitnami/apache2/conf/httpd.conf

Listen 80
Listen 8888

Regards,
Michiel

Hi @michiel

Thank you for your time and response.

I added the new port in the config and it seems to be listening as well:

sudo netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      1714/mysqld
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2319/sshd
tcp6       0      0 :::80                   :::*                    LISTEN      5845/httpd
tcp6       0      0 :::22                   :::*                    LISTEN      2319/sshd
tcp6       0      0 :::8888                 :::*                    LISTEN      5845/httpd
tcp6       0      0 :::443                  :::*                    LISTEN      5845/httpd

But the request http://server-ip:8888 times out.

Hi @burfbari,

Though Apache is listening to port 8888 now, you can only access it from localhost

 curl localhost:8888

To make it accesible publicly, you also need to open port 8888 in the AWS console:

https://docs.bitnami.com/aws/faq/administration/use-firewall/

Regards,
Michiel

1 Like

hi @michiel
thank you so much, it works!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.