0% found this document useful (0 votes)
13 views

Create EC2 Instance Containing Jupyter Server

Uploaded by

nitesh.9kr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Create EC2 Instance Containing Jupyter Server

Uploaded by

nitesh.9kr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Install Jupyter Notebook on an EC2 Instance

In this tutorial you will create an EC2 instance with Jupyter notebook server from Ubuntu AMI.

1. Login to the AWS console. Go to EC2 and create an EC2 instance using
Ubuntu server 20.04 AMI.

a. Type EC2 in the search bar of AWS console. Click on EC2 in the search results. This will
open the EC2 console.

b. On the EC2 dashboard page, click on Launch Instance button.

c. On the Step1: Choose an Amazon Machine Image (AMI) page scroll down and select
Ubuntu Server 20.04 LTS.

d. On the next page keep default t2.micro instance type. Click Next: Configure instance
details.

e. Now click Launch and Review button. Then Click Launch.

f. Select the existing Key pair.

g. Once the EC2 instance is created, use Putty to connect to this EC2 Instance.

2. Install Jupyter Server.

a. Once you login to the EC2 instance, enter following command first in the putty console..
sudo apt update -y

b. Once the above command completes then issue the following command.
sudo apt upgrade -y

c. Now install python pip and the python dev package using following command.
sudo apt install python3-pip python3-dev -y

d. Now first upgrade the pip package.


sudo -H pip3 install --upgrade pip

e. Now install virtual environment package


sudo -H pip3 install virtualenv

f. Create a directory where you will create the python virtual environment.
mkdir projects

cd Projects

g. Create virtual environment inside this directory.


virtualenv projects_env

This will create a directory inside projects directory by the name specified. (E.g. here the
directory projects_env is created). This directory contains the python and its required
libraries.
h. Activate the virtual environment by giving following command.
source projects_env/bin/activate

i. Now install jupyter server.


pip install jupyter

j. To test if the jupyter server is installed correctly and it is working properly issue the
following command.
jupyter notebook

if you get the output as follows then it means the jupter server is installed properly.

Now stop this jupyter server by pressing Ctrl+C buttons. Type y to shutdown the server.
Close the Putty connection to the EC2 server.

3. Use tunnel option in Putty to access the Jupyter notebook on local computer
port.

a. Open Putty. In the hostname field type public IPv4 address or Public IPv4 DNS name of
the EC2 instance.
b. Expand SSH section. In Auth field select the .ppk key to access the above EC2 instance.

c. Now in the SSH section, click Tunnels option.

In the Source field type a port number greater than 5000 (this is just to avoid conflicts with
other services. It is not a rule. You can type any port number above 1024). This is the port
that Putty will open on your local laptop and will make the Jupyter notebook available.

In the Destination field type localhost:8888. This the URL on which the Jupyter server runs.
The port 8888 is the port used by the Jupyter server on the EC2 instance.

Now click Add button. The configuration will look as shown below.

Click Open to connect to your EC2 instance.


d. Once Putty connects to the EC2 instance, issue following commands to start jupyter
server.

cd projects
source projects_env/bin/activate
jupyter notebook

This will start the jupyter server on the EC2 instance.

e. Now open a new tab in the local browser. In the tab type http://localhost:8000 . The
jupyter notebook web page will be displayed.

To login copy the number displayed in front of token= in the Putty screen. Paste in the
Password or Token field in the browser. Click Login.

Following page will be displayed if you login successfully.

f. Close this window. Press Ctrl+C in the Putty terminal to stop jupyter server. Close the
Putty connection.
Clean Up

Make sure you delete all the resources created for this practical.

1. Go to Instances. Select your instance . Select Instance State and Click Terminate.

You might also like