How to setup and configure Magento

on Amazon Lightsail

Amazon Lightsail is an easy-to-use virtual private server provider and is the easiest way to get started on AWS. You can get a Magento eCommerce site up and running on Amazon Lightsail in just a few minutes. 

Follow along this tutorial to get an e-commerce site up and running for $10. 

About this Tutorial
Time 30 minutes   
Cost $10
Use Case Compute
Products Amazon Lightsail
Level 200
Last Updated August 11, 2021

Step 1: Create the Magento instance

Complete the following steps to get a Magento instance up and running on Lightail. 

1.1 — Login to your AWS account and navigate to the Lightsail console. If you do not have an AWS account, please sign up using the links provided. 

Already have an account? Log in to your account

1.2 — On the Instances tab of the Lightsail homepage, choose Create instance. 

1.3 — Choose the AWS Region and Availability Zone for your instance. 

1.4 — Choose your instance image. First choose Linux/Unix as the platform, then select Magento as the blueprint. 

1.5 — Choose your instance plan. Since upgrading the Magento applications and extensions you obtain from Magento Marketplaces and other sources can require up to 2GB of RAM, we recommend you use the $10 instance plan or larger.

1.6 — Enter a name for your instance. 

1.7 — Choose one of the following to add tags to your instance: 

Add key-only tags or Edit key-only tags (if tags have already been added). Enter your new tag into the tag key text box, and press Enter. Choose Save when you’re done entering your tags to add them, or choose Cancel to not add them. This is shown in the first screenshot. 

Or, Create a key-value tag, then enter a key into the Key text box, and a value into the Value text box. Choose Save when you’re done entering your tags, or choose Cancel to not add them.

Key-value tags can only be added one at a time before saving. To add more than one key-value tag, repeat the previous steps.

For more information on key-only and key-value tags, see Tags in Amazon Lightsail. 

1.8 — Click Create instance. 

Your instance will become available after a few minutes. 

Step 2: Get the default application password for your Magento website

Now that you created your Magento instance, complete the following steps to get the default application password for your Magento website. 

2.1 — On the Instance management page, under the Connect tab, choose Connect using SSH. It will take a moment for your instance to become available. 

2.2 — After you're connected, enter the following command to get the default application password. 

You should see a response similar to the following screenshot, which contains the default application password. Store this password in a safe place. You will use it in the next section of this tutorial to sign in to the administration dashboard of your Magento website.

cat $HOME/bitnami_application_password

Step 3: Attach a static IP address to your Magento instance

The public IP address assigned to your instance when you first create it will change every time you stop and start your instance. You should create and attach a static IP address to your instance to ensure its public IP address doesn't change. Later, when you use a registered domain name, such as example.com, with your instance, you don’t have to update your domain’s DNS records every time you stop and start your instance.

3.1 — On the instance management page, under the  Networking  tab, choose  Create a static IP or Attach static IP (if you previously created a static IP that you can attach to your instance), then follow the instructions on the page.

For more information, see Create a static IP and attach it to an instance in Amazon Lightsail.

3.2 —  After the new static IP address is attached to your instance, you must complete the following steps to make the Magento software aware of the new static IP address.

Make a note of the static IP address of your instance. It's listed in the header section of your instance management page.

3.3 — On the Instance management page, under the Connect tab, choose Connect using SSH.

3.4 —  After you're connected, enter the following command. Be sure to replace <StaticIP>  with the new static IP address of your instance.

The second code block is an example. 

After you entered the command you should see a response similar to the following screenshot. The Magento software should now be aware of the new static IP address. 

Note: Magento does not currently support IPv6 addresses. You can enable IPv6 for the instance, but the Magento software will not respond to requests over the IPv6 network.

sudo /opt/bitnami/configure_app_domain --domain <StaticIP>
sudo /opt/bitnami/configure_app_domain --domain 203.0.113.0

Step 4: Sign in to the administration dashboard of your Magento website

Complete the following step to access your Magento website and sign in to its administration dashboard. To sign in, you will use the default user name (user) and the default application password that you got earlier in this guide

4.1 — In the Lightsail console, make note of the public or static IP address that is listed in the header area of the instance management page.

4.2 —  Browse to the following address to access the sign in page for the administration dashboard of your Magento website. Be sure to replace <InstanceIpAddress> with the public or static IP address of your instance.

The second code block is an example. 

http://<InstanceIpAddress>/admin
http://203.0.113.0/admin

4.3 — Enter the default user name (user), the default application password you got earlier in this guide, and choose Log in.

The Magento administration dashboard appears, as shown in the second screenshot. 

To change the default user name or password that you use to sign in to the administration dashboard of your Magento website, choose System in the navigation pane, and then choose All Users. For more information, see Adding users in the Magento documentation.

Step 5: Route traffic for your registered domain name to your Magento website

