Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Running multiple web development environments on one machine



>>>>> "Dave" writes:

    Dave> What I would like to do is simultaneously run different
    Dave> versions of MySQL/PHP on my home system so that I can
    Dave> simulate as closely as possible the web hosting conditions
    Dave> for each site I develop.

This is not something that you want a package manager anywhere near.
That's not what they're designed for.  If you're going to do this, the
first thing to do is uninstall all packages you're going to run
multiple versions of.

If you're not prepared to do that, take Godwin's advice.  However, I
really don't think "portable coding" is going to be easy, with two
major version bump for MySQL, and any version of PHP <shudder>.

    Dave> What particularly confuses me, and the issue I most need
    Dave> explained in simple terms, is to do with how the database
    Dave> gets called from within a PHP script. I simply run a command
    Dave> that says: mysql_pconnect('localhost', 'user', 'password')

It seems likely that the syntax

    mysql_pconnect('localhost:PORT_NO', 'user', 'password')

will work, where PORT_NO is a non-standard TCP port for mysql's
server.  See the PHP docs.  There may also be a way to config PHP to
look for mysql on some specific port.  If possible the latter is what
you want (it means that your program will run the same way on both
your home box and on the hosting service).  If not, you'd have to
translate those parts (learn to program sed!) from port-specific to
default-port versions.

The other possibility would be to only run one of the test
environments at a time.  Then the MySQL servers won't conflict with
each other.

    Dave> Ditto for PHP.

IIRC, PHP runs as a module inside of Apache, so you'll need to run
multiple instances of Apache.  As long as all internal references to
your website are relative to $DOCUMENT_ROOT, you will not need to
refer to the non-standard port from inside a web document.

    Dave> But, before I even get to that point, how can I install the
    Dave> different versions?

Manually.<wink>

    Dave> Then, after that how would I be able to specify for each web
    Dave> site I am developing which version to use? It would be nice
    Dave> to be able to bundle installations of PHP/MySQL and anything
    Dave> else under one directory, or in some conceptual way, so that
    Dave> in my home environment I could make my web sites adhere to
    Dave> the system that matches their web hosting service.

It would be nice, but it's not going to work that way, unless you're
willing to have a separate Apache installation for each one.

What I would do in your situation is to configure my webgalaxy like
this:

Sources:

/usr/local/src/apache/$VERSION
/usr/local/src/mysql/$VERSION
/usr/local/src/php/$VERSION

If you have multiple versions of a program, you'd have separate
sources.  Configure the program to install into /var/galaxy (see
below).  *You also must configure the program to install its
configuration files there, not in /etc.*  Then build and install it.

Installation for customer 1:

/var/galaxy/customer1/apache/$VERSION    # probably the PHP mod is here
/var/galaxy/customer1/mysql/$VERSION
/var/galaxy/customer1/htdocs/            # the actual website data

Each app (mysql and apache) would run on a non-standard port,
different for each customer.

Apache being an industrial-quality program, I'd be willing to bet you
could have only one instance installed, keep the customer-specific
configuration files only in /var/galaxy, and use a command line option
to pick the appropriate config for each instance.  MySQL might also
work that way, but since you're likely to have a bunch of versions
anyway, why bother?

-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links