Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Aug 23, 2012 12:05 pm 
Offline
Newbie

Joined: Thu Aug 23, 2012 12:01 pm
Posts: 3
Hi,

I want set up the following structure: staging.mydomain.com/client/projectname production.mydomain.com/client/projectname

For new projects i create the following folders in my /home/-folder:

    "clientname"-folder
      "projectname"-folder
        staging-folder
        production-folder

My apache conf file looks like below right now.

It is working fine with clientA for "production" and "staging", but of course clientB wont work since those vhosts will be ignored.
So, how can I use that so it works with my structure: staging.mydomain.com/clientA/projectA points to /clientA/projectA/staging, and staging.mydomain.com/clientB/projectA points to /clientB/projectA/staging and so on....? :P

Code:
<VirtualHost *:80> 
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DirectoryIndex index.html index.php
    DocumentRoot /home/mysite
</VirtualHost>

<VirtualHost *:80>
    ServerName production.mydomain.com
    ServerAlias production.mydomain.com
    DirectoryIndex index.html index.php
    DocumentRoot /home/clientA/projectA/production
    Alias /clientA/projectA /home/clientA/projectA/production
</VirtualHost>

<VirtualHost *:80>
    ServerName staging.mydomain.com
    ServerAlias staging.mydomain.com
    DirectoryIndex index.html index.php
    DocumentRoot /home/clientA/projectA/staging
    Alias /clientA/projectA /home/clientA/projectA/staging
</VirtualHost>

<VirtualHost *:80>
    ServerName production.mydomain.com
    ServerAlias production.mydomain.com
    DirectoryIndex index.html index.php
    DocumentRoot /home/clientB/projectA/production
    Alias /clientB/projectA /home/clientB/projectA/production
</VirtualHost>

<VirtualHost *:80>
    ServerName staging.mydomain.com
    ServerAlias staging.mydomain.com
    DirectoryIndex index.html index.php
    DocumentRoot /home/clientB/projectA/staging
    Alias /clientB/projectA /home/clientB/projectA/staging
</VirtualHost>


Top
   
PostPosted: Thu Aug 23, 2012 1:17 pm 
Offline
Senior Member

Joined: Mon Dec 20, 2010 11:37 pm
Posts: 76
I think you are looking something like this:
http://httpd.apache.org/docs/2.2/vhosts/mass.html
http://httpd.apache.org/docs/2.2/mod/mo ... alias.html


Top
   
PostPosted: Fri Aug 24, 2012 7:13 am 
Offline
Newbie

Joined: Thu Aug 23, 2012 12:01 pm
Posts: 3
Hm, maybe, but as far as I've read it still doesn't seem to be how it solves my problem...

Tried with aliases, but that doesn't really work either...


Top
   
PostPosted: Fri Aug 24, 2012 8:03 am 
Offline
Senior Member
User avatar

Joined: Tue Jan 04, 2005 7:32 am
Posts: 277
Website: http://www.betadome.com/
Location: Ă…lesund, Norway
Skype: neonnero
Twitter: neonnero
The other "production.mydomain.com" virtual will be ignored because you already have a "production.mydomain.com" virtual host configured. And similar with "staging.mydomain.com".

You will need to consolidate all the Alias statements into each of the virtual hosts, like this (based on the example you posted originally):

Code:
<VirtualHost *:80> 
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DirectoryIndex index.html index.php
    DocumentRoot /home/mysite
</VirtualHost>

<VirtualHost *:80>
    ServerName production.mydomain.com
    DirectoryIndex index.html index.php
    DocumentRoot /home/mysite
    Alias /clientA/projectA /home/clientA/projectA/production
    Alias /clientB/projectA /home/clientB/projectA/production
</VirtualHost>

<VirtualHost *:80>
    ServerName staging.mydomain.com
    DirectoryIndex index.html index.php
    DocumentRoot /home/mysite
    Alias /clientA/projectA /home/clientA/projectA/staging
    Alias /clientB/projectA /home/clientB/projectA/staging
</VirtualHost>

(I've set the DocumentRoot in each of the additional sites to point to the same as your main site - usually, you don't want clientB to see the work you've done for clientA as the default website view, since this might distract your client's attention away from the project you're working on.)


Top
   
PostPosted: Fri Aug 24, 2012 8:41 am 
Offline
Newbie

Joined: Thu Aug 23, 2012 12:01 pm
Posts: 3
yes! that's working correct, but it leaves me with the following issues;

1. i have to manually insert a new alias for each client. Is it possible to do something like a AliasMatch with regexp or something?

2. the document root will be /home/mysite no matter what the matching url is, not a big issue, but is there a way to control so the document root will be /home/clientA/projectA/staging for example?

3. if the user visits staging.mydomain.com the will be able to list the directories, guess you can deny directory listing for that folder, but what about next level? If the user enter staging.mydomain.com/clientA, then I don't want it to be a valid route, more like a "File Not found" or something like that?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group