How to Install Jenkins on CentOS and Configure It to Run on Port 8090
Jenkins is an open-source automation server that helps automate parts of software development, including building, testing, and deploying. This guide walks you through installing Jenkins on CentOS and configuring it to run on port 8090.
Step 1: Install Required Dependencies
First, ensure your system is up-to-date and install the necessary dependencies.
1sudo yum update -y
2sudo yum install epel-release -y
3sudo yum install fontconfig java-17-openjdk -y
- EPEL Repository: Provides additional packages not included in standard CentOS repositories.
- Java 17: Jenkins requires Java to run; OpenJDK 17 is recommended.
Step 2: Add the Jenkins Repository
Download and add the Jenkins repository to your system.
1sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo --no-check-certificate
2sudo rpm --import http://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
- The Jenkins repository contains the latest stable versions of Jenkins.
- The GPG key ensures the integrity of the repository.
Step 3: Install Jenkins
Install Jenkins using the YUM package manager.
1sudo yum install jenkins -y
Step 4: Configure Jenkins to Run on Port 8090
By default, Jenkins runs on port 8080. To change it to port 8090, edit the Jenkins service file.
-
Open the service file in a text editor:
1sudo vi /lib/systemd/system/jenkins.service
-
Locate the
Environment="JENKINS_PORT="
line and update it as follows:1Environment="JENKINS_PORT=8090"
-
Save and exit the file.
-
Reload the systemd daemon to apply changes:
1sudo systemctl daemon-reload
Step 5: Start Jenkins
Start the Jenkins service:
1sudo systemctl start jenkins
Enable Jenkins to start at boot:
1sudo systemctl enable jenkins
Step 6: Verify Jenkins Installation
-
Check the status of the Jenkins service:
1sudo systemctl status jenkins
-
Open a browser and navigate to:
1http://<your-server-ip>:8090
-
Retrieve the initial admin password:
1sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy and paste the password into the setup wizard.
Step 7: Configure Firewall
If you have a firewall enabled, allow traffic on port 8090:
1sudo firewall-cmd --add-port=8090/tcp --permanent
2sudo firewall-cmd --reload
Step 8: Complete Jenkins Setup
-
Follow the on-screen instructions in the browser to:
- Install suggested plugins.
- Create an admin user.
- Configure Jenkins according to your needs.
-
Jenkins is now ready to use!
Maintenance Tips
-
Keep Jenkins Updated: Regularly update Jenkins to ensure security and access to new features.
1sudo yum update jenkins -y
-
Monitor Logs: If you encounter issues, check Jenkins logs:
1sudo cat /var/log/jenkins/jenkins.log
Conclusion
By following these steps, you’ve successfully installed Jenkins on CentOS and configured it to run on port 8090. Jenkins is now ready to help automate your development and deployment workflows. For further customization, explore the vast library of Jenkins plugins to enhance its functionality.