Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Developement and production mod_perl sites on a single server

by bits (Sexton)
on Nov 11, 2002 at 23:36 UTC ( [id://212150]=perlquestion: print w/replies, xml ) Need Help??

bits has asked for the wisdom of the Perl Monks concerning the following question:

How do you handle setting up concurrent development and production mod_perl sites?

In my case, my setup is driven by a bunch of custom modules and Template Toolkit. I've been using two vhosts, two mod_perl startup scripts each instantiating their own TT objects pointing at different template paths and seperate copies of each of my modules. What a nightmare.

TMTOWTDI - and this isn't the right way.

How do you approach this?

  • Comment on Developement and production mod_perl sites on a single server

Replies are listed 'Best First'.
Re: Developement and production mod_perl sites on a single server
by IlyaM (Parson) on Nov 11, 2002 at 23:43 UTC
    Run two mod_perl servers. One for production and another for development. There is no other way with Apache 1.3.xx and mod_perl 1.xx. Perl interpretator is shared among all vhosts so you cannot separate production versions of modules from development.

    I heard that Apache 2.xx and mod_perl 2.xx will allow to run different Perl interpretators for different vhosts but it is not production-ready yet.

    --
    Ilya Martynov, ilya@iponweb.net
    CTO IPonWEB (UK) Ltd
    Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
    Personal website - http://martynov.org

      Doesn't that leave you with whatever modules are in the lib path being used by both processes? How do you maintain a seperate set of modules across the two server instances?

      How do you migrate from one set to the other?

        Doesn't that leave you with whatever modules are in the lib path being used by both processes? How do you maintain a seperate set of modules across the two server instances?

        Each mod_perl server can use its own lib path. There are many ways to modify default @INC: for example you can set PERL5LIB environment variable in Apache startup script (see perlrun for description of PERL5LIB) or just use lib in server startup script.

        How do you migrate from one set to the other?

        Simpliest solution: cp -rv /home/testing /home/production what requires you to store all information that varies in production and development environments like filepaths and database name in separate config files.

        Actually it may be much more complex (say, you want to use CVS). This is the question of deployment strategy which was recently covered by this thread in mod_perl maillist.

        --
        Ilya Martynov, ilya@iponweb.net
        CTO IPonWEB (UK) Ltd
        Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
        Personal website - http://martynov.org

      Run two mod_perl servers.

      Depending on the project size, you should even consider running completely seperate servers for development, QA and production. Since we don't like to shell out the money for a dozen physically separate servers, we use multiple virtual servers on one box with VMware (UserModeLinux will be tested soon).

      This can also be applied to the "virtual mod_perl hosting" problem.

      Best regards,
        Jochen "geewiz" Lillich

      That last post was mine -- logging in helps ... :)
Re: Developement and production mod_perl sites on a single server
by dws (Chancellor) on Nov 11, 2002 at 23:41 UTC
    How do you handle setting up concurrent development and production mod_perl sites? ... I've been using two vhosts, two mod_perl startup scripts each instantiating their own TT objects pointing at different template paths and seperate copies of each of my modules. What a nightmare.

    Unless you keep your development in a separate sandbox (e.g., a separate instance of Apache listening on a different port), you're asking for mega-trouble. (You're already asking for trouble by using a single box.)

    It might simplify things keep one "working" CVS area, and one "production" tree that that can refresh when your production efforts are stable.

