4

I need some help figuring why apache tells me that my document root does not exists.

My document root is /home/user/Documents/Git/site/index.html... It is there!

My vhost looks like

<VirtualHost *:80>
    ServerName site.com
    DocumentRoot /home/user/Documents/Git/site/index.html
    ErrorLog /home/user/Documents/Git/site/error.log
    <Directory /home/user/Documents/Git/site>
        Require all granted
    </Directory>
</VirtualHost>

Permissions are 775 for Git and its subfolders and files and in my hosts 127.0.1.1 site.com

What am I doing wrong?

Thanks

3 Answers 3

14

Your document root cannot be a file, it must be a directory.

1
  • 1
    I logged in the first time for years, just to upvote this. You are my hero. Aug 13, 2022 at 6:22
3

Use below command to know where is the apache configure file is: then to update the document root:

# apache2ctl -S   [On Debian/Ubuntu]
# apachectl -S    [On CentOS/RHEL]
OR
# httpd -S

it shows below:

AH00112: Warning: DocumentRoot [/usr/local/opt/httpd24/Users/YOURNAME/SOMESITE] does not exist
AH00112: Warning: DocumentRoot [/usr/local/opt/httpd24/c:/dev/blog] does not exist
VirtualHost configuration:
127.0.0.1:80           blog.localhost (/usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf:29)
172.18.0.4:80          Somesite.localhost (/usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf:24)
ServerRoot: "/usr/local/opt/httpd24"
Main DocumentRoot: "/Users/YOURNAME/Sites"
Main ErrorLog: "/usr/local/var/log/apache2/error_log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/usr/local/var/run/apache2/" mechanism=default 
Mutex mpm-accept: using_defaults
PidFile: "/usr/local/var/run/apache2/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="YOURNAME" id=501 not_used
Group: name="staff" id=20 not_used

In this case , you will know the warning, then update the Vhost file to delete the Vhosts.

   sudo nano /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf

It works!!!

1

Yes, document root can not be a file such as index.html. Create a root like /var/www. Not like /var/www/index.html

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.