← Back to Projects

Part 3: Production Server

Deploying the completed website live on the internet using an AWS EC2 instance and securing it with Let's Encrypt.

Taking a local application and securely launching it onto the internet requires a cloud server. For this portfolio, an Amazon Web Services (AWS) EC2 environment was selected for its robust performance and scalability.

1. Acquiring a Domain and DNS

Before launching a cloud server, a custom web domain (e.g., sjdawson.com) needs to be registered. This acts as the human-readable address for the server.

Screenshot of domain registration or AWS Route 53 DNS dashboard.

Placeholder: Take a screenshot of the domain registration or DNS management page.

2. Launching the EC2 Instance

Navigate to the AWS Console, specifically the EC2 Dashboard, and launch a new instance running Amazon Linux 2023.

Screenshot of the EC2 Instance dashboard in AWS.

Placeholder: Take a screenshot of the AWS EC2 management console showing the running instances.

Once the EC2 instance is running, an Elastic IP Address must be assigned to it so its IP stays permanent. Finally, head back to your Domain DNS settings and create an A Record that points the domain directly to this Elastic IP address.

3. Installing the LAMP Stack on Amazon Linux

SSH into the EC2 server and run the foundational commands to establish the web server and database engines.

Core Installation

sudo dnf update -y
sudo dnf install -y httpd mariadb105-server php php-mysqlnd php-gd
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start mariadb
sudo systemctl enable mariadb

Database Secure Config

Initialize the MySQL secure script and grant your application a database user:

sudo mysql_secure_installation
sudo mysql -u root -p
CREATE DATABASE personal_portfolio;
CREATE USER 'portfolio_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON personal_portfolio.* TO 'portfolio_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Folder Ownership & Permissions

Assign Apache ownership so you can pull code directly into the web root.

sudo usermod -a -G apache ec2-user
sudo chown -R ec2-user:apache /var/www
sudo chmod 2775 /var/www

Ensure your photo uploads directory can accept incoming images from the Admin Panel.

mkdir -p /var/www/html/uploads
sudo chown apache:apache /var/www/html/uploads/
sudo chmod 755 /var/www/html/uploads/

4. Securing with Let's Encrypt (HTTPS)

Finally, secure your network traffic and generate an SSL Certificate by executing the Certbot script via python virtual environments.

sudo dnf install -y python3 augeas-libs
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
sudo /opt/certbot/bin/pip install certbot certbot-apache
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot
sudo certbot --apache