sudo apt update && sudo apt install nginx. On AlmaLinux or Rocky Linux, run sudo dnf install nginx and then sudo systemctl enable --now nginx. Allow ports 80 and 443 in your firewall, then open http://203.0.113.10 (your server’s IP) in a browser. You see the Nginx welcome page when it works.
Before you start
- Connect to your server with SSH. See connect with SSH.
- Use a user with
sudorights. If you are logged in asroot, leave outsudo. - Only one program can listen on port 80. If Apache is already installed, stop it first or use a different port.
How to install Nginx
- Ubuntu / Debian
- AlmaLinux / Rocky
1
Update the package list
2
Install Nginx
3
Check the service
active (running). Press q to exit.How to open ports 80 and 443 in the firewall
- Ubuntu / Debian (ufw)
- AlmaLinux / Rocky (firewalld)
sudo ufw allow 'Nginx Full', which opens both ports. See set up ufw.Where are the Nginx files?
To host your own domain, create a server block (Nginx’s name for a site config). See set up server blocks.
How to check it worked
Test the configuration:HTTP/1.1 200 OK and a Server: nginx header. Finally, open http://203.0.113.10 (replace with your server IP) in your browser.
How to start, stop and reload Nginx
sudo nginx -t before a reload. If the test fails, Nginx keeps running with the old config, and the error message names the file and line to fix.
Frequently asked questions
Why can’t I see the Nginx page from my browser?
Check three things: the service isactive (running), your firewall allows port 80, and you used the right IP. curl -I http://127.0.0.1 on the server tells you whether Nginx itself works. See website not loading.
Nginx fails to start with “Address already in use”. What now?
Another program, usually Apache, already uses port 80. Find it withsudo ss -tlnp | grep ':80', then stop it (sudo systemctl stop apache2 or httpd) or change one of them to a different port.
Should I use Nginx or Apache?
Both are fine for most sites. Nginx is a common choice as a reverse proxy in front of Node.js or Python apps. Apache supports.htaccess files, which some PHP apps expect. See install Apache.
How do I add HTTPS?
Point your domain at the server, then run Certbot. See free SSL with Certbot.Related guides
VPS and dedicated server guides
Every server guide in one place.
Nginx server blocks
Host one or more domains.
Install a LEMP stack
Nginx, MariaDB and PHP together.
Free SSL with Certbot
Add HTTPS to your site.
Point a domain to your server
Set the DNS A record.
Nginx reverse proxy
Put Nginx in front of an app.
Checked against the official Ubuntu Server documentation and Red Hat Enterprise Linux 9 Nginx guide on 4 November 2026; install and configuration test commands tested on Ubuntu 24.04 LTS (Nginx 1.24.0). Commands can differ on other distributions or releases.
Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026