Connect to the server and install Nginx
We are now working on the remote Linux computer in AWS, not on your laptop. Commands typed in the SSH session run on EC2.
Step 5 — Connect using SSH
On macOS or Linux, open Terminal. On Windows, use OpenSSH in PowerShell or Windows Terminal (or use the approved browser-based EC2 Instance Connect method if supported by your workshop).
• Replace YOUR_PUBLIC_IP with the actual public IPv4 address displayed in your EC2 instance details.
• Ensure the key path matches where your .pem file was saved (e.g. ~/Downloads/aws-class-key.pem).
• The default SSH username for the Amazon Linux 2023 AMI is ec2-user.
• chmod 400 sets the required read-only permissions on macOS and Linux. Windows PowerShell handles key ACL permissions through file properties.
If your connection times out or rejects your key, verify each item below before asking a mentor:
- 1. Check that the file path to
aws-class-key.pemis exact and accessible. - 2. Confirm the key pair matches the one selected during instance launch.
- 3. Verify the security group inbound rule permits port 22 from your current IP address.
- 4. Confirm the instance state is Running and status checks report 2/2 passed.
- 5. Verify you copied the Public IPv4 address, not the Private IPv4 address.
- 6. Confirm the username is
ec2-user.
Step 6 — Install Git and Nginx on EC2
Now that you are connected to the Amazon Linux terminal, install the package dependencies and activate the Nginx web server daemon:
- •
sudo dnf update -y: Updates available installed packages according to Amazon Linux 2023 repositories. - •
sudo dnf install -y git nginx: Installs Git (for cloning the starter code) and Nginx (the web server daemon). - •
sudo systemctl enable --now nginx: Configures Nginx to start automatically at system boot and launches it immediately. - •
sudo systemctl is-active nginx: Verifies whether the service is running. The expected terminal output is active.
Note: These commands are specifically tailored for Amazon Linux 2023 using the dnf package manager. Do not substitute Ubuntu's apt commands.
Test Nginx Locally on EC2
Before copying your website files, check that Nginx responds to HTTP requests on the EC2 instance itself:
This request tests Nginx from inside the server. A successful response includes an HTTP status header such as HTTP/1.1 200 OK.
A successful local curl test proves the Nginx daemon is running, but does not prove public internet reachability. Public browser access will be verified in Step 8.
Capture the connected Amazon Linux terminal and a terminal showing the Nginx service as active together with the local HTTP test. Never include passwords, private keys, authentication tokens, or other secrets.
curl -I http://localhost) returns an HTTP 200 OK header.