Setting up a reliable and secure Linux server can seem daunting at first, but with the right guidance, it becomes a straightforward process. In this blog post, I’ll walk you through setting up a server with Java, Node.js, Jenkins, and Nginx while configuring basic security and automation tools. Let’s get started!
1. Update and Upgrade Your System
Before installing any software, ensure your server is up to date. Run the following commands to fetch and apply the latest updates:
- sudo apt update
- sudo apt upgrade -y
These commands ensure you’re working with the latest security patches and system improvements.
2. Install OpenJDK 17
Many applications, including Jenkins, rely on Java. Install OpenJDK 17, a widely used version of Java, with this command:
- sudo apt install openjdk-17-jdk -y
You can confirm the installation by checking the version:
- java -version
3. Set Up Node.js
Node.js is essential for running modern JavaScript applications. Use the official NodeSource setup script to install the latest long-term support (LTS) version:
- curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
- sudo apt install -y nodejs
To manage your Node.js processes effectively, install PM2, a popular process manager:
- sudo npm install pm2@latest -g
4. Install Git
Git is an indispensable tool for version control. Install it using:
- sudo apt install git -y
You can verify the installation with:
- git --version
5. Install Certbot for SSL Certificates
Securing your server with HTTPS is a must. Install Certbot and its Nginx plugin to handle SSL certificates:
- sudo apt install certbot python3-certbot-nginx -y
6. Set Up Jenkins
Jenkins is a powerful automation tool that streamlines software development tasks. Follow these steps to install it:
- Download the Jenkins `.deb` package:
- wget https://pkg.jenkins.io/debian-stable/binary/jenkins_2.452.2_all.deb
- Install the package:
- sudo dpkg -i jenkins_2.452.2_all.deb
- Fix any broken dependencies:
- sudo apt --fix-broken install -y
- Start and enable Jenkins:
- sudo systemctl start jenkins
- sudo systemctl enable jenkins
- Check Jenkins’s status to confirm it’s running:
- sudo systemctl status jenkins
To access Jenkins, open your browser and navigate to `http://<your-server-ip>:8080`. Retrieve the initial admin password with:
- sudo cat /var/lib/jenkins/secrets/initialAdminPassword
7. Configure Your Firewall
Ensure your server’s firewall is configured to allow essential ttraffic.
- Disable and re-enable the firewall to start fresh:
- sudo ufw disable
- sudo ufw enable
- Check the status of the firewall:
- sudo ufw status
- Allow Nginx traffic:
- sudo ufw allow 'Nginx HTTP'
- sudo ufw allow 'Nginx HTTPS'
- sudo ufw reload
8. Install Nginx
Nginx will serve as your web server and reverse proxy. Install it using:
- sudo apt install nginx -y
After installation, ensure Nginx is running:
- sudo systemctl status nginx
9. Check Your Network Tools
Install `net-tools` for handy network-related commands like `ifconfig`:
- sudo apt install net-tools -y
Final Thoughts
Congratulations😎! Your Linux server is now equipped with Java, Node.js, Jenkins, Nginx, Git, and Certbot. This setup ensures you’re ready to deploy web applications, automate tasks, and secure your server with HTTPS. Take a moment to explore the tools you’ve installed and customise them to fit your project needs.
If you run into any issues, don’t hesitate to reach out to the community, comment here, or consult the official documentation for each tool. Happy hosting! 🚀
0 Comments
If you have any doubts, Please let me know