If you missed our last article make sure to check it out here to read about getting up and running with Magento 2 and Amazon Lightsail.
Connecting to the Instance
In part one we discussed why you might choose Lightsail and some of the roadblocks you may experience while getting up and running. Since that time there have been some improvements. In particular, one-click connecting to an instance without the need for a Java applet to connect to the command line console is a big step forward.
Once connected you can do any command line actions without needing to mess with access keys or booting up a terminal. Finding the default user password for your Magento 2 instance on Lightsail was difficult before but now you can just review the boot log:
> sudo cat /var/log/boot.log | grep “application password”
The boot log contains the key for the default user password to log into the Magento 2 admin. The default admin lives at yourdomain.com/admin and the default username is “user”. With that covered we can log into the Magento admin and install sample data.
Magento Connect Keys
Once logged in reset the username, email and password for the default administrator. You can do this by visiting the top-right “user” context menu:
When your password is reset it’ll issue a warning that Magento 2 can’t send emails. We’ll skip this step for now and cover setting up Amazon SES in part 3.
To check for upgrades to your Magento 2 you’ll need to set up your secure keys to associate your new Magento 2 installation with your Magento.com account. To do this you’ll need to log in to your user account at Magento.com and from within your My Account panel select “Connect”. At this time, you may have to re-login to Connect. From here select “Secure Keys”:
If you do not do not currently have a secure key, you will need to create one. Copy the public and private keys to somewhere safe like 1Password or Lastpass.
From here we need to navigate to your new Lightsail Magento 2 backend. On the left-hand menu you will find an icon for the “System” tab. Click on “Web Setup Wizard”:
We will begin by upgrading our new Lightsail Magento 2.1.2 instance to 2.1.3. To do this we click on “System Upgrade”. It will ask us to input our secure public and private keys. We should then see a prompt to upgrade to 2.1.3:
When you select “Next” Magento 2 will do a readiness check. Part of this is ensuring there is enough free system memory (RAM) to complete an upgrade. The minimum required is 768MB of RAM. If you’re planning on running your Lightsail VPS at the $5/month 512MB option, this is where you may need to reboot a snapshot to a larger instance. Bear in mind that the larger the amount of RAM you have available generally the faster it will be to upgrade.
Even if you have enough system RAM it may not all be available to PHP even with the default Bitnami settings. So we’ll edit them to take advantage of a slightly larger capacity machine:
> vim /opt/bitnami/apps/magento/conf/php-fpm/php-settings.conf
I have a 4GB VPS started so I reset my INI file to take advantage of 3072MB of RAM (~3GB). No need to restart Apache or PHP-FPM to let this change take effect.
This value overrides the values set elsewhere like in the user.ini file, the php.ini and htaccess files. After you update this value you will need to restart PHP-FPM, Apache, and Varnish:
> sudo /opt/bitnami/ctlscript.sh restart php-fpm
> sudo /opt/bitnami/ctlscript.sh restart apache
> sudo /opt/bitnami/ctlscript.sh restart varnish
Upgrading to 2.1.3
Next we’ll begin our upgrade. Click on “Next” from the previous step. You should see the Readiness Check complete:
After selecting “Next” you will be presented with a number of options for performing a backup of your existing site. This includes code, media, and database. This can take some time to complete if this isn’t a brand new Lightsail site. If it is a brand new site this should take less than a minute. Click “Next” to proceed.
Finally, we click “Upgrade” to begin the upgrade process. The process can take upwards of 15 minutes to complete. During this time the store is in maintenance mode and will display your system default 503 error.
On our test boxes we ran into some permissions and application errors after our upgrade. These were solved by using the following:
> sudo /opt/bitnami/apps/magento/bnconfig –regenerateKeys 1
This rekicks the configuration keys for the bitnami instance and fixes permissions issues in var/generation folder.
The system is now upgraded to the most recent version!
Installing Sample Data
After you complete the upgrade the installation of sample data follows a different process than before. Unfortunately, at this time you can’t install sample data from the admin UI. This is likely due to the fact that sample data is fundamentally something that a developer would want to install. To install sample data, use the console to log in to the box and navigate to the Magento 2 htdoc root:
> php -f bin/magento sampledata:deploy
> php -f bin/magento setup:upgrade
These two steps are fairly lengthy and could run for 5-10 minutes. After the upgrade step you’ll be required to recompile the DI:
> php -f bin/magento setup:di:compile
After DI compilation is complete we again we have issues with the daemon group being lost on file permissions after running an upgrade so we will need to reissue the bnconfig command again:
> sudo /opt/bitnami/apps/magento/bnconfig –regenerateKeys 1
Refresh the homepage and you should see the new sampledata home page installed.
A default Magento 2 installation on Lightsail is a fast way to get up and running. However, managing a store is not a fully UI-capable affair, requiring you to delve into the shell to issue commands from time to time. Part of this is due to the setup of the Bitnami environment and some of it is due to some of the issues with how Magento 2 handles upgrade components.
Because of the ease and speed of setup it is still a very valuable way to get a Magento 2 site up and running fast. Hopefully Lightsail gets up to date with the newest 2.1.3 soon and the upgrade step will no longer be required. Until then it is still a great way for any merchant to quickly pilot Magento 2.
Written by: Phillip Jackson, Ecommerce Evangelist – 4 minute read