
Have you found this site helpful?
Donations are graciously accepted and help keep this site running.
Setup Your Own LAMP Server
This tutorial shows you how to setup a web server utilizing the LAMP platform. LAMP is an acronym for Linux Apache MySQL and PHP. Linux plays the role of the operating system, Apache is the web server software that handles HTTP requests, PHP is the software that executes the PHP code, returning it to the web server, and MySQL serves as a storage database, accessed by PHP. This platform is one of the most popular in the world for serving web sites. Since all the software is open source, it is also free!
First, you need a computer running Linux or UNIX. Next, you will need to obtain Apache, PHP, and MySQL from the internet
- MySQL - The latest version of MySQL at the time of this writing is 5.0.51. MySQL can be downloaded from http://www.mysql.com/. Many binary distributions are available, but this tutorial will show how to install from source.
- Apache – The latest version of the Apache web server is 2.2.8. This software can be downloaded from http://httpd.apache.org/. Only the source distribution is available directly from apache, but you may be able to find a binary specific to your Linux/Unix distribution elsewhere on the web. This tutorial will show how to install from source.
- PHP – The latest version of PHP is version 5.2.6. This can be downloaded from http://www.php.net/. Installation from source will be demonstrated in this tutorial.
Next, you should make sure you have recent versions libxml2 and zlib. These libraries add common functionality for various PHP extensions. When you are sure you have them, we can move on to the next step.
Installing MySQL
These steps will install MySQL using the console.
- Ensure you are either the root user, or have root access.# su root
- Lets assume that you downloaded the files to your desktop. Extract the files to /usr/local, making sure to use the correct download directory.# cd /usr/local
# tar -xzvf /home/user/Desktop/mysql-5.0.51b.tar.gz - Create a user and group called mysql. The MySQL server should never be run as root.# groupadd mysql
# useradd -g mysql mysql - Create a symbolic link to the MySQL files called mysql. This will make things easier.# ln -s mysql-5.0.51b mysql
- Change to the new directory.# cd mysql
- Ensure the user mysql has read/write privileges.# chown -R mysql .
# chgrp -R mysql . - Initialize the MySQL grant tables.# scripts/mysql_install_db --user=mysql
- Change the priveleges so that root owns the directory, but mysql still owns the data folder.# chown -R root .
# chown -R mysql data - Once everything is all set, you can now start the MySQL server.# bin/mysqld_safe --user=mysql &
Installing Apache
We will now install Apache and then install PHP as a dynamically loaded module. This will make it easier to upgrade PHP at a later date.
- Ensure you are either the root user, or have root access.# su root
- Change to the directory where the downloaded apache file is and extract it.# cd /home/user/Desktop
# tar -xzvf httpd-2.2.8.tar.gz - Change to the newly extracted directory and configure Apache with Dynamic Shared Object support.# cd httpd-2.2.8
# ./configure --prefix=/usr/local/apache --enable-module=so - Compile Apache with make.# make
# make install
Installing PHP
- Change to the download directory and extract PHP.# cd /home/user/Desktop
# tar -xzvf php-5.2.6.tar.gz - Change to the new directory and configure PHP. This has a lot of install parameters.# cd php-5.2.6
# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/lib --with-zlib --with-zlib-dir=/usr/local/lib - Compile PHP with make.# make
# make install - Now that everything is installed, we need to configure some basic options in Apache. Use a text editor to add the following line somewhere in the httpd.conf file. This should be located in /usr/local/apache/conf/.AddType application/x-httpd-php .phpSave the changes to the file.
- In the same file, make sure the following line appears somewhere. This is usually added during the PHP installation process, but it doesn't always work.LoadModule php5_module modules/libphp5.so
- Manually start the Apache server by running the apachectl script.# /usr/local/apache/bin/apachectl start
You should now have a working LAMP server! You can test to make sure it is working by opening a web browser and typing localhost as a url. You can edit the httpd.conf file to specify more advanced options for Apache.



