Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SrWebDeveloper

macrumors 68000
Original poster
Dec 7, 2007
1,871
3
Alexandria, VA, USA
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
 

NoNameBrand

macrumors 6502
Nov 17, 2005
434
1
Halifax, Canada
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.
 

jpyc7

macrumors 6502
Mar 8, 2009
276
0
Denver, CO
Convince them to use Debian so you can use apt.
...


2. Setup
. . .

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.


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

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>".
 

SrWebDeveloper

macrumors 68000
Original poster
Dec 7, 2007
1,871
3
Alexandria, VA, USA
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
 

ChrisA

macrumors G5
Jan 5, 2006
12,558
1,669
Redondo Beach, California
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, .....


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
 

NoNameBrand

macrumors 6502
Nov 17, 2005
434
1
Halifax, Canada
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).

Yeah, it's almost like I suggested it ;)
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 ...




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.

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.