Skip to main content

Command Palette

Search for a command to run...

CI/CD Using Jenkins, GitHub Webhooks, and Deployment on Nginx/Apache

Published
โ€ข2 min read
CI/CD Using Jenkins, GitHub Webhooks, and Deployment on Nginx/Apache
K

"Hello, I'm Kiran Pawar, a passionate Cloud and Devops Engineer with a strong background in cloud automation, configuration, and deployment. My journey in the world of technology has been a thrilling adventure, where I've had the privilege to work with cutting-edge tools and practices.

๐Ÿš€ As a DevOps Engineer:

I specialize in automating, configuring, and deploying instances in cloud environments and data centers. My expertise extends to DevOps, GitOps, CI/CD pipeline management, HashiCorp Terraform, and containerization. I'm proficient in AWS and Linux/Unix administration, ensuring robust infrastructure and application performance.

๐Ÿ”ง My Tech Stack:

Front-end skills: HTML, CSS, SCSS, Tailwind CSS, Bootstrap, React, Material-UI, JavaScript DevOps toolbox: GIT, OWASP,Nexus,Trivy, Github, Gitlab, Terraform, Ansible, Docker, Kubernetes, Helm, Jenkins, Prometheus, Grafana, Argo CD, AWS EKS.

๐ŸŒ My Cloud Expertise:

I have hands-on experience managing AWS services, including EC2, S3, EBS, VPC, ELB, RDS, IAM, Route53, and more.

๐Ÿ”’ Networking and Security:

My skills include managing networking concepts such as TCP/IP protocols, security policies, and subnet interfacing. I have a strong understanding of infrastructure and networking, covering topics like firewalls, IP addressing, DNS, and more.

๐Ÿ’ก What Sets Me Apart:

I bring a positive attitude, a strong work ethic, and a collaborative spirit to every project. I'm a self-starter, a fast learner, and an effective team player with strong interpersonal skills. In addition to my DevOps skills, I've developed shell scripts (Bash) for automating tasks and have proficiency in Python scripting. My ability to communicate and manage projects, along with a track record of resolving client issues, adds value to every team I work with. If you're looking for a DevOps engineer who is also well-versed in front-end technologies, feel free to connect with me. Let's explore new possibilities and create exceptional technical solutions together!"

Continuous Integration and Continuous Deployment (CI/CD) pipelines ensure automated code testing and deployment, enhancing the development process. This guide walks you through setting up a CI/CD pipeline using Jenkins, GitHub Webhooks, and deploying to an Nginx or Apache server.


Step 1: Create and Update an EC2 Server

  1. Launch an EC2 server from your AWS Management Console.

  2. Update the server packages by running the following commands:

sudo apt update -y

Step 2: Install Nginx

  1. Install the Nginx web server:
sudo apt install nginx -y
  1. Navigate to the Nginx HTML folder and replace the index.html file to display your webpage:
cd /var/www/html

Replace or add your index.html file here.


Step 3: Install Jenkins

Prerequisite: Install Java

Jenkins requires Java to run. Install it using:

sudo apt install jdk-17-jre -y

Install Jenkins

  1. Add the Jenkins key and repository:
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key

echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null
  1. Update the server and install Jenkins:
sudo apt-get update
sudo apt-get install jenkins -y

Step 4: Configure GitHub Webhooks

  1. Go to your GitHub repository settings.

  2. Under Webhooks, add a new webhook.

  3. Enter the Jenkins webhook URL:

http://<EC2-Public-IP>:8080/github-webhook/

Replace <EC2-Public-IP> with your EC2 server's public IP address. This ensures the Jenkins pipeline is triggered on every new commit.


Step 5: Create a Jenkins Freestyle Job

  1. Log in to Jenkins.

  2. Create a new Freestyle Project.

  3. Configure the Git repository URL for the project. For example:

https://github.com/imkiran13/Irrigation.git
  1. Enable the GitHub hook trigger option in Jenkins.

Step 6: Configure Deployment to Nginx

  1. Add a build step to copy project files to the Nginx HTML folder:
cp -r * /var/www/html/
  1. Run the pipeline. If you encounter a "Permission Denied" error, proceed to the next step.

Step 7: Resolve Permission Denied Error

  1. Grant the Jenkins user permission to access the Nginx folder:
sudo chown -R jenkins:jenkins /var/www/html/
  1. Rerun the pipeline.

Step 8: Verify the Deployment

  1. Open your browser.

  2. Enter your EC2 server's public IP address.

  3. Verify that your deployed webpage is displayed.


Conclusion

You have successfully set up a CI/CD pipeline using Jenkins and GitHub Webhooks, and deployed the application to an Nginx server. This process ensures seamless integration and automated deployment for your web applications.

Feel free to modify this pipeline to suit your project's specific requirements!

More from this blog

Kiran Pawar's Blog

122 posts