A
A
Artyom N2011-10-07 18:34:51
Apache HTTP Server
Artyom N, 2011-10-07 18:34:51

Automatic addition of VirtualHosts in apache2 [Ubuntu Server]?

Good evening!
I'm trying to make a local server in a virtual machine. I don't have much experience, so the questions are probably simple and stupid.
It is necessary to automatically read the names of directories in a certain directory when starting the server and create virtual hosts for Apache with the names of these directories. In principle, creating a virtual host does not cause problems for me. The problem is bash.
I figured out how to create a virtual host for a specific directory in bash, knowing its name. How can I read all directory names in a loop? However, their number may change. Maybe you don’t need to write your own script and somewhere there is a ready-made solution?
And one more follow-up question. Is it necessary to enable rewrite after creating hosts or is it not important?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
max_rip, 2011-10-07
@nobr

rewrite can be included in .htaccess, especially since the task is most likely for tests.
What about listing directories?

for dir in `ls -F1 /где_смотреть | grep -e ./ | tr -d \/`
do
echo $dir
done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question