Nov 29th, 2023

How to change the default web page on the Nginx server?

Author Picture

Dhairya Shah

Software Engineer

Nginx is a powerful web server used for hosting websites and applications. If you’ve recently set up a Nginx server and want to customize the default page that visitors see when they access your site, then this article is for you. This article will guide you through the step-by-step process of changing the default web page on an Nginx server.

Step: 1 Locate the default web page

By default, Nginx serves a welcome page when you access your server’s IP address in a web browser. The default page is typically located in the /var/www/html. You can use the following command to navigate to the directory:

cd /var/www/html

Step: 2 Backup the default web page

Before making any changes, it’s a good practice to take a backup of the default web page. This way, you can easily revert back to the original server configuration if something goes wrong. To create a backup, you can run the following command

sudo cp index.html index.html.bak

This command creates a backup of the original index.html file with the extension .bak.

Step: 3 Edit the default web page

Now that you have backup, you can edit the default web page with your desired content. You can use a text editor of your preference like nano or vim to open the index.html file:

sudo nano index.html

Replace the existing content with your customized HTML code.

Step: 4 Save and Exit



Step: 5 Apply the changes

To apply the changes, you need to restart the Nginx server. You can do this using the following command:

sudo systemctl restart nginx

This command will restart the Nginx service, and you changes to the default web page will take effect.

Verify the changes

Open your web browser and navigate to the server’s IP address. You should now see the updated default web page that you configured.

Tada! You’ve successfully changed the default web page on your Nginx server. I hope this article provides a helpful resource for you.

Thanks for reading!