• Home
  • Server Management
  • Home
  • Server Management
home/Knowledge Base/Nginx/NGINX Installation Guide

NGINX Installation Guide

26 views 0 February 29, 2024 admin

NGINX stands out as a premier choice for developers seeking a high-performance, open-source web server solution. Celebrated for its efficiency, minimal resource usage, and ease of configuration, NGINX ensures your web applications and sites run smoothly. It’s the go-to server software for a variety of web serving needs, from simple sites to complex applications.

This guide offers a detailed walkthrough for installing NGINX on two widely-used Linux distributions: Ubuntu and CentOS. Tailored for both new and experienced developers, we aim to simplify the process of setting up NGINX on your Linux system. From initial system updates to configuring the firewall and managing NGINX processes, we’ve got you covered.

Prerequisites

Before you begin, make sure you have:

  • A Linux system with root or sudo privileges.
  • An internet connection.
  • A basic grasp of command-line operations.

Step 1: System Update

Start by updating your system to ensure all existing packages are current. Open your terminal and execute the following:

  • For Debian-based systems (like Ubuntu):

sudo apt-get update

  • For RHEL-based systems (like CentOS):

sudo yum update

This command refreshes your package lists and prepares your system for new installations.

Step 2: Installing NGINX

Next, install NGINX by running the appropriate command for your distribution:

  • For Debian/Ubuntu:

sudo apt-get install nginx

  • For RHEL/CentOS:

sudo yum install nginx

Confirm the installation when prompted by typing ‘Y’ and pressing Enter.

Step 3: Confirming NGINX Installation

To verify the successful installation of NGINX, check its version with:

nginx -v

This command displays the current NGINX version installed on your system.

Step 4: NGINX Configuration

NGINX’s configuration files reside in /etc/nginx, with nginx.conf being the primary file. This file includes other configurations from the conf.d directory. Use a text editor to make changes:

sudo vi /etc/nginx/nginx.conf

Adjust the settings as needed and save your changes.

Step 5: Starting and Enabling NGINX

Enable and start the NGINX service so it initiates at boot:

sudo systemctl start nginx sudo systemctl enable nginx

Step 6: Firewall Configuration

Adjust your firewall settings to allow NGINX traffic:

  • For Ubuntu/Debian (using UFW):

sudo ufw allow 'Nginx HTTP' sudo ufw reload

  • For CentOS/RHEL (using firewalld):

sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --reload

Step 7: Testing Your Setup

Check your NGINX installation by navigating to your server’s IP in a web browser. A “Welcome to nginx!” page confirms everything is configured correctly.

Step 8: Managing the NGINX Process

Here are some basic commands to manage your NGINX service:

  • To halt NGINX:

sudo systemctl stop nginx

  • To initiate NGINX when stopped:

sudo systemctl start nginx

  • To restart NGINX:

sudo systemctl restart nginx

  • To reload NGINX without dropping connections:

sudo systemctl reload nginx

  • To prevent NGINX from starting on boot:

sudo systemctl disable nginx

  • To enable NGINX to start at boot again:

sudo systemctl enable nginx

Conclusion

You’ve successfully installed NGINX on your Linux system, setting a solid foundation for your web serving needs. While this guide covers installation and basic management, NGINX’s capabilities extend far beyond. It’s adaptable for a range of scenarios, from serving static content to acting as a reverse proxy. Dive into NGINX’s extensive configuration options to fully leverage its power.

Was this helpful?

Yes  No
Related Articles
  • Diagnosing and Fixing Nginx 502 Bad Gateway Errors
  • Resolving Nginx Permissions and File Access Issues
  • Debugging Nginx Rewrite Rules and Location Blocks
  • Troubleshooting Nginx SSL Certificate Issues
  • Securing Nginx: Hardening Your Web Server Against Common Vulnerabilities
  • Optimizing Nginx Performance for High-Traffic Websites

Didn't find your answer? Contact Us

Leave A Comment Cancel reply

Nginx
  • NGINX Installation Guide
  • Optimizing Nginx Performance for High-Traffic Websites
  • Securing Nginx: Hardening Your Web Server Against Common Vulnerabilities
  • Troubleshooting Nginx SSL Certificate Issues
  • Debugging Nginx Rewrite Rules and Location Blocks
  • Resolving Nginx Permissions and File Access Issues
  • Diagnosing and Fixing Nginx 502 Bad Gateway Errors
All Categories
  • Nginx
  • Linux
  • MySQL
  • Grafana
  • Kubernetes
  • Kafka

Optimizing Nginx Performance for High-Traffic Websites  

Manual
  • We we are
  • Contact us
  • Suppliers
Support
  • Live chat
  • Knowledge Base
  • Blog
Security
  • Report Copyright
  • Trademark
  • Security Issue
Manual Head Office
Phone : 765 987-7765
Toll free : 1 999 654-98729
Fax : 250 684-29865
Emergency Help Desk: 7pm-2pm

Center street, 18th floor, New York, NY 1007