LAMP setup, but MySQL is on different server

Discussion in 'Web Design and Development' started by SrWebDeveloper, May 22, 2009.

  1. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #1
    One of my clients is thinking of installing LAMP on their Red Hat 8 servers, they have two. One for web (PHP5/Apache2) and one for database (MySQL Community)

    Let's assume LAMP is not pre-setup on each server, and all installation must be done via ssh and CLI, no local console will be available. Must be RPM's.

    Please detail:

    1) which RPM's I'd need for each server
    2) basic installation and setup instructions for each server
    3) what's the method to upgrade each package via CLI in the future?

    Note: Remember the web and database are split. We only want to install what's necessary on each server with easy upgrade ability.

    Thanks

    -jim
     
  2. NoNameBrand macrumors 6502

    Joined:
    Nov 17, 2005
    Location:
    Halifax, Canada
    #2
    Convince them to use Debian so you can use apt.
    ...

    More seriously:

    1. Packages
    On the DB server, you need mysql-server. That's it. You probably want the client there as well, for setup and trouble shooting. I'd seriously consider putting on Apache and PHP to run PHP MyAdmin as well, though you don't have to do anything but mysql-server.

    On the webserver, you want Apache, PHP, PHP-MySQL, MySQL client. Depending on the nature of the use of this webserver (internet vs intranet, timeliness of data, etc), you may want to seriously consider squid to cache your generated HTML/images.

    I don't know the package/RPM names because my servers are all running Debian and Ubuntu rather than Red Hat or other RPM-based distro (entirely due to package management differences).

    2. Setup
    Open an SSH session or two to each server. On the DB server, use yum to install the mysql-server. On the webserver, use yum to install the other stuff. In the spare SSH sessions, start looking (Looking!) at how the network is configured. Make sure they don't use DHCP, or if they do, that there's a DNS server kept up-to-date with the host names. Better to use static addresses and hardcode the other machine's name in /etc/hosts (just remember you've done so!). If you need to make changes, wait till yum is finished.

    I hope the network is setup properly, remotely configuring a network can be hairy if you don't do it right. SSH will auto-restore if you use 'ifdown -a; ifup -a;' to reload the ethernet. Anyway, you should probably sort this out now.

    Just proceed as normal for the LAMP stack on the webserver, except in your PHP app, the DB connect calls need a host parameter, rather than the default of localhost. That's it.

    On the DB server, you may need to configure MySQL to accept connections from remote hosts - once that's done, connect to the DB. If you installed the client on this machine, connect as normal; if on the webserver, just add a '-h dbserver.local' to the command to talk to the db-server.

    Create a user for your PHP app as normal, but put the webserver's address in the command:
    GRANT INSERT,SELECT,DELETE,UPDATE,... to 'foo'@'webserver.local' IDENTIFIED BY ...

    Test.

    3. Upgrades
    I don't remember how to upgrade Red Hat from the command line, sorry. Presumably there's a yum command though.
     
  3. jpyc7 macrumors 6502

    Joined:
    Mar 8, 2009
    Location:
    Denver, CO
    #3
    Depending on how paranoid you are, you might want to restrict your mysql remote access to specific hosts even though you'll have password protection. Probably you want to limit to just the web server and your development system(s).

    As for upgrades, it is just "yum upgrade <pkg-name>".
     
  4. SrWebDeveloper thread starter macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #4
    Sorry, they're running RH and committed to it. Turns out it'll be v5, not 8 - they're upgrading from 3 and 4 on various machines and are restricted by licensing.

    Anyway, I researched YUM and that's the way to go, thanks for the advice on that, all. I'll get the RPM's from the RHN and do installs/upgrades for the various LAMP daemons via YUM as this nice tutorial demonstrates.

    Folks, I don't need help on configuring or security issues as it turns out - I just learned we've got it covered. But thank you kindly for your efforts! :)

    -jim
     
  5. ChrisA macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #5

    All the above is 100% correct. But I'd suggest doing one thing more. Seeing as you have two servers take advantage of the redundancy. Someday one server might fail. Or actually one will fail. So install everything on both, so each server can act as a backup to the other. When one server fails you can restart quickly in single server mode.

    So the way I do this is to first set up a signal server with the DBMS and web server both on the same server. Then repeat that setup on the second server. Then modify the setup so the DBMS hostname is contained in an environment variable and is never defaulted. Now you are set for a fast change over should on server need to be taken off line.

    Last time I set up a multi-teired web server we had a requirement to I should be able to go into the server room and pull the A/C power cord out of any box in the room without disrupting service. This included pulling to power from a routers or Ethernet switch. It can be done but if you need to depends on how much money the website is pulling in per hour and if your customers can afford to wait while, say a smoked power supply is replaced.

    But you can get to nearly as good simply by pre-configuring so a manual fail over is quick and easy
     
  6. SrWebDeveloper thread starter macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #6
    We have a a COOP solution, this is part of a governmental agency setup, complete with real time data replication and an off-site failover situation.
     
  7. NoNameBrand macrumors 6502

    Joined:
    Nov 17, 2005
    Location:
    Halifax, Canada
    #7
    Yeah, it's almost like I suggested it ;)



    That wasn't asked ;)

    I use DBRD and Heartbeat to replicate the DB and handle failover. Howto for Debian, howto for VMWare on Redhat.

    I could've used MySQL master-master replication, but this seemed less complicated, which tells you where my background is.
     

Share This Page