Jump to content

Question

Posted

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>

Share this post


Link to post
Share on other sites

2 answers to this question

  • 0

Posted

<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.

Share this post


Link to post
Share on other sites
  • 0

Posted

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>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.