0% found this document useful (0 votes)
10 views3 pages

Nginx Task

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Nginx Task

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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/axispay.com


• sudo mkdir -p /var/www/axis-01.com
• sudo mkdir -p /var/www/axis-02.com

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/axispay.com/index.html
• echo "<html><body><h1>Welcome to Axis 01</h1></body></html>" |
sudo tee /var/www/axis-01.com/index.html
• echo "<html><body><h1>Welcome to Axis 02</h1></body></html>" |
sudo tee /var/www/axis-02.com/index.html

5. Configure Nginx to Serve the Websites

Create separate configuration files for each website.


• sudo nano /etc/nginx/sites-available/axispay.com

Add the following configuration:

• server {
• listen 80;
• server_name axispay.com;
• root /var/www/axispay.com;
• index index.html;
• location / {
• try_files $uri $uri/ =404;
• }
• }

Save and close the file.

Create the configuration file for axis-01.com:

• sudo nano /etc/nginx/sites-available/axis-01.com

Add the following configuration:

• server {
• listen 80;
• server_name axis-01.com;
• root /var/www/axis-01.com;
• index index.html;
• 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/axispay.com /etc/nginx/sites-enabled/
• sudo ln -s /etc/nginx/sites-available/axis-01.com /etc/nginx/sites-enabled/
• sudo ln -s /etc/nginx/sites-available/axis-02.com /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 axispay.com
• your_server_ip axis-01.com
• your_server_ip axis-02.com

10. Verify the Setup

Open a web browser and navigate to http://axispay.com, http://axis-01.com, and


http://axis-02.com. You should see the welcome pages you created for each domain.

You might also like