New Perspectives On Web Design

(C. Jardin) #1

CHAPTER 8 How to Fix The Web: Obscure Back-End Techniques and Terminal Secrets


The end result is that this find command tells you roughly where your
document root is. In Plesk, all the virtual hosts are generally stored within
the /var/www/vhosts directory, with the document roots in /var/www/
vhosts/domain.com/httpdocs.

The long waY
You can find the document root more accurately by looking through the
configuration files. For Apache servers, you can find the default website’s
document root by looking through the main configuration file which is
usually /etc/apache2/apache2.conf or /etc/httpd/conf/httpd.conf.
$ grep DocumentRoot /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html"

Somewhere inside this conf file will also be an Include line which
references other conf files, which may themselves include further conf
files. To find the DocumentRoot for your virtual host, you’ll need to
search through them all. You can do this using grep and find but its a long
command, so we will build it up gradually.
First, we will find all the files (because of the -type f) on the whole
server (the /) whose names end in “conf” or “include”. The -type f finds
only files and the -o lets us look for files ending in “conf” or “include”, with
surrounding escaped parentheses. As above, the errors are banished into
the ether:

$ find / -type f \( -name \*conf -o -name \*include \) 2> /dev/null
/var/spool/postfix/etc/resolv.conf
/var/some file with spaces.conf
/var/www/vhosts/myserv.com/conf/last_httpd.include...

This is not quite complete as any files with spaces will confuse the grep
command we are about to attempt. To fix that you can pipe the output of
the find command through the sed command which allows you to specify a
Free download pdf