To route traffic for your registered domain name, such as example.com, to your Magento website, you add a record to the domain name system (DNS) of your domain. DNS records are typically managed and hosted at the registrar where you registered your domain. However, we recommend that you transfer management of your domain's DNS records to Lightsail so that you can administer it using the Lightsail console.

5.1 — On the Lightsail console home page, under the  Networking  tab, choose  Create DNS zone, then follow the instructions on the page.

For more information, see Creating a DNS zone to manage your domain’s DNS records in Amazon Lightsail.

5.2 — After your domain name is routing traffic to your instance, you must complete the following steps to make the Magento software aware of the domain name.

On the Instance management page, under the Connect tab, choose Connect using SSH.

5.3 — After you're connected, enter the following command. Be sure to replace <DomainName> with the domain name that is routing traffic to your instance.

You should see a response similar to the following screenshot. The Magento software should now be aware of the domain name.

sudo /opt/bitnami/configure_app_domain --domain <DomainName>
sudo /opt/bitnami/configure_app_domain --domain www.example.com

Step 6: Configure HTTPS for your Magento website

Complete the following steps to configure HTTPS on your Magento website. These steps show you how to use the Bitnami HTTPS configuration tool (bncert), which is a command line tool for requesting SSL/TLS certificates, setting up redirections (e.g. HTTP to HTTPS), and renewing certificates.

Important: The bncert tool will issue certificates only for domains that are currently routing traffic to the public IP address of your Magento instance. Before starting with these steps, make sure that you add DNS records to the DNS of all domains that you want to use with your Magento website.

6.1 — On the instance management page, under the Connect tab, choose Connect using SSH.

6.2 — After you're connected, enter the following command to start the bncert-tool.

You should see a response similar to the following screenshot. Note: The bncert tool does not support the configuration of redirections for Magento instances. You will not be able to configure non-www to www redirect (or vice-versa), and HTTP to HTTPS redirect using the bncert tool, but we will show you how to configure that through the Magento administration dashboard later in these steps.

sudo /opt/bitnami/bncert-tool

6.3 — Enter your primary domain name and alternate domain names separated by a space as shown in the following screenshot.

6.4 — The changes that are going to be made are listed. Type Y and press Enter to confirm and continue.

6.5 — Enter your email address to associate with your Let's Encrypt certificate and press Enter.

6.6 —  Review the Let's Encrypt Subscriber Agreement. Type Y and press Enter to accept the agreement and continue.

The actions are performed to enable HTTPS on your instance, including requesting the certificate and configuring the redirections you specified. This is shown in the second screenshot. 

Lastly, your certificate is successfully issued and validated, and the redirections are successfully configured on your instance if you see a message similar to the following example. The bncert tool will perform an automatic renewal of your certificate every 80 days before it expires. Continue to the next set of steps to finish enabling HTTPs on your Magento website.

6.7 — Browse to the following address to access the sign in page for the administration dashboard of your Magento website. Be sure to replace <DomainName> with the registered domain name that is routing traffic to your instance.

http://<DomainName>/admin
http://www.example.com/admin

6.8 — Enter the default user name (user), the default application password you got earlier in this guide, and choose Log in. 

The Magento administration dashboard appears as shown in the second screenshot. 

6.9 — Choose Stores in the navigation pane, and then choose Configuration. 

6.10 — Choose Web, and then expand the Base URLs node. 

 

6.11 — In the Base URL text box, enter the full URL of your website, for example: https://www.example.com/.

6.12 — Expand the Base URLs (Secure) node.

 

6.13 — In the Secure Base URL text box, enter the full URL of your website, for example https://www.example.com/.

6.14 — Choose Yes for the Use Secure URLs on Storefront, Use Secure URLs in Admin, and Upgrade Insecure Requests options.

6.15 —Choose Save Config at the top of the page.

HTTPS is now configured for your Magento website. When customers browse to the HTTP version (e.g., http://www.example.com) of your Magento website, they will be automatically redirected to the HTTPS version (e.g., https://www.example.com). For more information about configuring HTTPS in the administration dashboard of your Magento website, see Store URLs in the Magento User Guide.

Congratulations

Congratulations. You have successfully setup a Magento website with Amazon Lightsail.

Amazon Lightsail is a great choice to develop, build, and deploy a variety of applications like WordPress, websites, and blog platforms.

Was this tutorial helpful?

Read the documentation

Read the Bitnami documentation to learn how to perform administrative tasks on your Magento instance and website, such as install plugins and customize the theme. For more information, see Bitnami Magento Stack for AWS Cloud in the Bitnami documentation.

You should also read the Magento documentation to learn how to administer your Magento website. For more information, see the Magento 2.4 User Guide.

Take a snapshot

After you configure your Magento instance, create periodic snapshots of your instance to back it up.

Configure SMTP for email notifications

Configure the SMTP settings of your Magento website to enable email notifications for it. For more information, see Install the Magento Magepal SMTP extension in the Bitnami documentation.