An open API service indexing awesome lists of open source software.

https://github.com/amarjotsinghh/apache-setup-on-ec2

A bash script that sets up an Apache web server on an EC2 instance and ensures that Apache will start automatically on reboot.
https://github.com/amarjotsinghh/apache-setup-on-ec2

apache ec2 shell-script

Last synced: 4 months ago
JSON representation

A bash script that sets up an Apache web server on an EC2 instance and ensures that Apache will start automatically on reboot.

Awesome Lists containing this project

README

          

```md
# Apache Web Server Setup on EC2

This guide provides a step-by-step process to set up an Apache web server on an EC2 instance using a bash script. The script ensures Apache will start automatically on reboot and configures the firewall to allow HTTP (port 80) and HTTPS (port 443) traffic.

## Steps to Use

### 1. Create the Bash Script on Your EC2 Instance

First, connect to your EC2 instance and create the script file by running the following command:

```bash
nano automation.sh
```

Then, copy and paste the following script into the `automation.sh` file:

```bash
#!/bin/bash
# Update the package list
sudo apt update -y

# Install Apache
sudo apt install apache2 -y

# Enable Apache to start on boot
sudo systemctl enable apache2

# Start Apache
sudo systemctl start apache2

# Allow HTTP and HTTPS traffic through the firewall
sudo ufw allow 'Apache Full'
```

Save the file by pressing `Ctrl + X`, then `Y`, and hit `Enter` to confirm.

### 2. Make the Script Executable

Run the following command to make the script executable:

```bash
chmod +x automation.sh
```

### 3. Run the Script

Now, run the script using the command:

```bash
./automation.sh
```

This script will:
- Update the package list.
- Install the Apache web server.
- Set Apache to start automatically on reboot.
- Start the Apache service.
- Configure the firewall to allow HTTP (port 80) and HTTPS (port 443) traffic.

### 4. Verify Apache Installation

Once the script is complete, you can verify the installation by visiting your EC2 instance's public IP address in a web browser. You should see the Apache default page.

You can also check the status of Apache by running:

```bash
sudo systemctl status apache2
```

This confirms that Apache is installed and running.

## License

This project is licensed under the MIT License - see the LICENSE file for details.
```

This `README.md` provides a clear and structured set of instructions for using the bash script to set up Apache on an EC2 instance.