Tech
Infected

Linux, OpenSource, Programming And Hacks

Sep 30, 2016

Run Python SimpleHttpServer on Amazon AWS EC2

Sep 30, 2016

With Python's SimpleHTTPServer you can quickly setup a webserver without any hassle. In order to use it, you don't need to install or configure anything.. you just need to have python installed on your server.

Step 1: Open up your AWS console and in your instance security group make the Inbound & Outbound settings like shown in the sceenshots below



Step 2: Login into your remote server via ssh

example:
aman@vostro:~$ ssh -i yourkeyfile.pem ubuntu@your-server-ip



Step 3: After you got logged in, Create a Html page named index.html which will be displayed.
ubuntu@ip-132-55-51-221:~$ nano index.html

press Ctrl+o, enter then Ctrl+x to save and exit nano after you have written your html code.
example:
<html>
<html>
<head>
</head>
<body>
<h1>Hello, TechInfected!</h1>
</body>
</html>

Step 4: Finally, Run the server to display that html page.
ubuntu@ip-132-55-51-221:~$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

Open up your browser and enter your public ip with the port on which the server is running.


Note: By default files are served on port 8000,  you can change it to any other like shown below
ubuntu@ip-132-55-51-221:~$ python -m SimpleHTTPServer 9000
Serving HTTP on 0.0.0.0 port 9000 ...





No comments:

Post a Comment