Arch Linux BasedManjaro

How To Install Nginx on Manjaro

Install Nginx on Manjaro

In this tutorial, we will show you how to install Nginx on Manjaro. Nginx is a high-performance, open-source web server known for its stability, scalability, and efficiency. It’s an excellent choice for serving web content, reverse proxying and load balancing. Nginx is also highly configurable, making it an ideal candidate for hosting multiple websites on a single server.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Nginx web server on a Manjaro Linux.


  • A server or desktop running one of the following operating systems: Manjaro, and other Arch-based distributions.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • You’ll need access to a terminal or command line interface. Manjaro Linux provides a terminal emulator, so you can open it from your desktop environment.
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Nginx.
  • To install software and configure system settings, you’ll need administrative privileges. You can use the ‘sudo‘ command to execute commands as a superuser.

Install Nginx on Manjaro

Step 1. Before installing Nginx, it’s essential to ensure that the package is available and up-to-date. Open your terminal and run the following command:

sudo pacman -Syu
sudo pacman -S base-devel

Step 2. Installing Nginx on Manjaro.

To install Nginx on your Manjaro system, use the ‘pacman’ package manager. Run the following command:

sudo pacman -S nginx

Once Nginx is installed, you can start the service and enable it to start automatically on system boot. Use the following commands:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 3. Basic Nginx Configuration

Nginx’s configuration files are located in /etc/nginx/. The primary configuration file is /etc/nginx/nginx.conf. It’s important to understand and edit this file as needed, but for now, let’s keep things simple.

sudo nano /etc/nginx/nginx.conf

Within this file, you can find various directives related to the server’s settings, such as worker processes and user privileges.

Once Nginx is running, open your web browser and enter your server’s IP address or domain name. You should see the default Nginx welcome page. Congratulations, you’ve successfully installed Nginx!

Step 4. Configuring Virtual Hosts.

Virtual hosts, also known as server blocks in the Nginx world, allow you to host multiple websites on a single server. This feature is invaluable if you plan to run more than one website or web application on your server.

Before we start configuring virtual hosts, let’s set up a directory structure to keep your websites organized. It’s a good practice to create a separate directory for each site. For instance, create directories like /var/www/site1 and /var/www/site2 for your different websites:

sudo mkdir -p /var/www/site1
sudo mkdir -p /var/www/site2

Let’s create a basic server block configuration for a sample website. We’ll assume you have a domain name, like, pointing to your server’s IP address. You can adjust the following configuration accordingly.

sudo nano /etc/nginx/sites-available/sample-site

Add the following content to the file, modifying it to match your domain:

server {
listen 80;

root /var/www/site1;
index index.html;

location / {
try_files $uri $uri/ =404;

Save the file and exit the text editor, then create a symbolic link in the sites-enabled directory. This tells Nginx to use this configuration:

sudo ln -s /etc/nginx/sites-available/sample-site /etc/nginx/sites-enabled/

Before you apply the changes, it’s a good practice to test the configuration for any syntax errors:

nginx -t

To apply the changes, reload Nginx:

sudo systemctl reload nginx

Now, if you visit your domain (e.g., in your browser, it should display the content from the /var/www/site1 directory.

Step 5. Setting Up a Firewall.

A firewall is an essential component for securing your Linux server. It acts as a barrier between your server and the outside world, controlling incoming and outgoing traffic. For this guide, we’ll use UFW (Uncomplicated Firewall) to manage your firewall settings on Manjaro Linux. To install UFW, you can use the following command:

sudo pacman -S ufw

Once UFW is installed, you can enable it and ensure it starts automatically at boot with the following commands:

sudo systemctl enable ufw

To allow traffic to your Nginx web server, you’ll need to configure UFW rules to permit incoming connections on the HTTP (port 80) and HTTPS (port 443) ports. Here’s how you can do it:

sudo ufw allow 'Nginx Full'

After configuring UFW rules, it’s essential to verify that your firewall is functioning correctly. Run the following command:

sudo ufw status

Step 6. Troubleshooting.

Common Issues and Solutions

  • Nginx Fails to Start: If Nginx fails to start, check the configuration for syntax errors using sudo nginx -t. Correct any errors found in the configuration files.
  • Firewall Blocks Legitimate Traffic: If UFW blocks legitimate traffic, review your UFW rules and ensure they allow the necessary ports and services.
  • SSL Issues: If you encounter SSL-related issues, ensure your SSL certificate files and configurations are correctly set up. Pay attention to file permissions and paths.

Useful Commands for Diagnosing Problems

To help diagnose issues with your Nginx server and firewall, consider using the following commands:

  • journalctl -xe: Displays system log messages, which can be helpful for identifying errors and issues.
  • ufw status verbose: Provides detailed information about UFW’s status, including active rules and application profiles.
  • sudo tail -f /var/log/nginx/error.log: Monitors Nginx’s error log in real-time, which can be useful for tracking errors as they occur.

Congratulations! You have successfully installed Nginx. Thanks for using this tutorial to install the latest version of the Nginx web server on the Manjaro system. For additional help or useful information, we recommend you check the official Nginx website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button