Test and Troubleshoot Chrooted Apache Jail

This is 3rd and the final installment for Apache Chroot Jail for CentOS / RHEL series. Once Apache is configured with mod_chroot, you may need to test and debug problems. This article will provide a few troubleshooting tips.

Check Log Files

As always check Apache’s error log files. In our case apache’s error log located inside each domains’ directory. For example in our sample setup error_log for nixcraft.com is located at /httpdjail/home/httpd/.nixcraft.com/logs/error_log. The relevant error should be logged to error_log. Use less or grep to view Apache error log files:
# tail -f /httpdjail/home/httpd/.nixcraft.com/logs/error_log
# grep error /httpdjail/home/httpd/.nixcraft.com/logs/error_log

Dealing with segmentation fault

If you are seeing any kind of segmentation fault, or any error that appears to be coming from Apache, try following troubleshooting guide

You can always run strace as follows:
# pgrep httpd
# strace -s 2000 -p {PID-of-HTTPD} -o /tmp/httpd

strace will write findings to /tmp/httpd.PID-of-HTTPD file. This provides lots of good information to get rid of problems.

Databases Configuration

Chrooted Apache cannot access MySQL database via a UNIX socket which is outside of your chroot jail. Configure MySQL to listen on and update php / perl script to connect host

PHP mail() function and sendmail not working

PHP needs a sendmail binary to send mail. You have few options here:

Use a class/function that knows how to send directly via SMTP. See how to send an email using PHP SMTP server. You also need to “Install PHP Pear Mail / SMTP package on CentOS / Red Hat Enterprise Linux” to use this option.

Alternatively, you can install mini_sendmail or sSMTP or nbsmtp. Put SMTP only binary inside your jail, and deliver mail via a smarthost.

Dealing with DNS lookups

You need to install a small caching server listening on such as dnsmasq dns caching server.

Testing your setup scripts

Test php installtion inside your jail.

Test MySQL database connectivity using PHP inside your jail.

Test MySQL database connectivity using PERL inside your jail.

Patched /etc/init.d/httpd init script.


  1. Apache project documentation.
  2. mod_chroot project.
  3. lighttpd – chroot jail setup.
  4. man pages httpd, httpd.conf, yum, strace, tail, and grep.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum