Day 19/100 of DevOps
Day 19: Install and Configure Web Application
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:
Login to the App Server 2.
ssh steve@stapp02
Install httpd
sudo yum install httpd -y
Edit the
httpd.conffile and change the port to5001sudo vi /etc/httpd/conf/httpd.conf
Change the port to
5001.
save and exit.
Start and check the status of httpd
systemctl start httpdsystemctl enable httpdsystemctl status httpd
Open another terminal and from jump host copy the required file to the
/tmpdirectory of stapp02.scp -r /home/thor/apps tony@stapp02:/tmp/ scp -r /home/thor/ecommerce tony@stapp02:/tmp/
Verify if files are copied to
/tmpdirectory of stapp02
Move the files from
/tmpto/var/www/htmlsudo 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/orhttp://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 asindex.htmlorindex.php, which serve as the entry points for your site.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
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.confAt 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.
Verify using the
curlcommand.curlhttp://localhost:5001/ecommerce/curlhttp://localhost:5001/apps/