When dis­cern­ing types of websites, there two different general cat­e­gories that your website might fall under – static or dynamic. Static web pages display HTML documents on their cor­re­spond­ing servers, and their content can be only be adjusted when a developer changes its source code. The content of dynamic web pages, on the other hand, is actively generated upon receiving a request from the user. This method offers a key advantage for websites that require regular updates for ever-changing data, like weather reports or stock market prices. Dynamic web pages require special in­fra­struc­ture that is composed of operating systems, web servers, database systems, and script in­ter­preters; this in­fra­struc­ture comprises the basic structure of LAMP stacks.

What is a LAMP server?

LAMP owes its name to an acronym derived from the four software com­po­nents that make up its in­fra­struc­ture: Linux, Apache, MySQL, and PHP. These combined elements provide a server in­fra­struc­ture that is able to both host and generate dynamic websites. The in­di­vid­ual com­po­nents com­ple­ment and build upon one another, hence the software bundle’s name, LAMP stack.

The webserver, Apache, runs on Linux. Although this server is not able to interpret dynamic content, it is pro­grammed to take into account that the script in­ter­preter PHP is able to carry out this task. For this reason, the server sends the re­spec­tive source code, including in­for­ma­tion on the website’s visitor behavior, to the PHP in­ter­preter. This in­ter­preter in turn accesses the database, MySQL. The finished result of this process is then sent back to Apache where it is shown to the visitor in its re­spec­tive web browser.

Due to their rea­son­able prices and easy avail­abil­i­ty, LAMP servers have proven to be a popular option for web de­vel­op­ers. In­di­vid­ual server com­po­nents can be replaced with com­pa­ra­ble al­ter­na­tives. Operating systems like Windows (WAMP) or Mac OS (MAMP) can also be used. The web server nginx is often used in lieu of Apache. For database purposes, MySQL and MariaDB are used at similar rates. Ad­di­tion­al pro­gram­ming languages, are: Perl, Ruby, and Python.

How to install a LAMP server

A few things should be cleared before in­stalling a LAMP server. It is important to first make sure that the hardware supplies enough capacity for in­stal­la­tion and various functions of the LAMP stack. In principle, LAMP systems do not require top-of-the-line computing per­for­mance. Depending on the type of content that is to be delivered to web page visitors, however, a high-per­form­ing system may be needed. Services offering online streaming media, for example, may not be able to forego such high-end equipment. The number of users should also be taken into account before the hardware is purchased.

Once the hardware has been accounted for, the next task is to determine which of the many Linux dis­trib­u­tors is right for the job. Whether it be Red Hat, openSUSE, Debian, Ubuntu, or CentOS, choosing the right dis­trib­u­tor depends on both the intended purpose of the LAMP server as well as your Linux com­pe­ten­cy level.

The following guide lays out the steps for in­stalling the four com­po­nents of an Ubuntu LAMP server. 

Step 1: Choose the right operating system

As is the case for Ubuntu, many other open source Linux dis­trib­u­tors (often shortened simply to “distros”) are available free of charge online. The following steps are a guide to the Debian-based operating system:

  1. Download or purchase the Ubuntu server edition on their homepage: Ubuntu; after the download is complete, save or burn the ISO file on a USB stick or CD
  2. Using the USB stick or CD, start the operating system.
  3. Select language and begin server in­stal­la­tion.
  4. Select or enter details on language options, keyboard layout, network con­fig­u­ra­tion, hostname, time zone and passwords.
  5. Configure the hard drive.
  6. At this point, the installer will scan the CD for software packages as well as in­for­ma­tion regarding update options. Make sure to select that no automatic updates should be carried out.
  7. Finally, after the in­stal­la­tion, restart the system and enter the following script into the command line.
sudo apt-get update

Ubuntu has now been fully installed. The next steps for in­stalling further Ubuntu LAMP server com­po­nents may now proceed. 

Step 2: Install the web server

In the case that the Apache web server was not suc­cess­ful­ly installed during the Ubuntu in­stal­la­tion, Execute the following command:

sudo apt-get install apache2

Following this step, ensure that Apache 2 (“2” refers to the most current version) is now installed by accessing the page localhost or the host IP. The following ad­just­ments should then be made:

  1. Although KeepAlive improves the website speed for the user, it also demands a con­sid­er­able amount of working memory. Adjusting KeepAlive in the main con­fig­u­ra­tion file /etc/apache2/apache2.conf to „KeepAlive Off“ is es­pe­cial­ly worth­while for those working on less robust systems.  
  2. The con­ven­tion­al Mul­ti­Pro­cess­ing module (MPM) for Apache is the event module, while PHP uses the Prefork module. Running /etc/apache2/mods-available produces the file mpm_prefork.conf. This file should be adjusted as shown:
<IfModule mpm_prefork_module>
StartServers              2
MinSpareServers           6
MaxSpareServers           12
MaxRequestWorkers         39
MaxConnectionsPerChild    3000
</IfModule>
  1. Next, the event module should be turned off and the Prefork module should be turned on.
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
  1. Finally, the server should be restarted:
sudo service apache2 restart

Step 3: Install the database

The database man­age­ment system MySQL operates as a server that allows multiple databases to be created on it; many data tables can be set up for each database. One or multiple clients send queries to the MySQL server, which is installed with the following command:

sudo apt-get install mysql-server

During in­stal­la­tion, it’s possible to determine the password for the MySQL root user; this step should in­vari­ably be carried out. The next step deals with MySQL security. MySQL Secure offers the options of changing passwords, removing anonymous user accounts or test databases, or pre­vent­ing all root logins from the local host. Here is the in­stal­la­tion command:

sudo mysql_secure_installation

To create a database, log into the following MySQL: 

mysql -u root -p

Following this step, the database, including users with access rights, are created:

create database webdata;
grant all on webdata.* to “some user” identified by “password”;

Step 4: Install the Script software

During the last step, the script language PHP and the library PEAR (PHP Extension and Appli­ca­tion Repository) are added to the LAMP stack. PEAR contains valuable modules and ex­ten­sions for PHP. These are installed with the following command:

sudo apt-get install php5 php-pear

In­stalling the MySQL support for PHP5 should also be done at this point:

sudo apt-get install php5-mysql

As soon as the in­stal­la­tion process is over, the PHP con­fig­u­ra­tion file should be modified; it can be found by accessing the following: /etc/php5/apache2/php.ini

error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
error_log = /var/log/php/error.log
max_input_time = 30

Through this process, the user receives more in­for­ma­tive error reports and better per­for­mance. Saving errors in the error.log is ad­di­tion­al­ly made possible. Next, a log directory has to be made for PHP and the Apache server needs to be given ownership rights.

sudo mkdir /var/log/php
sudo chown www-data /var/log/php

After an Apache reload, the in­stal­la­tion of the entire LAMP server should then be complete:

sudo service apache2 reload

LAMP-Stacks: open source software for every web project

The advantage of open source software isn’t just that it’s available for free. A further plus of open source software is, as its name suggest, that every user has access to its de­vel­op­ment code. This allows users to in­de­pen­dent­ly edit and continue de­vel­op­ing the software. For ex­pe­ri­enced users, open software elim­i­nates the need of worrying about support for a par­tic­u­lar software being dis­con­tin­ued.

In­stalling a LAMP server offers more than just high flex­i­bil­i­ty and low prices: it in­cor­po­rates robust com­po­nents that mesh well with one another. LAMP servers enable users to operate both static and dynamic websites. Wikipedia runs on the software MediaWiki, which is just one of many examples of a website that was developed on a LAMP system.

Go to Main Menu