Installing a Debian / Ubuntu LAMP Server
One of the things you have to learn if you are going to be a true Drupal Ninja is to setup your own LAMP (Linux Apache MySQL PHP/Perl) stack for your web server. Even if you aren't running Drupal, knowing how to setup and manage your LAMP stack is essential to web development. Basically, each operating system has a little bit different setup to it's Apache MySQL and PHP server setup. This particular tutorial is to help setup a LAMP server stack on your Debian 5 (Lenny) or Ubuntu 9.10 (Karmic Koala) or less. It seems that the distribution packages available for Ubuntu 10.04 (Lucid Lynx) contain PHP 5.3, which many web software have not been upgraded to work with yet. Because of this, I do not recommend running Ubuntu 10.04 (Lucid Lynx) if you plan on running Drupal on your server. Drupal doesn't play nicely with PHP 5.3.
Here is a quick step by step process to get your LAMP stack setup on Debian 5 (Lenny) and Ubuntu 10.04 (Lucid Lynx) or earlier versions of Ubuntu.
By following this tutorial, you will install the following programs:
- Apache 2
- MySQL 5
- PHP4 or PHP5
- phpMyAdmin
Please note: This tutorial assumes that you have already setup SSH access to your server, have console access of some sort, or are physically sitting at the console of your server.
Ubuntu has a nice feature that allows you to install your LAMP stack in one easy command.
sudo tasksel install lamp-server
If you are using Debian you will have to manually configure your LAMP stack. Don't worry, it's not that difficult and if you are going to be using something like DRUSH, you will have to add PHP5-cli anyway, so this gives you a better understanding of what components make up your LAMP server.
Installing Apache Server, PHP, and MySQL on Debian 5 (Lenny)
First you will want to setup your Apache and PHP servers. Depending on what web software you are planning on running on your server, you will want to choose PHP 4 or PHP 5. This will also determine a different package to download when installing MySQL. Here are few quick commands that will get Apache 2 and PHP 4 or PHP 5 installed on your Debian 5 (Lenny).
Manual Install Apache 2 and PHP 4
apt-get install apache2 php4 libapache2-mod-php4
Manual Install Apache 2 and PHP 5
apt-get install apache2 php5 libapache2-mod-php5
In most cases, if you are running PHP you are going to be running a MySQL server to hold your data. After that you will want to get your MySQL server setup. During this process you should be prompted for your root password. Do not lose this! Depending on the version of PHP that you chose above, choose the correct version of the php-mysql package.
Manual Install MySQL for PHP 4
apt-get install mysql-server mysql-client php4-mysql
Manual Install MySQL for PHP 5
apt-get install mysql-server mysql-client php5-mysql
After setting up your MySQL server on Debian, you might want to adjust some settings in your server setup. The MySQL configuration file is located at:
/etc/mysql/my.cnf
May need to wipe the root password, some versions of Linux don’t install a root password
mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;
To make things easier administering your MySQL server install phpMyAdmin
apt-get install phpmyadmin
You may need to setup some things in the phpMyAdmin configuration file as well. It is located here:
/etc/phpmyadmin
Drupal Servers RSS Feed