CHAPTER 8 How to Fix The Web: Obscure Back-End Techniques and Terminal Secrets
The end result, hopefully, is that you’ve definitively found the
document root for your website.
You can use a similar technique for nginx. It also has a main conf file,
usually in /etc/nginx/nginx.conf, and it can also include other conf files.
However its document root is just called “root”.
aPaChe ConTRol inTeRfaCe
With Apache, there is yet another way to find the right conf file, using the
apachectl or newer apache2ctl command with the -S option.
$ apachectl -S
VirtualHost configuration:
80.72.139.101:80 is a NameVirtualHost
default server default (/usr/local/psa/admin/conf/genera-
ted/13656495120.10089200_server.include:87)
port 80 namevhost default (/usr/local/psa/admin/conf/genera-
ted/13656495120.10089200_server.include:87)
port 80 namevhost http://www.smashingmagazine.com (/var/www/vhosts/
smashingmagazine.com/conf/last_httpd.include:10)...
If this whizzes by too fast, you can try piping the results through grep.
It won’t work, however, because grep only operates on stdout and for some
reason apachectl outputs its information to stderr. So, you have to first
direct stderr into stdout and then send it through grep. This is done by
redirecting the error stream 2 into the output stream 1 with 2>&1, like this:
$ apachectl -S 2>&1 | grep smashingmagazine
port 80 namevhost smashingmagazine.com (/var/www/vhosts/smas-
hingmagazine.com/conf/13656495330.08077300_httpd.include:10)
This also reveals the conf file which contains the DocumentRoot for
this website. As above further grep or less will reveal the DocumentRoot.