DEV Community

Cover image for 21.Apache Troubleshooting
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

21.Apache Troubleshooting

Lab Information

xFusionCorp Industries uses some monitoring tools to check the status of every service, application, etc running on the systems. Recently, the monitoring system identified that Apache service is not running on some of the Nautilus Application Servers in Stratos Datacenter.

  1. Identify the faulty Nautilus Application Server and fix the issue. Also, make sure Apache service is up and running on all Nautilus Application Servers. Do not try to stop any kind of firewall that is already running.

  2. Apache is running on 5004 port on all Nautilus Application Servers and its document root must be /var/www/html on all app servers.

  3. Finally you can test from jump host using curl command to access Apache on all app servers and it should be reachable and you should get some static page. E.g. curl http://stapp01:5004/.

Lab Solutions

🧭 Part 1: Lab Step-by-Step Guidelines

1️⃣ Login to jump host

ssh thor@jump_host
# Password: mjolnir123
Enter fullscreen mode Exit fullscreen mode

2️⃣ Identify faulty app server

Test all servers:

curl http://stapp01:5004/
curl http://stapp02:5004/
curl http://stapp03:5004/

3️⃣ Login to faulty server

Example:

ssh tony@stapp01
# Password : Ir0nM@n
sudo -i
Enter fullscreen mode Exit fullscreen mode

(Use correct user for each server)

4️⃣ Check Apache status

systemctl status httpd
Enter fullscreen mode Exit fullscreen mode

5️⃣ Fix Apache issues

βœ… Set correct port (5004)

vi /etc/httpd/conf/httpd.conf
Enter fullscreen mode Exit fullscreen mode

Check:

Listen 5004

βœ… Start and enable Apache

systemctl restart httpd
systemctl enable httpd
systemctl status httpd
Enter fullscreen mode Exit fullscreen mode

6️⃣ Verify locally on that server

curl http://stapp01:5004/

7️⃣ Repeat check on all app servers

Login to each:

ssh steve@stapp02
# Password : Am3ric@
sudo -i
sudo systemctl status httpd
sudo systemctl restart httpd
journalctl -xeu httpd.service
# Change ServerRoot "/etc/httpd"
vi /etc/httpd/conf/httpd.conf
systemctl restart httpd
systemctl enable httpd
systemctl status httpd
curl http://stapp02:5004/
Enter fullscreen mode Exit fullscreen mode
ssh banner@stapp03
# Password: BigGr33n
sudo -i
sudo systemctl status httpd
sudo systemctl restart httpd
journalctl -xeu httpd.service
# Uncomment Listen 5004 and  Add " " at DocumentRoot "/var/www/html"
vi /etc/httpd/conf/httpd.conf
systemctl restart httpd
systemctl enable httpd
systemctl status httpd
curl http://stapp03:5004/
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ All must be running

πŸ‘‰ All should return a webpage

🧠 Part 2: Simple Step-by-Step Explanation (Beginner Friendly)

What this lab is about

You are fixing a real production issue:

Some servers are working, some are broken β†’ find and fix them

Step 1: Find which server is broken
curl http://stapp01:5004/
curl http://stapp02:5004/
curl http://stapp03:5004/

πŸ‘‰ This is like checking:

β€œWhich machine is not responding?”
If it shows a page β†’ βœ… working
If it fails β†’ ❌ faulty server

Step 2: Check Apache service

systemctl status httpd

πŸ‘‰ This tells you:

Is Apache running or stopped?

Step 3: Fix configuration issues

You checked logs:

journalctl -xeu httpd.service

πŸ‘‰ Logs tell you:

Why Apache failed
Common problems you fixed

πŸ”΄ Problem 1: Wrong ServerRoot

ServerRoot /var/www/html ❌

πŸ‘‰ This is wrong because:

ServerRoot = where Apache system files are stored

Correct:

ServerRoot "/etc/httpd" βœ…

πŸ”΄ Problem 2: Port not configured

Listen 5004

πŸ‘‰ Apache must listen on the correct port, otherwise:

curl http://server:5004 β†’ will fail

πŸ”΄ Problem 3: DocumentRoot formatting

DocumentRoot /var/www/html ❌

Correct:

DocumentRoot "/var/www/html" βœ…

πŸ‘‰ Quotes are important in Apache config.

Step 4: Restart Apache

systemctl restart httpd

πŸ‘‰ Applies your fixes.

Step 5: Verify again

curl http://stapp02:5004/

πŸ‘‰ Now it should work.

Step 6: Repeat for all servers

Each server can have different issues:

Server Issue
stapp01 may be OK
stapp02 ServerRoot broken
stapp03 Listen/DocumentRoot issue

πŸ‘‰ So you fix each one individually

πŸ” Final Flow (Very Important)

Test β†’ Find broken server β†’ Check service β†’ Check logs β†’ Fix config β†’ Restart β†’ Test again

⚑ Key Concepts You Learned

1️⃣ Services depend on config

Wrong config β†’ service won’t start

2️⃣ Logs are your best friend

journalctl -xeu httpd.service

πŸ‘‰ Always tells the real problem

3️⃣ Apache has strict syntax

Small mistake β†’ full service failure

4️⃣ Ports must match requirement

Apache must listen on 5004

βœ… Final Result
All app servers:
βœ” Apache running
βœ” Port 5004 working
βœ” curl returns webpage

🎯 Key Takeaway

Don’t guess β†’ Test β†’ Read logs β†’ Fix exactly what’s broken


Resources & Next Steps
πŸ“¦ Full Code Repository: KodeKloud Learning Labs
πŸ“– More Deep Dives: Whispering Cloud Insights - Read other technical articles
πŸ’¬ Join Discussion: DEV Community - Share your thoughts and questions
πŸ’Ό Let's Connect: LinkedIn - I'd love to connect with you

Credits
β€’ All labs are from: KodeKloud
β€’ I sincerely appreciate your provision of these valuable resources.

Top comments (0)