How do I modify and add Apache's default site directory

  • 2020-07-21 07:06:16
  • OfStack

1. Modify the default site directory of Apache
After the installation of Apache HTTP Server, the default site directory is located in the htdocs folder under the installation directory, and the default home page is the index.html file of the folder. For example, my Apache is installed in the C: / wamp bin apache/Apache2. 2.21, so my Apache complete address of the site directory by default is C: / wamp/bin/apache/Apache2 / htdocs / 2.21, the default home page is C: / wamp bin apache/Apache2. 2.21 / htdocs/index html.

Many times, whether it's learning, testing, or actually building your site, you may not want to put your site in the Apache default site directory, but this section will help you out.

Modification method:
1. Go to the installation directory of Apache and find the conf folder. In this folder, there will be a text document like ES38en. conf, which is the configuration file of Apache and is responsible for directing the operation of Apache.

2. Double-click to open the text document httpd.conf, press the Ctrl+F combination key on the keyboard to find "DocumentRoot" (with English double quotation marks, see the figure), and after finding out (there is only one place), modify the string inside the double quotation marks after the string "DocumentRoot" into the website directory you want to set.

Such as the default for DocumentRoot "C: / wamp/bin/apache/Apache2. 2.21 / htdocs", is now modified into DocumentRoot D/Apache: ""

3. After the completion of the second step above, do not close the file httpd. conf, and continue to search for" < Directory "" (with double quotation marks), find" < After Directory "", change the string inside the double quotation marks after the first" Directory "string to the website directory you want to set.

For example: default is < Directory "C:/wamp/bin/apache/Apache2.2.21/htdocs" > , which is now amended as < Directory " D:/Apache" >

4. At the same time, press the Ctrl+S combination key on the keyboard to save the above modifications. Remember to stop (STOP) Apache service once and then start (START) again to make the modification take effect.


Related articles: