Jump to content



Photo

Change Apache <Directory> for entire site directory


  • Please log in to reply
2 replies to this topic

#1 Mr.XXIV

Mr.XXIV

    Shine bright like Iron Man.

  • Tech Issues Solved: 1
  • Joined: 30-April 11
  • Location: Durham, North Carolina
  • OS: OS X Yosemite
  • Phone: iPhone 5s

Posted 02 October 2013 - 05:54

Alright, so normally I like to keep my files organized, my entire server in the VirtualBox actually. I was thinking about running the server on my very Mac itself, but I think running Linux inside a box, which I could duplicate for backups is more necessary.

 

All of my sites have their own .conf because I run many subdomains and whatnot to keep everything categorized.

 

Here's my question: I have my Virtual Hosts set up as what I have listed below where each Directory have their own Options and Indexes, but how do I create just ONE <Directory> setting for all of the subdomains including the domain itself? Because I feel like I'm just rewriting the same thing over and over and I feel like it's a waste of a file.

<VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        ServerAdmin mrxxiv@icloud.com
        DocumentRoot /var/www/example/public
 
        <Directory "/var/www/example/public">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
 
<VirtualHost *:80>
ServerName dyno.example.com
        ServerAdmin mrxxiv@icloud.com
        DocumentRoot /var/www/example/dyno
 
        <Directory "/var/www/example/dyno">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>



#2 DeathLace

DeathLace

    Neowinian God!

  • Joined: 27-November 01
  • Location: Toronto, Canada

Posted 03 October 2013 - 21:30

<VirtualHost *:80>
ServerAlias *.cimi.dev
 
RewriteEngine On
RewriteCond %{HTTP_HOST} !^cimi.dev$
RewriteRule .* /%{HTTP_HOST}/www%{REQUEST_URI}
 
DocumentRoot /Users/rcimicata/Sites/cimi
</VirtualHost>
 
 
I use something like this.  This way if I make a file inside /Users/rcimicata/Sites/cimi/test.cimi.dev/
 
Then it'll load:
/Users/rcimicata/Sites/cimi/test.cimi.dev/www/index.php as the default file for the website (or index.html):
 
I just have to update my hosts file so it loads this dummy domain obviously. Since yours may be real domains it'll just load properly and work :).
 
Hope this helps with what you're doing.


#3 OP Mr.XXIV

Mr.XXIV

    Shine bright like Iron Man.

  • Tech Issues Solved: 1
  • Joined: 30-April 11
  • Location: Durham, North Carolina
  • OS: OS X Yosemite
  • Phone: iPhone 5s

Posted 03 October 2013 - 22:34

I forgot to throw in that I created the solution a few days later.

 

This will globally handle everything within that configuration file.

 

I'm running Ubuntu 13.04, PHP 5.5.4 and Apache 2.4.6, so I want everything to run efficiently instead of relying on several htaccess'. Sorry, this is what I had in mind. I'm using WordPress Network to virtually run multiple sites without having to install WordPress over and over, plus the fact that I need users to be logged on across the network.

NameVirtualHost *:80
 
ServerAdmin mrxxiv@icloud.com
DocumentRoot "/var/www/example/public"
<Directory "/var/www/example">
     Options Indexes FollowSymLinks MultiViews Includes
     AllowOverride All
     Order allow,deny
     Allow from all
     AddType application/vnd.ms-fontobject .eot
     AddType font/ttf .ttf
     AddType font/otf .otf
     AddType application/x-font-woff .woff
     AddType application/font-woff .woff
</Directory>
 
<VirtualHost *:80>
     ServerName example.com
     ServerAlias www.example.com
</VirtualHost>
 
<VirtualHost *:80>
     ServerName dyno.example.com
     DocumentRoot /var/www/example/dyno
</VirtualHost>
 
<VirtualHost *:80>
     ServerName forums.example.com
     DocumentRoot /var/www/example/community/forums
</VirtualHost>