How to install LAMP (Apache, PHP and MySql in Linux)

Here's a basic guide on how to get Apache2, PHP5 and MySql working on most Debian based distros in a few easy steps.
1. Install Apache2 and PHP5 (as an Apache module)
apt-get install apache2 php5 libapache2-mod-php5 php5-mysql
Installing and configuring Trac and Subversion on squeeze
Trac is an enhanced wiki and issue tracking system for software development projects. Trac uses a minimalistic approach to web-based software project management.
Trac allows wiki markup in issue descriptions and commit messages, creating links and seamless references between bugs, tasks, changesets, files and wiki pages. A timeline shows all current and past project events in order, making the acquisition of an overview of the project and tracking progress very easy. The roadmap shows the road ahead, listing the upcoming milestones.
Install and configure Trac and subversion
1. Install required packages for both Trac and Subversion. We'll be using Apache to publish the Subversion repositories
apt-get install python-setuptools trac subversion libapache2-svn libapache2-mod-python
a2enmod dav_fs
Installing eAccelerator
eAccelerator is a free open-source PHP accelerator & optimizer. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times.
eAccelerator only works with mod_php or php in fastcgi mode. It can't be used in cgi or cli because eAccelerator needs to set up shared memory, and this can only be done when all php instances that need to access it are forks of the first process.
1. Download the eAccelerator source. The latest version is mirrored on www.debiantutorials.com as it's not available on the official site anymore.
cd /tmp
wget http://www.debiantutorials.com/static/eaccelerator-0.9.6.1.tar.bz2
Running Apache2 virtual hosts as different users with mpm-itk
apache2-mpm-itk is an MPM (Multi-Processing Module) for the Apache web server. mpm-itk allows you to run each of your vhost under a separate uid and gid — in short, the scripts and configuration files for one vhost no longer have to be readable for all the other vhosts.
1. Install the apache2-mpm-itk package
apt-get install apache2-mpm-itk
Upgrade from lenny to squeeze
Debian has released a stable version of Debian 6.0 (squeeze). If you're running previous version of Debian, you can easily upgrade.
1. Update all packages currently installed to the latest lenny versions
apt-get update
apt-get upgrade
How to upgrade to PHP 5.3 on Debian Lenny
Dotdeb provides a repository with PHP 5.3 for lenny and it's easy to upgrade:
1. Add these lines to the apt sources (pico /etc/apt/sources.list)
deb http://php53.dotdeb.org stable all
deb-src http://php53.dotdeb.org stable all
Installing and configuring Unison File Synchronizer
Unison is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.
1. Install the Unison package
apt-get install unison
Installing and configuring Varnish HTTP accelerator
Varnish is a state of the art web accelerator. Its mission is to sit in front of a web server an cache the content. It makes your web site go fast.
1. Install Varnish
apt-get install varnish
Install and configure MailWatch monitoring tool for MailScanner
MailWatch for MailScanner is a web-based front-end to MailScanner written in PHP, MySQL and JpGraph. It comes with a CustomConfig module for MailScanner which causes MailScanner to log all message data (excluding body text) to a MySQL database which is then queried by MailWatch for reporting and statistics.
1. Install Apache2, MySql server and PHP5 with required modules. You may already have some or all of these packages installed.
apt-get install apache2 php5-cli php5 mysql-server libdbd-mysql-perl php5-gd php5-mysql libapache2-mod-php5
Installing PEAR framework and packages
PEAR is a framework and distribution system for reusable PHP components.
1. Install the PEAR framework
get install php-pear