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
Tuning MySql with MySqlTuner to increase efficiency and performance
mysqltuner is a high-performance MySQL tuning script written in perl that will provide you with a snapshot of a MySQL server's health. Based on the statistics gathered, specific recommendations will be provided that will increase a MySQL server's efficiency and performance.
1. Install MySqlTuner
apt-get install mysqltuner
Installing EHCP (Easy Hosting Control Panel)
EHCP is a powerful, yet easy to install control panel that allows the user to manage services such as Web, FTP, Database and DNS servers.
The install script handles the installation and configuration of the required services. I recommend starting with a clean Debian system to avoid conflicts.
1. Download required EHCP files
wget http://www.ehcp.net/download
Installing Courier POP3 and IMAP daemon with MySql backend
The Courier mail transfer agent (MTA) is an integrated mail/groupware server based on open commodity protocols, such as ESMTP, IMAP, POP3, LDAP, SSL, and HTTP. Courier provides ESMTP, IMAP, POP3, webmail, and mailing list services within a single, consistent, framework. In this tutorial we'll only use the Courier POP3 and IMAP services.
It's assumed that you have already installed and configured Postfix according to this tutorial: Installing Postfix with MySql backend and SASL for SMTP authentication
1. Install required packages
apt-get install courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl
Installing Postfix with MySql backend and SASL for SMTP authentication
Postfix is a free and open source mail transfer agent (MTA). It is intended as a fast, easy-to-administer, and secure alternative to the widely-used Sendmail MTA.
Install and configure Postfix
1. Install Postfix and SASL
apt-get install postfix postfix-mysql libsasl2-modules-sql sasl2-bin libsasl2-2 postfix-tls libpam-mysql
> Internet Site
> host.domain.com
MySql database replication (master/slave)
In this tutorial we'll create a simple one-way master/slave database replication. You must have at least one master and one slave but you can use multiple slaves.
Master
1. Configure master to listen on all ip addresses (pico /etc/mysql/my.cnf)
#bind-address = 127.0.0.1
Moving databases from one MySql server to another
1. On the source database server run the following command to export all databases:
mysqldump -h localhost -u {username} -p --all-databases > database_dump.sql
Replace {username} with your MySql username.
Installing vsftpd with MySql backend
vsftpd is a secure, fast and stable FTP server. In this tutorial we'll install the server and make create a user database in MySql for virtual users.
1. Install required packages (make sure you have installed MySql)
apt-get install vsftpd libpam-mysql
Installing Courier POP3 and IMAP services with MySql backend
This tutorial assumes you already have Postfix installed with MySql backend as described in this tutorial: Installing Postfix with MySql backend and TLS
1. Install required packages
apt-get install courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl
Installing Postfix with MySql backend and TLS
In this tutorial we'll install a ready to use Postfix mail server with MySql backend for virtual users. Notice that this tutorial only covers installing the SMTP server (not POP3 and IMAP). Click here for a tutorial on installing Courier POP3 and IMAp services.
Once installed and configured, you can easily create your own admin system to modifiy the domains and users because the table structure is very simple.
This tutorial has been tested on Debian etch and lenny
1. Install the Postfix mail server, MySql server and other required packages
apt-get install postfix postfix-mysql sasl2-bin libsasl2-modules mysql-client mysql-server libpam-mysql