LAMP From Source (Debian)
After years of using older/outdated version of the LAMP setup (Apache, MySQL, PHP running on Linux), I decided that it was time to upgrade and get everything working with the new versions.
While I am a fan (sometimes) of package management, in the instances where you need more flexibility, compiling from source is the way to go. Unfortunately, after digging around on the web, it was hard to find a comprehensive up-to-date guide for doing so. In this guide, I am still using package management for installing things like libraries and compilers but for the main applications themselves, we'll compile them from the source code.
We'll still use some package management for some things like libraries but we'll get the main components compiled and working together from source.
This HOWTO was written using the following versions:
These instructions for compiling LAMP on a Debian (lenny) system.
Before We Start / Disclaimer
Everyone will have a different setup in mind, so you should be aware that unless you want to copy my installation preferences verbatim, you'll probably need to change a few things such as paths and whatnot. You may also need to tweak the configuration options if you need to add or remove components.
If there winds up being enough feedback for a certain option or method, I can always update this page with alternative instructions.
It is assumed that you have already downloaded the necessary files from their respective websites and placed them into some kind of temp directory. Additionally, you should either be root or using sudo where appropriate.
Lastly, because I feel I have to, I'm not making any guarantee that this guide will work for you, solve all of your problems, and not completely break your server. You should have a good idea about what you're doing before working through this guide.
Debian (lenny)
MySQL
The first thing to note is that newer versions of MySQL have done away with using GNU configure/make. Installation now requires cmake, among other dependencies. (Most/all should be available via package repositories.)
Prerequisites
Configure / Install
Post-Install
Note: The install seems to ignore the DATADIR directive, at least for this run-through. Instead of creating "var", it auto-creates a "data" directory instead. (Could just be the default.)
Starting / Configuring
Note: You will need to do some additional configuration (not listed here) to get it to auto-start on reboot.
Log in to mysql from command line:
./bin/mysql -p
drop database test;
use mysql;
delete from db;
delete from user where not (host="localhost" and user="root");
flush privileges;
MySQL should be all set now.
Apache (httpd)
Compared to dealing with the new version of MySQL, getting Apache compiled and installed is relatively painless.
Note: This does not cover setting up Apache to use SSL as I did not have a need for it during this run-through. I can always put up a separate HOWTO for that if needed later.
Configure / Install
Post-Install
Note: Near the bottom of the config file, there are options to include various "extra" config files. This is not needed for default operation but you'll likely want to uncomment "vhosts" among others to enable that functionality.
Starting / Configuring
PHP
Before starting with the compilation of PHP, I include a number of additional components/libraries for my desired install. These may or may not already be included on a standard system.
Prerequisites
Note: As with the MySQL install above, the below components were installed using Debian package management. You will need to adjust these according to your OS.
Configure / Install
Post-Install
While the PHP install will update httpd.conf to auto-load the new module, you generally have to add handlers for .php files manually.