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.
- Identify the faulty
Nautilus Application Serverand fix the issue. Also, make sure Apache service is up and running on allNautilus Application Servers. Do not try to stop any kind of firewall that is already running. - Apache is running on
8089port on allNautilus Application Serversand its document root must be/var/www/htmlon all app servers. o - Finally you can test from
jump hostusing 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:8089/.
Environment Details
| Server | Hostname | User | Password |
|---|---|---|---|
| App Server 1 | stapp01 | tony | Ir0nM@n |
| App Server 2 | stapp02 | steve | Am3ric@ |
| App Server 3 | stapp03 | banner | BigGr33n |
| Jump Host | jump-host | thor | mjolnir123 |
Step 1: Identify the Faulty Server
Connect to the jump host and test each app server.
ssh thor@jump-host
Password: mjolnir123
Test Apache on each server.
curl -I http://stapp01:8089/
curl -I http://stapp02:8089/
curl -I http://stapp03:8089/
In this scenario, all three servers returned connection refused, indicating Apache was not running on any of them.
curl: (7) Failed to connect to stapp01 port 8089: Connection refused
curl: (7) Failed to connect to stapp02 port 8089: Connection refused
curl: (7) Failed to connect to stapp03 port 8089: Connection refused
Step 2: Troubleshoot App Server 1 (stapp01)
Connect to stapp01 and switch to root.
ssh tony@stapp01
sudo su -
Check the Service Status
systemctl status httpd
The output showed the service was inactive.
○ httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
Active: inactive (dead)
Check the Configuration for Syntax Errors
httpd -t
The output revealed the root cause.
AH00526: Syntax error on line 47 of /etc/httpd/conf/httpd.conf:
Invalid command 'Listen 808989', perhaps misspelled or defined by a module not included in the server configuration
The Listen directive had a typo: Listen 808989 instead of Listen 8089.
Examine the Problematic Line
sed -n '40,55p' /etc/httpd/conf/httpd.conf
The line was:
"Listen 808989"
The line had quotes around it, which prevented standard sed commands from matching it.
Check DocumentRoot
grep "DocumentRoot" /etc/httpd/conf/httpd.conf
The output showed:
DocumentRoot /var/www/html;
The semicolon at the end made the path invalid.
Fix the Configuration
Remove the problematic line and ensure correct directives.
# Remove the line containing "Listen 808989"
sed -i '/Listen 808989/d' /etc/httpd/conf/httpd.conf
# Remove any other Listen lines with quotes
sed -i '/"Listen/d' /etc/httpd/conf/httpd.conf
# Ensure correct Listen directive
grep -q "^Listen 8089" /etc/httpd/conf/httpd.conf || echo "Listen 8089" >> /etc/httpd/conf/httpd.conf
# Fix DocumentRoot
sed -i 's|^DocumentRoot.*|DocumentRoot "/var/www/html"|' /etc/httpd/conf/httpd.conf
Verify the Fix
grep -n "^Listen" /etc/httpd/conf/httpd.conf
grep -n "^DocumentRoot" /etc/httpd/conf/httpd.conf
httpd -t
Expected output:
358:Listen 8089
124:DocumentRoot "/var/www/html"
Syntax OK
Start and Enable Apache
systemctl start httpd
systemctl enable httpd
systemctl status httpd
The service started successfully.
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running)
Main PID: 11989 (httpd)
Status: "Started, listening on: port 8089"
Step 3: Troubleshoot App Server 2 (stapp02)
Connect to stapp02 and switch to root.
ssh steve@stapp02
sudo su -
Check the Configuration
grep -n "^Listen" /etc/httpd/conf/httpd.conf
grep -n "^DocumentRoot" /etc/httpd/conf/httpd.conf
grep -n "^ServerRoot" /etc/httpd/conf/httpd.conf
The output showed two issues:
47:Listen 808989
124:DocumentRoot "/var/www/html"
34:ServerRoot "/etc/httpd;"
The Listen directive had a typo, and the ServerRoot had a semicolon making it invalid.
Check the Syntax
httpd -t
The output revealed the ServerRoot issue.
httpd: Syntax error on line 34 of /etc/httpd/conf/httpd.conf: ServerRoot must be a valid directory
Fix the Configuration
# Remove the problematic Listen line
sed -i '/Listen 808989/d' /etc/httpd/conf/httpd.conf
sed -i '/"Listen/d' /etc/httpd/conf/httpd.conf
# Ensure correct Listen directive
grep -q "^Listen 8089" /etc/httpd/conf/httpd.conf || echo "Listen 8089" >> /etc/httpd/conf/httpd.conf
# Fix ServerRoot
sed -i 's|^ServerRoot.*|ServerRoot "/etc/httpd"|' /etc/httpd/conf/httpd.conf
# Fix DocumentRoot
sed -i 's|^DocumentRoot.*|DocumentRoot "/var/www/html"|' /etc/httpd/conf/httpd.conf
# Ensure index.html
echo "Welcome to xFusionCorp Industries" > /var/www/html/index.html
Verify and Start Apache
grep -n "^ServerRoot" /etc/httpd/conf/httpd.conf
grep -n "^Listen" /etc/httpd/conf/httpd.conf
grep -n "^DocumentRoot" /etc/httpd/conf/httpd.conf
httpd -t
systemctl start httpd
systemctl enable httpd
systemctl status httpd
The service started successfully.
● httpd.service - The Apache HTTP Server
Active: active (running)
Status: "Started, listening on: port 8089"
Step 4: Troubleshoot App Server 3 (stapp03)
Connect to stapp03 and switch to root.
ssh banner@stapp03
sudo su -
Check the Configuration
grep -n "^ServerRoot" /etc/httpd/conf/httpd.conf
grep -n "^Listen" /etc/httpd/conf/httpd.conf
grep -n "^DocumentRoot" /etc/httpd/conf/httpd.conf
Apply the Same Fixes
# Fix ServerRoot
sed -i 's|^ServerRoot.*|ServerRoot "/etc/httpd"|' /etc/httpd/conf/httpd.conf
# Fix Listen
sed -i '/Listen 808989/d' /etc/httpd/conf/httpd.conf
sed -i '/"Listen/d' /etc/httpd/conf/httpd.conf
grep -q "^Listen 8089" /etc/httpd/conf/httpd.conf || echo "Listen 8089" >> /etc/httpd/conf/httpd.conf
# Fix DocumentRoot
sed -i 's|^DocumentRoot.*|DocumentRoot "/var/www/html"|' /etc/httpd/conf/httpd.conf
# Ensure index.html
echo "Welcome to xFusionCorp Industries" > /var/www/html/index.html
# Verify
grep -n "^ServerRoot" /etc/httpd/conf/httpd.conf
grep -n "^Listen" /etc/httpd/conf/httpd.conf
grep -n "^DocumentRoot" /etc/httpd/conf/httpd.conf
# Check syntax
httpd -t
# Start and enable
systemctl start httpd
systemctl enable httpd
systemctl status httpd
The service started successfully.
Step 5: Verify from Jump Host
Return to the jump host and test all servers.
curl http://stapp01:8089/
curl http://stapp02:8089/
curl http://stapp03:8089/
Expected output:
Welcome to xFusionCorp Industries!
Welcome to xFusionCorp Industries
Welcome to xFusionCorp Industries
All three servers returned the static page content successfully.
Summary of Issues and Fixes
| Server | Issue | Fix |
|---|---|---|
| stapp01 |
"Listen 808989" typo with quotes |
Removed line, added Listen 8089
|
| stapp01 | DocumentRoot /var/www/html; |
Fixed to DocumentRoot "/var/www/html"
|
| stapp02 |
Listen 808989 typo |
Removed line, added Listen 8089
|
| stapp02 | ServerRoot "/etc/httpd;" |
Fixed to ServerRoot "/etc/httpd"
|
| stapp03 | Same issues as stapp02 | Applied same fixes |
Verification Checklist
| Check | stapp01 | stapp02 | stapp03 |
|---|---|---|---|
| Apache running | Active | Active | Active |
| Port 8089 | Listening | Listening | Listening |
| DocumentRoot | /var/www/html | /var/www/html | /var/www/html |
| Index page | Present | Present | Present |
| curl test | 200 OK | 200 OK | 200 OK |
Common Apache Configuration Errors
| Error | Cause | Fix |
|---|---|---|
Invalid command 'Listen ...' |
Typo in port number | Correct the Listen directive |
ServerRoot must be a valid directory |
Semicolon or wrong path | Set ServerRoot "/etc/httpd"
|
DocumentRoot not working |
Semicolon in path | Set DocumentRoot "/var/www/html"
|
| Service fails to start | Syntax error | Run httpd -t to identify |
| Port already in use | Another service on port | Change port or stop conflicting service |
Best Practices
- Always run
httpd -tbefore restarting Apache to catch syntax errors. - Use
grep -nto view configuration lines with line numbers. - Remove problematic lines entirely rather than trying to edit them in place.
- Verify the ServerRoot, Listen, and DocumentRoot directives are correct.
- Ensure the index.html file exists in the document root.
- Check the service status after starting Apache.
- Test from a remote host to confirm the service is reachable.
Useful Commands
| Task | Command |
|---|---|
| Check syntax | httpd -t |
| Check service | systemctl status httpd |
| Start service | systemctl start httpd |
| Enable service | systemctl enable httpd |
| Check listening ports | `ss -tlnp \ |
| View configuration | {% raw %}grep -n "^Listen" /etc/httpd/conf/httpd.conf
|
| Remove a line | sed -i '/pattern/d' /etc/httpd/conf/httpd.conf |
| Replace a line | `sed -i 's\ |
Conclusion
This guide covered a complete Apache troubleshooting workflow on three application servers. The root causes were configuration errors: typos in the Listen directive, semicolons in ServerRoot and DocumentRoot paths, and quotes around directive values.
By systematically checking the service status, configuration syntax, and specific directives, the issues were identified and fixed. After correcting the configuration and restarting Apache, all three servers responded correctly on port 8089.
The key takeaway is that Apache configuration errors are often caused by small typos or stray characters. Using {% raw %}httpd -t to check syntax and grep to inspect specific directives makes troubleshooting efficient and reliable.
Top comments (0)