DEV Community

Cover image for Hosting a Portfolio website on AWS | Amazon Web Service | Step by Step Guide | Mini-Project for Beginners
Shamim Ansari
Shamim Ansari

Posted on

Hosting a Portfolio website on AWS | Amazon Web Service | Step by Step Guide | Mini-Project for Beginners

Hosting a portfolio website on an AWS Ubuntu server is a great way to showcase your work. Here's a step-by-step guide on how to do it:

Step-1: Launch an AWS EC2 Instance:

  • Log in to your AWS Management Console.
  • Navigate to the EC2 dashboard.
  • Click on "Launch Instance" to create a new EC2 instance.
  • Choose an Amazon Machine Image (AMI) for Ubuntu Server.
  • Select an instance type and configure instance details.
  • Add storage as needed.
  • Configure security groups to allow incoming traffic on ports 80 (HTTP) and 443 (HTTPS).
  • Review and launch the instance.

Step-2: Connect to Your Ubuntu Server:

  • Once the instance is running, connect to it using SSH. You can use a terminal on your local machine with the following command (replace your-key.pem and your-instance-ip with your actual key file and instance IP):
$ ssh -i your-key.pem ubuntu@your-instance-ip
Enter fullscreen mode Exit fullscreen mode

Step-3: Update and Upgrade Your Server:

  • After connecting, run the following commands to update and upgrade your server:
$ sudo apt update
$ sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode

Step-4: Install a Web Server (Apache or Nginx):

  • You can choose between Apache and Nginx as your web server. Here's how to install Apache:
$ sudo apt install apache2
Enter fullscreen mode Exit fullscreen mode
  • After installation, start the Apache server:
$ sudo systemctl start apache2
Enter fullscreen mode Exit fullscreen mode

Step-5: Upload Your Website Files:

  • You can use SCP or SFTP to transfer your HTML, CSS, and JavaScript files to the server. Replace 'your-local-directory' with the path to your website files and 'your-remote-directory' with the path where you want to store them on the server:
$ scp -i your-key.pem -r your-local-directory ubuntu@your-instance-ip:your-remote-directory
Enter fullscreen mode Exit fullscreen mode

Step-6: Configure the Web Server:

  • Create a virtual host configuration file for your website (replace your-public-ip with your server IP):
$ sudo vi /etc/apache2/sites-available/public-ip.conf
Enter fullscreen mode Exit fullscreen mode
  • Add the following configuration (modify as needed):
<VirtualHost *:80>
    ServerAdmin webmaster@your-public-ip
    ServerName your-public-ip
    DocumentRoot /var/www/html/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Step-7: Enable the virtual host and restart Apache:

$ sudo a2ensite public-ip.conf
$ sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode

Step-8: Configure DNS (if using a domain):

  • If you're using a custom domain, configure your DNS settings to point to your server's IP address.

Step-9: Secure Your Website (Optional):

  • It's recommended to secure your website with HTTPS. You can use Let's Encrypt to obtain a free SSL certificate.

Step-10: Test Your Website:

  • Open a web browser and visit your domain or server IP to verify that your website is live.
  • Your portfolio website should now be hosted on your AWS Ubuntu server. You can further customize and optimize the server and website as needed.

Please do let me know if you face any error, I will be happy to help and troubleshoot your issue.

Follow me on Linkedin | Twitter for more such contents

Top comments (3)

Collapse
 
dani_el-dev profile image
Daniel Oyola

Nice article. I never thought setting up a website on AWS would be that easy. I assume this costs zero at the start and just a little afterwards but anyways, I'll try it and let you know.

Collapse
 
nicolasaws profile image
nicolas

gracias, sube mas contenido para principiantes de aws

Collapse
 
msfaizi profile image
Shamim Ansari

dont understand what did you say