Search code examples
.htaccessphpmailerbitnamiamazon-lightsail

Lightsail Bitnami HTTP-Only Application


HTTP-Only Application in Lightsail seems to not popular.

  • Where is right place for the html application;

('/home/bitnami/projects/myapp', '/opt/bitnami/apps/myapp', 'opt\bitnami\apache\htdocs')

  • Where and how locate rule for remove 'myapp' from url (www.myDomain.com/myapp);
  • Where should be 'amazon-ses-smtp-sample.php' and how to prevent them to access from url;

Solution

  • Bitnami Engineer here, you will need to follow the next steps to deploy your custom application on top of a Bitnami solution

    • Create the same structure used by Bitnami when installing Bitnami PHP applications. To do this, run these commands:
    sudo mkdir /opt/bitnami/myapp
    sudo chown -R bitnami:daemon /opt/bitnami/myapp
    sudo chmod -R g+w /opt/bitnami/myapp
    
    • Create and edit the /opt/bitnami/apache2/conf/vhosts/myapp-vhost.conf file and add the configuration block shown below:
    <VirtualHost 127.0.0.1:80 _default_:80>
      ServerAlias *
      DocumentRoot /opt/bitnami/myapp
      <Directory "/opt/bitnami/myapp">
        Options -Indexes +FollowSymLinks -MultiViews
        AllowOverride All
        Require all granted
      </Directory>
    </VirtualHost>
    
    • Create and edit the /opt/bitnami/apache2/conf/vhosts/myapp-https-vhost.conf file and add the configuration block shown below:
    <VirtualHost 127.0.0.1:443 _default_:443>
      ServerAlias *
      DocumentRoot /opt/bitnami/myapp
      SSLEngine on
      SSLCertificateFile "/opt/bitnami/apache2/conf/bitnami/certs/server.crt"
      SSLCertificateKeyFile "/opt/bitnami/apache2/conf/bitnami/certs/server.key"
      <Directory "/opt/bitnami/myapp">
        Options -Indexes +FollowSymLinks -MultiViews
        AllowOverride All
        Require all granted
      </Directory>
    </VirtualHost>
    
    • Restart the Apache server:
    sudo /opt/bitnami/ctlscript.sh restart apache
    

    You should now be able to access the application at http://SERVER-IP/.

    You can find more information about how to deploy the app here:

    https://docs.bitnami.com/aws/infrastructure/lamp/administration/create-custom-application-php/

    Regarding the amazon-ses-smtp-sample.php file, you will need to add the required rule in the .htaccess file inside the /opt/bitnami/myapp directory. Something similar to this

    <Files "amazon-ses-smtp-sample.php">  
      Require all denied
    </Files>