Adding RStudio to an Amazon Lightsail Instance

Today I decided to try adding the RStudio Server to my Amazon Lightsail instance. There are three steps to this – downloading and installing the software, opening up port 8787, and adding a user with a password who can log in to the server.

To install the software, fire up a terminal connection to your instance from Amazon or with PuTTY. Next, go to the instance-setup-files directory our install script created. The command for that is cd /home/ec2-user/instance-setup-files. After that, enter the commands that will download and install the most recent version of the RStudio Server software, which you can get here, but make sure you click on the RedHat/CentOS tab on the page that link goes to. Run the two commands shown there (without the leading $), one at a time. That’s all it takes to install the software.

Next, on your Amazon Lightsail home screen, click on the three vertical dots on the instance you’ve added RStudio to, and select Manage from the menu that pops up. On the page that appears, click the Networking tab. In the Firewall section, click on + Add Another and in the spaces provided enter Custom for the application, TCP for the protocol, and 8787 for the Port range.

To run RStudio, you add :8787 to the end of your server’s IP number or URL. You can do that now and the RStudio login screen should appear.

But to login, you need to create a user with a password. Back in your terminal, enter these commnds, replacing USERNAME with the name you want to use:

sudo useradd USERNAME
sudo passwd USERNAME

After you enter the second command you will be prompted to enter the password twice. (The password is not printed on your screen; in other words, your terminal will appear to have crashed! Ignore that and just enter the password followed by Return.)

Now you should be able to log into RStudio Server with the username and password you’ve just set up.

At the very end of this Brief Guide on Running RStudio Server on Amazon Web Services, there are tips on how to upload and download files to your server using RStudio. The rest of the post is about Amazon EC2 instances rather than Lightsail instances. If you’re using Amazon but not Lightsail, that post is probably a better resource for you than this one.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.