To set up multiple websites on an Nginx server using AlmaLinux 9, follow these steps:
Step 1 : Check if Nginx is Installed
First, ensure that Nginx is installed on your system:
Once installed, start and enable Nginx:
Step 2 : Create a Directory for Your Website
Create a directory to store your website's files:
Then, create a simple index.html
file:
Step 3 : Set Proper Permissions
Set the correct ownership and permissions for the directory:
Step 4 : Create an Nginx Configuration File
Create a new configuration file for example.com
:
Add the following content:
Save and exit the file.
Step 5 : Configure SELinux (if enabled)
If SELinux is enabled, adjust the context for the web directory:
Step 6 : Test the Configuration
Before applying the changes, test the Nginx configuration:
If there are no errors, proceed to the next step.
Step 7 : Restart Nginx
Restart Nginx to apply the new configuration:
Step 8 : Access Your Website
Open a web browser and visit http://example.com
. If everything is set up correctly, you should see your test page.
Congratulations! You have successfully set up an Nginx server block on AlmaLinux 9.