skip navigation

Content:: LAMP Server Installation

Setup and configuration of a LAMP web server
Last Modified: 2013-01-15
Using the Debian netinst CD's we can setup a LAMP web server with ease. We will be setting up Apache, MySQL and PHP.

Table of Contents
Core installation
Make sure our package management queries are up to date and the OS is upgraded. # apt-get update
# apt-get upgrade
Set up remote access with SSH, afterwords you can run "ifconfig" to determin the IP address of the system. This will allow you remote access to make copy and paste a lot easier. # apt-get install ssh
A few useful tools that aren't neccessary for completing an installation. # apt-get install less
# apt-get install dnsutils
# apt-get install lynx
# apt-get install ncurses-hexedit
# apt-get install zip
# apt-get install bzip2
# apt-get install gcc
# apt-get install g++
The core of the LAMP installation is Apache, MySQL, and PHP.
# apt-get install apache2 php5 libapache2-mod-php5 php5-mysql
# apt-get install mysql-server mysql-client mysql-common
You will be prompted for a password
New password for the MySQL "root" user: 
Repeat password for the MySQL "root" user: 
Setting a static IP Address
Go into the directory where the network configurations are. # cd /etc/network
Make a backup copy of your interface file. # cp interfaces interfaces.orig
Use your favorite editor to edit the interfaces file # nano interfaces
We'll first comment out the default DHCP lines and add some more. You will want to verify your interface. In general eth0 will be your default
#allow-hotplug eth0
#iface eth0 inet dhcp
auto eth0
iface eth0 inet static
Restart your interface (you will need to re-establish your network connection if you are logged in via SSH. # ifdown eth0 && ifup eth0

Install CURL
CURL is a PHP module that will allow us to use CAS for authentication purposes. # apt-get install curl libcurl3 libcurl3-dev php5-curl
Installing and Configuring Mod Rewrite
By default the module should be loaded but not in use. We can verify the file location in "/usr/lib/apache2/modules/". We can run a simple "ls" command to see if it is there. # ls -l /usr/lib/apache2/modules/
The output should be similar to the following:
-rw-r--r-- 1 root root 59264 Sep 25 15:19 /usr/lib/apache2/modules/

We should also be able to see the module being loaded by apache. We can verify this by checking the rewrite.load file. It should be an apache statement pointed to the file we checked for above. # nano /etc/apache2/mods-enabled/rewrite.load
Inside the file we should see the following
LoadModule rewrite_module /usr/lib/apache2/modules/

If you DO NOT see the file or any content in it you can load the mod rewrite module by typing in # a2enmod rewrite This will basically create a shortcut to the rewrite.load file in /etc/apache2/mods-available/ folder.

Next we will configure the primary website to allow mod rewrite. We will be doing this in the virtual hosts file, on Debian/Ubuntu it will be in the "/etc/apache2/sites-available/default" file.

To be safe make a copy of the file, as we shouldn\'t have modified this file before we can rename the file to default.orig. If you have modified it before we should add a date stamp to the end of the file. # cp /etc/apache2/sites-available/default /etc/apache2/sites-available/default.orig

Open the default file for editing. # nano /etc/apache2/sites-available/default
Modify the AllowOverride from "none" to "all" for the base directory (/var/www/) * You will have to modify this for other directories and websites
The section should look like the following when completed.
<Directory /var/www/>
       Options Indexes FollowSymLinks MultiViews
       AllowOverride all
       Order allow,deny
       allow from all
Install PHP mcrypt extension
PHPMYAdmin will want the mcrypt extension for better security. # apt-get install php5-mcrypt
Install and configure PHP apc
This is a requirement for Drupal # apt-get install php-apc

Copy apc.ini file # cp apc.ini apc.ini.orig
Edit apc.ini # nano /etc/php5/conf.d/apc.ini
apc.rfc1867 = 1
Restart the Apache client
# /etc/init.d/apache2 restart