server by using the appropriate
XAMPP startup command, or the apachectl or apache2ctl commands described later in this section in Starting and Stopping
Apache.”
If you see some response when you try to load a page in your browser, you can try placing content in the server’s document root. Let’s see how to find this directory.
The Apache Document RootThe
document root is the base or parent directory in which the web server stores web resources (such as HTML, PHP, or image files) and serves them to web browsers. For the Apache web server, common locations of the document root include:
Linux/var/www/html,
/var/www/htdocs, or
/var/www fora distribution installation
/usr/local/apache/htdocs fora standalone installation, and
/opt/lampp/htdocs for an
XAMPP installation.
WindowsC:\Program Files\xampp\htdocs for an XAMPP installation, and
C:\Program Files\Apache Group\Apache2\htdocs if Apache is installed independently
Mac OS X/Applications/xampp/htdocs for an XAMPP installation, and
/Library/WebServer/Documents for the installation of Apache that is part of the standard Mac OS X
configuration
If you’re using a Linux system and don’t know where your server’s document root is,
search for it by following these instructions.
First, login as the
system superuser by typing su -in a terminal window. Then try to list the common document root directories that we listed previously
ls -directory /var/www/html /var/www/htdocs /var/www /usr/local/apache/htdocs/bin/ls: /var/www/htdocs:
No such file or directory/bin/ls: /usr/local/apache/htdocs: No such file or directory
/var/www /var/www/html
The directory option asks the ls program to list only directory names, and not their contents.
If you get an error message fora directory, that directory doesn’t exist. Where
the directory name is listed, as for
/var/www and
/var/www/html above, the directory exists.
One of these is likely to be the document root. If none of the directories exist, you can try searching your whole filesystem fora directory called htdocs
:
#
find / -typed -name htdocsBe patient this may take a few minutes. Any directory it finds is likely to be the directory root if more than one is found, you’ll need to experiment by creating files in each to determine which is the one used by your Apache installation.
Share with your friends: