How did you like the article?
0
How did you like the article?
0

LAMP Servers: an affordable solution for dynamic websites

When discerning types of websites, there two different general categories that your website might fall under – static or dynamic. Static web pages display HTML documents on their corresponding 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 infrastructure that is composed of operating systems, web servers, database systems, and script interpreters; this infrastructure comprises the basic structure of LAMP stacks.

What is a LAMP server?

LAMP owes its name to an acronym derived from the four software components that make up its infrastructure: Linux, Apache, MySQL, and PHP. These combined elements provide a server infrastructure that is able to both host and generate dynamic websites. The individual components complement 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 programmed to take into account that the script interpreter PHP is able to carry out this task. For this reason, the server sends the respective source code, including information on the website’s visitor behavior, to the PHP interpreter. This interpreter 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 respective web browser.

Due to their reasonable prices and easy availability, LAMP servers have proven to be a popular option for web developers. Individual server components can be replaced with comparable alternatives. 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. Additional programming languages, are: Perl, Ruby, and Python.

How to install a LAMP server

A few things should be cleared before installing a LAMP server. It is important to first make sure that the hardware supplies enough capacity for installation and various functions of the LAMP stack. In principle, LAMP systems do not require top-of-the-line computing performance. Depending on the type of content that is to be delivered to web page visitors, however, a high-performing 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 distributors is right for the job. Whether it be Red Hat, openSUSE, Debian, Ubuntu, or CentOS, choosing the right distributor depends on both the intended purpose of the LAMP server as well as your Linux competency level.

The following guide lays out the steps for installing the four components of an Ubuntu LAMP server. 

Step 1: the operating system

As is the case for Ubuntu, many other open source Linux distributors (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 installation.
  4. Select or enter details on language options, keyboard layout, network configuration, 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 information regarding update options. Make sure to select that no automatic updates should be carried out.
  7. Finally, after the installation, 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 installing further Ubuntu LAMP server components may now proceed. 

Step 2: the web server

In the case that the Apache web server was not successfully installed during the Ubuntu installation, 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 adjustments should then be made:

  1. Although KeepAlive improves the website speed for the user, it also demands a considerable amount of working memory. Adjusting KeepAlive in the main configuration file /etc/apache2/apache2.conf to „KeepAlive Off“ is especially worthwhile for those working on less robust systems.  
  2. The conventional MultiProcessing 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: the database

The database management 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 installation, it’s possible to determine the password for the MySQL root user; this step should invariably 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 preventing all root logins from the local host. Here is the installation 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: the Script software

During the last step, the script language PHP and the library PEAR (PHP Extension and Application Repository) are added to the LAMP stack. PEAR contains valuable modules and extensions for PHP. These are installed with the following command:

sudo apt-get install php5 php-pear

Installing the MySQL support for PHP5 should also be done at this point:

sudo apt-get install php5-mysql

As soon as the installation process is over, the PHP configuration 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 informative error reports and better performance. Saving errors in the error.log is additionally 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 installation 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 development code. This allows users to independently edit and continue developing the software. For experienced users, open software eliminates the need of worrying about support for a particular software being discontinued.

Installing a LAMP server offers more than just high flexibility and low prices: it incorporates robust components 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.

MySQL Linux PHP