M
M
Mikhail Fedotov2021-01-06 22:46:50
Apache HTTP Server
Mikhail Fedotov, 2021-01-06 22:46:50

How to create virtual host outside DocumentRoot?

There is a default configured Apache.
DocumentRoot is registered in httpd.conf, for example,
/Users/user_name/server

Now I want to create a virtual host and go to httpd-vhosts.conf
and write there

<VirtualHost *:80>
 ServerName test.localhost
 ServerAlias test.localhost
 VirtualDocumentRoot "/Users/user_name/some_folder"
 DocumentRoot "/Users/user_name/some_folder"
</VirtualHost>


As a result, I get 403 forbidden at test.localhost.
I believe this is because the original (httpd.conf) DocumentRoot is different from the one in .

Actually, the question is:
How and is it even possible to scatter virtual hosts in completely different places that differ from the original DocumentRoot ?
If possible, what and where should I write to make it work?

UPDATE:
Played with the rights a little. Now I go to the site normally, but instead of the site I see an Index of / and a list of pages.
.htaccess is set up fine. Working sites that I transfer to the same folder also become Index of /
In Apache logs like this:
client denied by server configuration: /Users/user_name/some_folder/.htaccess

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-01-07
@Libiros

I guess this is because the original (httpd.conf) DocumentRoot is different from the one in

Not because of this.
Add to VirtualHost
<Directory "/Users/user_name/some_folder">
    Require all granted
</Directory>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question