T
T
Tortway2015-09-20 01:07:00
linux
Tortway, 2015-09-20 01:07:00

How to create a shared folder for all virtual hosts in Apache?

Now everything looks like this:

www{
    sites{
          styles{ style.css }
          site1{ index.php } #В конфиге: DocumentRoot /www/sites/site1
          site2{ index.php } #В конфиге: DocumentRoot /www/sites/site2
    }
}

How can I make the styles folder public for both sites? Or this will not work and you will have to copy it for each site to the root. The problem is that there are many sites, and the styling is the same, including the js files are also the same.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
littleguga, 2015-09-20
@Tortway

As an option, assign each site an alias for styles and js

<VirtualHost *:80>
        DocumentRoot "/var/www/sites/site1"
        ServerName "site1.ru"

        Alias /styles /var/www/sites/styles
        Alias /js /var/www/sites/js
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot "/var/www/sites/site2"
        ServerName "site2.ru"

        Alias /styles /var/www/sites/styles
        Alias /js /var/www/sites/js
</VirtualHost>

T
Tortway, 2015-09-20
@Tortway

ln -s /www/sites/styles/ /www/sites/site1/styles
ln -s /www/sites/styles/ /www/sites/site2/styles

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question