This project about more Web stack debugging cases.
I learnt about tmux and strace and how to use them to debug web applications.
These are the steps I took for the project.
- Start the
tmuxsession:tmux - List Apache Processes (parent/child):
ps aux | grep apache - Attach strace to "the" Apache Process:
sudo strace -p <PID> - Trigger the 500 Error:
- split
tmuxinto two panes:C-b % - on the new pane, use
curlto Trigger the Error:curl -sI 127.0.0.1
- split
- Analyze the
straceOutput:- look for error messages or failed system calls
- in this case,
error: No such file or directoryrelated to a.phppfile, a typo
- Search for the files containing the typo error:
grep -ro "phpp" <PATH>
root@07778635a2a2:/# grep -ro "phpp" /var/www/html
/var/www/html/wp-includes/js/zxcvbn.min.js:phpp
/var/www/html/wp-includes/js/zxcvbn.min.js:phpp
/var/www/html/wp-includes/js/zxcvbn.min.js:phpp
/var/www/html/wp-includes/js/zxcvbn.min.js:phpp
/var/www/html/wp-includes/js/zxcvbn.min.js:phpp
/var/www/html/wp-includes/js/zxcvbn.min.js:phpp
/var/www/html/wp-settings.php:phpp
root@07778635a2a2:/#- Inspect "the" file and fix the typo occurence(s):
- search for the line number(s) containing the typo:
grep -n "phpp" <PATH> - open the file and make the necessary correction. (from
.phppto.php)
- search for the line number(s) containing the typo:
- write puppet manifest to fix the typo error:
0-strace_is_your_friend.pp
Here's a video I watched, that's on how strace can be used to debug an applications. YouTube
Each file contains the solution to a task in the project.
- 0-strace_is_your_friend.pp: Using
strace, find out why Apache is returning a 500 error. Once you find the issue, fix it and then automate it using Puppet (instead of using Bash as you were previously doing).