Re: Developement and production mod_perl sites on a single server
by cLive ;-) (Prior) on Nov 12, 2002 at 06:29 UTC

    Funny, I've just had to deal with the same thing :)

    Sounds like you're on your own here, so why not do what I'm doing?

    Mirror the install on your desktop, and move code over only when thoroughly tested. I use scp:

    scp -r /home/userdir user@host.com:/home/

    I'm using Mandrake as the Desktop, but installing and compiling Apache with SSL and mod_perl in the same way I am on the server (rather than using the Mandrake versions), and running the site under the same username with the same directory structure and httpd.conf (excluding the domain, of course, which is set to localhost!), startup.pl and Perl Modules.

    Fingers crossed, I haven't encountered any major differences yet. Of course, if you're writing Apache modules, there might be issues, but that's not something I know how to do at the moment, so I can't really comment.

    To be honest, I haven't even bothered to see what *nix the server is actually running - I was just dumped on the box and told to get it up and running, and that seemed like the easiest route.

    .02

    cLive ;-)

      If you're really twisted you could do what I do - I develop my website on the laptop on which I'm writing this using Windows 2000, I test it on the same laptop using Red Hat 7.2, and I deploy it (with Unison) on a server running RedHat 7.0. I spent some time ensuring that the directory structures all had the same names though...

      --
      Anthony Staines

      PS - I use Apache, mod-perl, the latest version of Mason (1.05 I think), and MySql. I keep a subset of the database on the laptop, and the main database lives on another server. The only difference is in a single configuration file.

Re: Developement and production mod_perl sites on a single server
by perrin (Chancellor) on Nov 12, 2002 at 00:00 UTC
    One strategy is decribed here.
It can be done! ->Re: Developement and production mod_perl sites on a single server
by drat (Hermit) on Nov 13, 2002 at 16:29 UTC
    We handle our development and production apache servers as follows (on Sparc Solaris 8, E250, 1 GB ram) using a single box. While we have enabled mod_perl on some of them for prototyping we haven't deployed any operational mod_perl code yet. YMMV though I have proven the concept.

    Our single server has multiple IP addresses configured, say 122.133.99.10, 122.133.99.11, 122.133.99.12, 122.133.99.13, 122.133.99.14, etc. These all happen to be on the same subnet.

    We install apache 1.3.xx and with --enable-shared=max then add several apache modules (including mod_perl) by building outside the source tree with APXS.

    Then we have apache installed at /opt/apache-1.3.xx/(...) but I don't run it from that location. I create directories (one per plane ... plane is our term for an instance of apache: the conceptual equivalent of a vhost but planes each have independent pools of children) named: /opt/planes/dev_server1 , /opt/planes/dev_server2, /opt/planes/production , /opt/planes/beta, etc, etc.

    Each directory in /opt/planes consists of
    |_ dev_server1 - (apachectl) |_ conf - (httpd.conf) |_ logs - (httpd.pid will be created here)
    Each plane's httpd.conf file uses the BindAddress directive to limit it to a single IP address. Each Plane has its own document root, script alias, and enabled set of modules. Each plane has its own user directive. Each plane is started/stopped independently via its own apachectl. Some of our planes load mod_perl, some don't.

    Advantages: Fully independent instances of apache each running unique sets of modules. Each can be started/sopped independently. This technique also avoids the suexec limitations of vhosting: Any developer in the dev group can place code in our integration plane using his or her own account(not production though)

    Disadvantages: Memory usage, although using separate hosts for apache servers uses even more :)
    ---------
    "That is the best engineering, not which makes the most splendid, or even the most perfect, work, but that which makes a work that answers the purpose well, at the least cost"
    --Ashbel Welch, President ASCE 1882
Re: Developement and production mod_perl sites on a single server
by Hrunting (Pilgrim) on Nov 13, 2002 at 14:27 UTC
    You need to run two separate servers. There's no other clean way around it. We keep all of our web code, including configuration, in CVS. The same Apache installation is hard-coded into configuration, but the rest is left relative to a server-root, which is dynamically replaced at startup time (as is the port; hard to run all servers on the same port). The startup script also takes care of setting PERL5LIB, the easiest way to reassign library paths to development libs (since it unshifts the paths onto @INC rather than pushing them). Since our CVS hierarchy mirrors our production hierarchy, our "production" environment is just another checkout of our CVS code. We actually use this to setup multiple development environments, so that each of our developers can run their own "personal" web servers.
Re: Developement and production mod_perl sites on a single server
by domm (Chaplain) on Nov 13, 2002 at 20:43 UTC
    Although not 100% on the topic of this thread, there was similar discussion on the modperl mailinglist a short time ago.

    See here (or choose another modperl mailinglist archive over there)
    (It gets more interesting later in the thread...)

    -- #!/usr/bin/perl for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://212150]
Approved by tye
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found