Skip to main content

Command Palette

Search for a command to run...

Day 19/100 of DevOps

Day 19: Install and Configure Web Application

Published
3 min read

xFusionCorp Industries is planning to host two static websites on their infra in Stratos Datacenter. The development of these websites is still in-progress, but we want to get the servers ready. Please perform the following steps to accomplish the task:
a. Install
httpd package and dependencies on app server 2.
b. Apache should serve on port
5001.
c. There are two website's backups
/home/thor/ecommerce and /home/thor/apps on jump_host. Set them up on Apache in a way that ecommerce should work on the link http://localhost:5001/ecommerce/ and apps should work on link http://localhost:5001/apps/ on the mentioned app server.
d. Once configured you should be able to access the website using
curl command on the respective app server, i.e curl http://localhost:5001/ecommerce/ and curl http://localhost:5001/apps/

Apache, officially called Apache HTTP Server, is a web server software — it’s what delivers websites to users over the internet.

When you visit a website like: http://xyz.com

your browser sends a request to a web server.
If that server is running Apache, it receives the request, finds the correct webpage (like an HTML file), and sends it back to your browser.

Step by step process:

  1. Login to the App Server 2.

    ssh steve@stapp02

  2. Install httpd

    sudo yum install httpd -y

  3. Edit the httpd.conf file and change the port to 5001

    sudo vi /etc/httpd/conf/httpd.conf

    Change the port to 5001.

    Chane the port to 5001

    save and exit.

  4. Start and check the status of httpd

    systemctl start httpd

    systemctl enable httpd

    systemctl status httpd

  5. Open another terminal and from jump host copy the required file to the /tmp directory of stapp02.

    scp -r /home/thor/apps tony@stapp02:/tmp/ scp -r /home/thor/ecommerce tony@stapp02:/tmp/

    Verify if files are copied to /tmp directory of stapp02

  6. Move the files from /tmp to /var/www/html

    sudo mv /tmp/apps /var/www/html/ sudo mv /tmp/ecommerce /var/www/html/

    Now your content directories are:

    /var/www/html/apps /var/www/html/ecommerce

    /var/www/html is the typical/default location.It holds the public-facing content of a website. When a user visits your server's address (e.g., http://localhost/ or http://your_domain_name/), the web server (Apache, Nginx, etc.) looks for files within this specific directory. This folder typically contains your main website files, such as index.html or index.php, which serve as the entry points for your site.

  7. Set permissions.

    sudo chown -R apache:apache /var/www/html/ecommerce /var/www/html/apps sudo chmod -R 755 /var/www/html/ecommerce /var/www/html/apps

  8. Configure Virtual Hosts

    Although both can work directly under /var/www/html, it’s cleaner to create directory aliases.

    Edit the Apache config file again:

     sudo vi /etc/httpd/conf/httpd.conf
    

    At the bottom, add:

     Alias /media /var/www/html/apps
     <Directory /var/www/html/apps>
         AllowOverride None
         Require all granted
     </Directory>
    
     Alias /games /var/www/html/ecommerce
     <Directory /var/www/html/ecommerce>
         AllowOverride None
         Require all granted
     </Directory>
    

    Save and exit.

  9. Verify using the curl command.

    curl http://localhost:5001/ecommerce/

    curl http://localhost:5001/apps/