LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-26-2009, 01:17 PM   #1
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676
Blog Entries: 7

Rep: Reputation: 32
Apache Dilemna


Dear All

Situation :
We have a live site at a clients datacenter, we need to setup a second site for development purposes on a temporary basis.
Site is accessed through load balancer, security restrictions on the LB prevent me from setting up another hostname and creating vhosts, and I did try to setup a second site in the site.com/~user fashion.

So in short I need to setup a second site. I did try to setup the site in the following fashion

site.com/site2/

However, with this approach the following problem arises.

The two sites are identical and the vhosts file for the original site contains the following entries amongst similar entries:

Alias /custom/images /site1/client/xyz/images
Alias /js_includes /site1/core/js_includes

When I do access site 2 which is basically a subfolder of site1, site2 does fetch the js scripts and other include code from the folders of site1, this makes site2 unusable for development.

I need a way so that I can exclude site2 from the Alias entries of site1 or a way to force site2 to use it's own code using some server side method.

I know this might sound ridiculous, but it is a vacation emergency and I need to find a workaround untill the vacations are over.

Regards
 
Old 12-26-2009, 02:36 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

One way that we've dealt with similar situations (have "clones" of development, QA and production environments; but alias the same hostnames to point to different server addresses) is with static hosts files.

Quote:
EXAMPLE:
# Explicitly alias this name to a different IP address (EX: to "192.168.1.10")
192.168.1.10 myserver myserver.mydomain.com

# "null-out" this name (you will *not* be able to connect outside of the localhost)
127.0.0.1 myotherserver myotherserver.mydomain.com

# Allow DNS to resolve (comment out this line from /etc/hosts => resolve to the "standard" IP address)
# 192.168.1.12 yetanotherserver yetanotherserver.mydomain.com
Then simply copy the appropriate version of the hosts files to each server.

'Hope that helps .. PSM

PS:
By default, Linux should use /etc/hosts before it uses DNS.

You can control this with "/etc/nsswitch.conf" (to specify order of static hosts, DNS and NIS), and /etc/resolv.conf (to specify order of DNS servers)

Last edited by paulsm4; 12-26-2009 at 03:02 PM.
 
Old 12-26-2009, 02:39 PM   #3
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
Hi
Thanks for the input, I did not quit get what you are pointing out. Can you clarify more ?
Regards
 
Old 12-26-2009, 03:11 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, again -

I don't know what your exact scenario is, so I can't give you a simple "1, 2, 3" cookbook solution. I *do* believe I understand your *general* problem, and I think using different "/etc/hosts" files *might* be a good solution.

EXAMPLE:
Let's say you have a set of three production servers: PRODA, PRODB and PRODC. Between them, you've got one (or more) HTTP web servers, one (or more) databases, maybe a Java application server or two, and a whole bunch of PHP (server side) and/or js (client side) code.

Now let's say you've "cloned" this environment, for use by your development team. You've now got three *different* servers (DEVA, DEVB and DEVC) with the *same* mix of HTTP web servers, databases, web services and code. All of the code is using *all the same host names* (because it's the same code, and none of your code is using IP addresses. Right?).

Q: What do you do? How can you run tests in either/both environments without conflicts?

A: Have one set of hosts files for the PROD servers, and a different set of hosts files for the DEV servers. Deploy the PROD hosts files to the prod servers, the DEV hosts files to the DEV servers ... and use one or the other hosts file on your clients.

If a client has the DEV hosts files, it will point to the DEV environment. If the client has the PROD hosts files, then that client will point to the PROD environment.

In other words, I'm suggesting DON'T modify your code for the different environments, DON'T play with different vhost configurations ... but simply COPY the environments ("clone" them) ... then just use a different "/etc/hosts" file to execute one environment vs. the other.

It's really simpler than it sounds

And, depending on your exact scenario ... who knows? It just might work!

'Hope that helps .. and Good luck!

Last edited by paulsm4; 12-26-2009 at 08:29 PM.
 
Old 12-26-2009, 09:07 PM   #5
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Maybe I am missing the point completely and am I saying something stupid, so in that case, my apologies.

I use the same situation, I have a production, testing and development version of my web site. As a matter of fact it is not a web site but a control system which is accessed thru a web interface. Doesn't make a difference, I have the files for the three versions in three subtrees:

/var/www/smc/production
/var/www/smc/development
/var/www/smc/testing

In my /etc/apache2/sites-available/default I have set up 3 different document roots:

- smc.mydomain.com: DocumentRoot /var/www/smc/production
- smcdev.mydomain.com: DocumentRoot /var/www/smc/development
- smctest.mydomain.com: DocumentRoot /var/www/smc/testing

The three trees are complete clones, and contain everything in the subtree. There is one exception for the database, which comes in three flavors as well. But from the beginning I have set up the program such that every connection to the database goes thru a single function call and this function determines the database name from the document root. I don't see another solution to that.

If I want to run testing one day instead of production, I simply change the documentroot.

jlinkels
 
Old 12-28-2009, 09:42 AM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, jlinkels -

You're correct.

Our scenario is a complex distributed application with multiple different services running on multiple different hosts. Hence the "/etc/hosts".

Your scenario is much simpler than ours:
a) your web clients talk 1::1, to one web server
b) your web server talks 1::1, to one database

Yes: simply changing httpd.conf:ocumentRoot (to point to production or Q/A web root) + changing a web .ini file (to point to production or Q/A databases) is ideal in your case. And might well be the best solution for ALInux.

The final answer, of course, is:

"It depends".

ALInux - please post back what finally happened!

Thank you in advance .. PSM
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Webserver on Slackware - Failed to Start Apache - 'no listening sockets .." CCTVGuru Linux - Server 4 10-11-2009 01:14 AM
Moral Dilemna Euneek General 15 06-06-2006 02:09 PM
The Triple Boot Dilemna, Installing Grub "Live" ajferrari Linux - Software 3 11-07-2005 07:27 AM
partition dilemna on mandrake/xp dual boot miner Linux - Newbie 2 05-16-2004 12:25 PM
apache benchmarks (apache v13 / apache v20) ; large differences between benchmarking markus1982 Linux - Software 0 02-08-2003 10:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration