Step-by-Step Guide to Install Jenkins on EC2
1. Launch an EC2 instance on AWS with Ubuntu 20.04+ (or the latest version).
2. Connect to your EC2 instance using SSH:
$ ssh -i /path/to/your-key.pem ubuntu@<your-ec2-public-ip>
3. Update the package list and install dependencies:
$ sudo apt update -y
$ sudo apt install openjdk-11-jdk -y
4. Verify Java installation:
$ java --version
(You should see OpenJDK version 11 or later)
5. Add the Jenkins repository key:
$ wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
6. Add the Jenkins repository to the package manager sources:
$ echo "deb http://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list
7. Update the package list again:
$ sudo apt update
8. Install Jenkins:
$ sudo apt install jenkins -y
9. Start Jenkins service:
$ sudo systemctl start jenkins
10. Enable Jenkins to start on boot:
$ sudo systemctl enable jenkins
11. Verify Jenkins status:
$ sudo systemctl status jenkins
(You should see Jenkins running)
12. Retrieve the Jenkins initial admin password:
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
13. Access Jenkins through your web browser at:
http://<your-ec2-public-ip>:8080
14. Paste the initial admin password to unlock Jenkins.
15. Install suggested plugins or manually select plugins.
16. Create an admin user and complete the Jenkins setup.
17. Jenkins is now ready to use!
Note: Make sure to configure security groups in AWS to allow HTTP traffic on port 8080.