Apache file root Settings modify the method of Document Root

  • 2020-05-06 12:01:06
  • OfStack

Find the information about modifying Apache server root directory on the Internet, compare and learn, and record
here When Apache is installed, the system is given a default file root directory.
If you find it inconvenient to store your web page in this default directory and think you should set another directory as the Apache file root, you can modify the Apache configuration file httpd.conf for the Apache file root.
Assume that the default file root (DocumentRoot) for Apache HTTP Server is:
DocumentRoot "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs"
To modify the Apache file root (DocumentRoot), do the following:

1. To avoid errors in modification, please backup your Apache configuration file httpd.conf, the path of which is
C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf

2. Open the http.conf file, find the line beginning with DocumentRoot, and then
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
Change to a new DocumentRoot path. For example, if your new path is C:\htdocs, change to
DocumentRoot "C:/htdocs"

3. Then find the following in the http.conf file,
# This should be changed to whatever you set DocumentRoot to.
#
< Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" >
Change the path in Diectory to your new root directory, e.g.
< Directory "C:/htdocs" >

4. Save the configuration file http.conf.

5. After modifying the configuration file, you should restart Apache Service. (Start -- > All Programs -- > Apache HTTP Server 2.2 -- > Monitor Apache Servers -- > Restart)
After you modify the file root, you can store your web pages in a new directory.

Related articles: