Hosting a Portfolio website on AWS | Amazon Web Service | Step by Step Guide | Mini-Project for Beginners
Tags: devops, aws, cloud, opensource
Published: 2023-10-21 17:05:50

## 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
```

**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
```

**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
```
- After installation, start the Apache server:
```
$ sudo systemctl start apache2
```

**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
```
**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
```
- 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>
```
Step-7: Enable the virtual host and restart Apache:
```
$ sudo a2ensite public-ip.conf
$ sudo systemctl restart apache2
```

**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](https://www.linkedin.com/in/shamim-ansari7/) | [Twitter](https://twitter.com/shamim_faizi786) for more such contents