To set up multiple websites on CentOS Stream 9 using Nginx server blocks, follow the steps below.
Step 1 : Check Nginx Installation
Step 2 : Create example.com Directory and Index File
Inside index.html, add your HTML content. For example:
Step 3 : Set ownership and permissions to allow Nginx to access and serve content from the specified directory:
Step 4 : Create the Nginx configuration file for your website:
Inside the configuration file, add the server block settings for example.com:
Step 5 : If SELinux is enabled, set the SELinux context to allow Nginx to access the directory:
Step 6 : Test the Nginx configuration for syntax errors:
Step 7 : Restart the Nginx service to apply the changes:
Step 8 : Open a web browser and navigate to your test domain.
Congratulations, you have successfully set up Nginx server blocks on CentOS Stream 9.