How to Set Up Nginx Server Blocks on CentOS Stream 10

To set up multiple websites on an Nginx server in CentOS Stream 10, you can configure Nginx server blocks, which allow hosting multiple domains on a single server. Follow these steps to get started.

Step 1 : Ensure Nginx is installed and running on your system. Run the following command:

If Nginx is not installed, use the following to install it:

Step 2 : Create a directory for your website files:

Create a sample index.html file:

Step 3 : Set ownership and permissions to ensure Nginx can access the files:

Step 4 : Create a configuration file for example.com:

Add the following content:

Save and exit the file.

Step 5 : If SELinux is enabled, run the following command to set the correct context:

Step 6 : Test the Nginx configuration for syntax errors:

Step 7 : If the test is successful, reload Nginx to apply the changes:

Step 8 : Open a browser and visit http://example.com. You should see the message: "Success! example.com is set up!"

Congratulations! You have successfully set up an Nginx server block on CentOS Stream 10. You can now repeat these steps to host additional websites on the same server.