Nginx Task
Create Three Welcome Pages Using Nginx:
1. Update and Install Nginx
First, ensure your package list is up-to-date and install Nginx.
• sudo apt update
• sudo apt install nginx
2. Start and Enable Nginx
Start the Nginx service and ensure it starts on boot.
• sudo systemctl start nginx
• sudo systemctl enable nginx
3. Create Directories for Your Websites
Create directories to hold the content for each website.
• sudo mkdir -p /var/www/[Link]
• sudo mkdir -p /var/www/[Link]
• sudo mkdir -p /var/www/[Link]
4. Create HTML Files for the Websites
Create simple HTML files for each website.
• echo "<html><body><h1>Welcome to AxisPay</h1></body></html>" |
sudo tee /var/www/[Link]/[Link]
• echo "<html><body><h1>Welcome to Axis 01</h1></body></html>" |
sudo tee /var/www/[Link]/[Link]
• echo "<html><body><h1>Welcome to Axis 02</h1></body></html>" |
sudo tee /var/www/[Link]/[Link]
5. Configure Nginx to Serve the Websites
Create separate configuration files for each website.
• sudo nano /etc/nginx/sites-available/[Link]
Add the following configuration:
• server {
• listen 80;
• server_name [Link];
• root /var/www/[Link];
• index [Link];
• location / {
• try_files $uri $uri/ =404;
• }
• }
Save and close the file.
Create the configuration file for [Link]:
• sudo nano /etc/nginx/sites-available/[Link]
Add the following configuration:
• server {
• listen 80;
• server_name [Link];
• root /var/www/[Link];
• index [Link];
• location / {
• try_files $uri $uri/ =404;
• }
• }
Save and close the file.
6. Enable the Configuration Files
Create symbolic links to enable these configuration files.
• sudo ln -s/etc/nginx/sites-available/[Link] /etc/nginx/sites-enabled/
• sudo ln -s /etc/nginx/sites-available/[Link] /etc/nginx/sites-enabled/
• sudo ln -s /etc/nginx/sites-available/[Link] /etc/nginx/sites-enabled/
7. Test Nginx Configuration
Check the Nginx configuration for syntax errors.
• sudo nginx -t
8. Restart Nginx
Restart Nginx to apply the changes.
• sudo systemctl restart nginx
9. Update Your Hosts File
For testing purposes, update your local /etc/hosts file to map the domain names to your
server’s IP address.
• sudo nano /etc/hosts
Add the following lines, replacing your_server_ip with your actual server IP address:
• your_server_ip [Link]
• your_server_ip [Link]
• your_server_ip [Link]
10. Verify the Setup
Open a web browser and navigate to [Link] [Link] and
[Link] You should see the welcome pages you created for each domain.