First of all the Framework which I used is the flask, so first thing check your model whether it is running or not in your local environment.
Run anaconda prompt and go on the appropriate path of your model and type
Then the output must look like this
Now after verifying on a local machine its time to go on an AWS management console.
- Open EC2.
- Then Click on Running Instances.
- Then Launch Instance.
- Then Search Ubuntu Because it is free so you can use that for your personal projects. but In companies, they use premium server so that so many things are pre-installed they will not do it manually but we have to do it manually.
Then it might look like this
- Choose a t2-micro version of Ubuntu server for the free tier.
- Then click on review and launch.
- Again click on launch. Then a pop-up will show up like this.
- Create a new key pair and give it a name and download that keypair and put inside your project folder.
That ''' .pem ''' extension file will help us to interact with the server which is running on EC2 instance.
- Now click on Launch Instance.
Putty - A ssh client to interact with the server.
Putty gen - For converting that ''' .pem ''' file into private key.
WinSCP - For sending your all-important files to the server.
- Load yours.pem file.
- Generate your private key. (Convert .pem to .ppk file)
- And save that on your project folder.
- Go to EC2.
- Open Running Instances.
- Right-click on Instance which we are working and click on connect.
- And Copy that.
- Paste your Hostname in hostname column.
- Click on Advanced.
- Now click on Authentication and browse your private key (.ppk) file.
- Now click on log-in and press yes on the pop-up.
- Now drag your appropriate files from your local machine to Ubuntu server.
- Paste your Hostname.
- Now click on ssh expand it and click on Auth.
- Now browse the private key and save the session.
- Now click on open.
- Now type Ubuntu in login as.
- Now you are in the ubuntu server panel.
Here now you have to update and install pip and appropriate libraries respectively to run your project.
run this command as you enter inside your server terminal.
sudo apt-get update && sudo apt-get install python3-pip
Now this command will manage your all issues regarding '''pip3 installer'''
Make sure in your
app.py or model.py
your host and port must be as is this.
host='0.0.0.0' and port=8080
pip install -r requirements.txt
As your installation of the libraries completed.
Python3 app.py or model.py
- Go to search bar.
- Now paste your HostName followed by port 8080.
Now enjoy, Your model is successfully deployed on EC2 Instance.
nohup Python3 app.py or model.py &
Thank you so much for reading and visiting this.