Installing and configuring the Nginx web server on a Virtual Private Server is one of the most fundamental skills in system administration, enabling you to host fast, reliable, and secure websites with ease. By deploying your own web server, you gain complete control over your hosting environment, server configurations, and performance optimization without the limitations of shared hosting.
Last updated: May 8, 2026
According to recent data from W3Techs, Nginx is the most popular web server in the world, powering over 34% of all active websites. Its lightweight, event-driven architecture makes it exceptionally efficient at handling high-concurrency workloads, serving static files at lightning speed, and functioning as a reverse proxy or load balancer. Whether you are launching a personal blog, a business homepage, or a complex API backend, Nginx is the industry-standard choice for modern web infrastructure.
In this beginner-friendly tutorial, we will walk you through the step-by-step process of installing Nginx on an Ubuntu-based server, configuring the system firewall, verifying the server status, hosting your first custom website, and securing it with a free SSL certificate from Let's Encrypt.
Prerequisites
Before starting this guide, make sure you have the following ready:
- A FlashRDP Linux VPS: We recommend our Bronze plan or higher, which includes full root access, unmetered bandwidth, and enterprise-grade NVMe SSD storage. View Linux VPS plans.
- Ubuntu 22.04 or 24.04 LTS: This guide is tailored for Ubuntu, though the principles apply to any Debian-based distribution.
- Root or Sudo Access: Full privileges are required to install packages and edit system configuration files.
- A Domain Name: A registered domain name pointed to your VPS's static IPv4 address via an A record (required for SSL configuration).
💡 Tip All FlashRDP unmanaged Linux VPS plans include full root access via SSH, unmetered 1 Gbps bandwidth, and a dedicated static IPv4 address. Plans start at just $11.99/month, and servers are provisioned automatically in under 3 minutes. Deploy a VPS instantly.
Step 1: Update the Package Index & Install Nginx
To ensure you install the latest security-patched version of Nginx, you must update your system's package index before downloading the web server package.
1.1 Update System Packages
Connect to your FlashRDP server via SSH and run the following command to retrieve the latest package metadata from the Ubuntu repositories:
1.2 Install the Nginx Package
Once the update is complete, install Nginx using the apt package manager:
After the installation finishes, Nginx will be installed on your VPS, and the web server service will automatically start in the background.
Step 2: Configure the UFW Firewall
Before you can access your web server from the outside world, you need to configure your system's firewall to permit traffic on standard web ports. On Ubuntu, this is managed via the Uncomplicated Firewall (UFW).
2.1 View Available Application Profiles
UFW maintains pre-configured profiles for common services, including Nginx. List these profiles to see what options are available:
You should see three Nginx-related profiles in the output:
- Nginx HTTP: Opens port 80 (normal, unencrypted traffic)
- Nginx HTTPS: Opens port 443 (secure, encrypted traffic)
- Nginx Full: Opens both port 80 and port 443
2.2 Allow Web Traffic
To ensure your server can handle both standard and secure traffic, allow the Nginx Full profile:
2.3 Verify Firewall Status
Check the status of UFW to confirm that Nginx Full is permitted:
If UFW is inactive on your server, you can enable it with sudo ufw enable, ensuring that your SSH connection port (port 22) is allowed first so you do not lock yourself out of the system.
Step 3: Verify Nginx Web Server Status
With the installation completed and the firewall configured, you should verify that the Nginx service is running correctly.
3.1 Check Systemd Service Status
Ubuntu uses systemd to manage background services. Check the status of the nginx service:
Look for the line that says Active: active (running) in the output. This confirms that Nginx is active and listening for incoming connections.
3.2 Access the Default Landing Page
To verify that the web server is reachable over the internet, open your web browser and navigate to your VPS's static IP address:
http://your_vps_ip_address
You should see the clean "Welcome to nginx!" default landing page, confirming that your web server is successfully installed, running, and accessible online.
Step 4: Host Your Custom Website (Server Blocks)
To host a custom domain name, it is best practice to configure an Nginx Server Block. Server blocks (similar to Apache Virtual Hosts) allow you to host multiple distinct websites on a single VPS, each with its own root directory, security settings, and configurations.
4.1 Create the Directory Structure
Create a custom directory for your website inside the /var/www/ directory. Replace example.com with your actual domain name throughout this step:
Assign ownership of the directory to the current system user so you can modify files easily without needing root privileges:
Ensure that permissions are set correctly so Nginx can read the files:
4.2 Create a Sample Landing Page
Create a simple index.html file using your preferred text editor (like nano):
Paste the following HTML content into the file, then save and close it (press Ctrl + O, Enter, and then Ctrl + X):
4.3 Configure the Server Block
Nginx server blocks are configured using configuration files stored in the /etc/nginx/sites-available/ directory. Create a new configuration file for your website:
Paste the following configuration into the file, making sure to replace example.com with your domain:
4.4 Enable the Server Block
To activate your new configuration, create a symbolic link from the file in sites-available to the sites-enabled directory, which Nginx reads upon startup:
To avoid a potential server name bucket size issue (common when adding multiple server blocks), edit the main Nginx configuration file:
Find the server_names_hash_bucket_size directive and uncomment it by removing the # symbol:
Save and exit the file.
4.5 Test & Restart Nginx
Always test your Nginx configuration files for syntax errors before restarting the service. Running Nginx with a broken configuration can take your existing sites offline.
If the output states that the syntax is OK and the test is successful, restart Nginx to apply the changes:
Open your browser and navigate to your domain name (http://example.com). You should see your custom HTML page active.
Step 5: Secure Your Site with a Free Let's Encrypt SSL
Hosting a website over unencrypted HTTP (port 80) exposes your users' data to interception and results in a "Not Secure" warning in modern web browsers. Securing your site with HTTPS is essential, and you can accomplish this for free using Let's Encrypt and the Certbot software client.
5.1 Install Certbot and the Nginx Plugin
Install Certbot along with its dedicated Nginx integration plugin:
5.2 Obtain the SSL Certificate
Run Certbot to request an SSL certificate. The Nginx plugin will automatically inspect your server blocks, verify domain ownership, acquire the SSL certificate, and edit your Nginx server block configuration to serve HTTPS traffic:
During the process, you will be prompted to:
- Enter your email address for renewal and security notifications.
- Agree to the Let's Encrypt terms of service.
- Choose whether to automatically redirect all HTTP traffic to HTTPS (highly recommended). Select option 2 (Redirect) when prompted.
5.3 Test Automated SSL Renewal
Let's Encrypt SSL certificates are valid for 90 days. Certbot automatically configures a system cron job and systemd timer to renew certificates that are within 30 days of expiration. Verify that the automated renewal process runs correctly:
If the dry run completes without errors, your website is permanently secured with free, automated SSL certificates.
Nginx Directory Structure Quick Reference
To help you manage your new web server, here are the key file locations you should be familiar with:
| File / Directory | Purpose |
|---|---|
/var/www/ | Parent directory where all website files and document roots are stored. |
/etc/nginx/ | Main Nginx configuration directory. Contains server settings. |
/etc/nginx/nginx.conf | The primary Nginx configuration file. Controls global server settings. |
/etc/nginx/sites-available/ | Contains individual configuration files for each server block (website). |
/etc/nginx/sites-enabled/ | Contains symlinks to the active server block files Nginx reads on startup. |
/var/log/nginx/ | Log directory containing access and error logs. Crucial for troubleshooting. |
Why FlashRDP for Installing Nginx & Hosting Websites
FlashRDP Virtual Private Servers are engineered to deliver maximum speed, isolation, and control for web developers and system administrators:
- True Hardware Isolation: Our KVM-based virtualization ensures that your CPU and RAM allocations are fully dedicated to your server, providing consistent website performance.
- Enterprise Storage: With NVMe M.2 solid-state drives, your Nginx server can read static assets and run high-traffic database operations with sub-millisecond I/O latency.
- Unmetered 1 Gbps Bandwidth: FlashRDP plans feature unmetered data transfers with no surprise overage charges, allowing your websites to handle heavy visitor spikes effortlessly.
- Instant Deployment: Launch your unmanaged Linux VPS with Ubuntu, Debian, or Rocky Linux in under 3 minutes, fully automated and ready for configuration.
- DDoS Mitigation: Always-on Layer 4 protection is included for free with every instance, keeping your Nginx websites online during malicious traffic spikes.
- Zero-KYC & Crypto-Friendly: Protect your privacy and host your site anonymously. We accept 50+ cryptocurrencies (Bitcoin, USDT, Litecoin) and require no identity documents.
VPS hosting plans start at just $11.99/month. View all Linux VPS hosting plans.
Frequently Asked Questions
What is the difference between Nginx and Apache?
Nginx is designed with an asynchronous, event-driven architecture, making it highly efficient at serving static files and handling a massive number of concurrent connections with low memory usage. Apache uses a process-per-connection model which can consume more RAM under high traffic volumes. Nginx is also commonly deployed in front of Apache as a reverse proxy.
How do I restart Nginx after modifying configuration files?
You can test your files with sudo nginx -t to check for syntax errors. If the test passes, restart the service with sudo systemctl restart nginx to apply changes, or run sudo systemctl reload nginx to apply updates without dropping active connection pools.
Where are the default Nginx web files stored?
On Ubuntu, the default Nginx landing page is stored in /var/www/html/index.nginx-debian.html. However, when hosting a custom domain, you should create a separate directory (e.g., /var/www/example.com/html/) to keep your websites organized.
Do I need multiple VPS instances to host multiple websites?
No. With Nginx server blocks, you can easily host dozens of different websites on a single VPS plan. FlashRDP's Bronze VPS plan ($11.99/month with 4 GB RAM) is more than powerful enough to host multiple low-to-medium traffic websites, databases, and APIs simultaneously using Nginx.
How do I troubleshoot Nginx errors?
If Nginx fails to restart or your website displays an error, inspect the global error logs at /var/log/nginx/error.log or run sudo journalctl -xeu nginx to review detailed startup diagnostics.
Can I run Python, Node.js, or PHP applications using Nginx?
Yes. Nginx acts as a high-performance reverse proxy for backend applications. You can use PHP-FPM for PHP sites, or proxy incoming traffic to a specific port on your VPS where your Node.js, Python, or Go application is running.

Rohan
Operations Manager & Founder
Operations Manager at FlashRDP. With 5+ years in cloud infrastructure, Rohan specializes in KVM virtualization, network security, and building privacy-focused hosting solutions for professionals worldwide.




