36 LAMP Stack

Mr. Hardik Joshi

epgp books

 

Overview and LAMP

 

A “LAMP” stack refers to a group of open source software, originally the LAMP stack was popularized from acronym that represents the Linux OS, Apache web server, data is stored in MySQL database and the dynamic content is processed by PHP. The LAMP stack is usually installed together to enable a server to host dynamic websites and web apps. LAMP stack uses the software that is free and open source software. Today, LAMP stack does not restrict itself to four different software listed above but is a generic term where the combination of different software provides a platform to run web applications.

 

LAMP stacks servers as a platform to host websites and web applications over it. Usually, dynamic websites require databases and scripting at server side. LAMP stack provides both the database and the scripting support. With the help of LAMP model, we can deploy applications like Content Management Systems, Learning Management Systems, Wikis, Helpdesk systems, Open Journal Systems etc. These applications are dynamic web applications that can be hosted on departmental server or online to cater the user needs.

 

Figure 2: LAMP Stack and Web Applications

(Source of Image: https://upload.wikimedia.org/wikipedia/commons/f/fa/LAMPP_Architecture.png)

 

Applications like Jhoomla, WordPress, Drupal, Moodle, OJS, etc. can be hosted on LAMP stack. The LAMP stack means that each component can be interchanged, the scope of LAMP stack has widened to avoid vendor lock-in. Earlier, the database MySQL was the default software but now, we can use PostgresSQL, Mariadb or Mongodb. Similarly the scripting language PHP can be replaced by Perl or Python.

 

Figure 3: LAMP Stack Services

 

Variants of LAMP Stack

 

Though LAMP stack is a popular word, there are many variants that serve to be a platform for web applications. Since, vendor lock-in is not appreciated in open source software, there are many bundles that server as platform for web applications. This software can be different from the ones listed above. LAMP stack is now also known as WAMP (Windows + AMP), SAMP (Solaris + AMP), MAMP (MacOS + AMP), etc. The AMP can be acronym of Apache/nginX + MySQL/Mariadb/Mongodb/PostgresSQL + PHP/Perl/Python. LAMP stacks are available as binaries or appliances that can be installed in a single click of mouse. Advantages of using LAMP stack in web development are listed below:

  • Applications built over LAMP stack can scale well.
  • Lamp Stack can be customized.
  • Lamp Stack is supported on many different operating systems and its versions.
  • It is rich in libraries, hence reduces coding efforts.
  • It is secure and gets regular updates.

Apache Web Server

 

Any web application needs a web server to execute. One of the widely used web server for Linux is Apache Web Server. Now-a-days, apache is available for different platforms like Windows, Mac OS, etc. Apache is a free and open source web server released under the license Apache 2.0 license. Apache is maintained and being developed by an open community. The developers develop Apache web server under the auspices known as Apache software foundation. Following are the few features of Apache software:

  • The Apache HTTP Server has been the most popular web server on the public Internet.
  • Nearly 54% Websites over Internet runs on Apache
  • Apache is a robust, free and open-source software.
  • Supports multi-users, multi-tasking etc.
  • A wide variety of features are supported, and many of them are implemented as compiled modules which exTend the core functionality of Apache.
  • A wide range of programming languages including PHP are supported by Apache web server.
  • Apache provides interfaces support Perl, Python, TCL, and PHP.
  • Apache provides additional functionalities with the help of modules.
  • Apache supports hosting of multiple websites on a single server using virtual directories.
  • Apache supports compression of web-pages while travelling over internet.

Modules in Apache

 

Apache web server can support additional functionalities with the help of modules. There are modules to implement confidentiality, authentication, authorization, load balancing etc. Let us briefly study the modules that are widely used. The mod_ssl module supports security using the secure sockets layer(SSL), apache also supports transport layer security(TLS). A secure website can use HTTPS protocol. Few other modules related to security and authentication are mod_access, mod_auth, mod_digest, mod_auth_digest.

 

The mod_gzip module helps in using the bandwidth optimally as it compresses the pages during transfers. There are modules to support proxy (mod_proxy), modules for filtering support like mod_ext_filter, modules to support URL rewriting like mod_rewrite.

 

Apache webserver supports concurrency control and load balancing. There are modules like mpm’s that provide multiprocessing capabilities. Multi-processing and multi-threading are supported by apache web server.

 

Apart from different modules, apache can easily integrate with external tools. For instance there is a web firewall ModSecurity which is open source. It helps in intrusion detection and prevention of web applications. Another interesting software is AWStats or W3Perl, which is used to generate statistics of website. These applications generate statistics from the apache logs.

 

Nginx web server

 

NginX is an alternate web server to the apache web server. It can be replaced by the apache web server in the LAMP stack. It is the second widely used web server after apache web server. . It is licensed under the 2-clause BSD license. This web server can efficiently handle concurrent requests (in the scale of thousands of request) and utilizes very small amount of RAM. So the performance for concurrent users is better than the Apache web server. Nginx also supports SSL and TLS.

 

MySQL Database

 

MySQL is an open source relational database management system. The open source is released under the GNU GPLv2 license. My SQL is the database in LAMP stack. My SQL is a product of Oracle Corporation as of now, originally it was developed by MySQL AB. There are two different editions of MySQL available. The editions of MySQL are:

  • Open source MySQL Community Server (released under GNU GPLv2)
  • Proprietary Enterprise Server Let us review few features of MySQL Community Server. Some of the features of MySQL are:
  • It is and open source RDBMS
  • It supports multi-threading, multi-user access
  • It supports ANSI SQL 99 query standards
  • Usage of stored procedures, cursors, triggers and updatable views is supported
  • Supports information schema and performance schema
  • Performance optimization can be achieved by query caching
  • Supports nested queries
  • Provides choice of various engines like InnoDB, MyISAM, Merge, Memory (heap), Federated Archive, CSV, Blackhole, NDB Cluster.
  • Support for SSL security
  • It has inbuilt replication support
  • Full-text indexing and searching is provided by MySQL
  • It has its embedded database library
  • Multi-lingual support through Unicode
  • Supports partitioned tables and pruning of partitions is possible
  • Transactions are well supported
  • It has a backup tool mysqldump which offers variety of backups
  • MySQL fabric provides high availability and very less downtime to the databases

Since MySQL is a popular database, it has various GUIs. Rather than dealing with MySQL through command line interface, various GUI are available to manage the database. Few of the interfaces use browser. Following is the list of few widely used GUIs for MySQL:

  • MySQL Workbench
  • Adminer
  • Database Workbench
  • DBEdit
  • HeidiSQL
  • LibreOffice Base
  • phpMyAdmin
  • Webmin

Although MySQL is a robust and widely used database, few other database software can also be used within LAMP stack. Apache web server and PHP can be easily integrated with other database software like PostgresSQL, Mariadb, Mongodb etc. We have a dedicated module that you will study in future that discusses the database software and its functionalities. With the increased use of NoSQL databases, the LAMP stack also supports NoSQL databases like Mongodb.

Figure 4: phpMyAdmin GUI

PHP

 

PHP is a server side scripting language that is used to create web user interface. PHP is released under the PHP license. Earlier, PHP was abbreviated as “Personal Home Page”, but now, it stands as “Hypertext Preprocessor”. PHP can integrate with the databases. Web applications like wordpress, moodle, jhoomla, ojs, etc. can be built using PHP and can be easily deployed. Customized web applications like websites, tracking systems, content management systems, reservation system, helpdesk systems, etc. can be easily created with the help of PHP.

 

Perl

 

Perl is a popular high-level language released under GNU GPL / Artistic License. It is a general purpose language that supports dynamic programming. It is an interpreted language and has a good support of regular expressions (regex). Perl was developed by Larry Wall and was known as “practical extraction and reporting language”.

 

Python

 

Python is a widely used general-purpose and scientific, high-level programming language and is released under the python software foundation license. Python is used by many reputed organizations like Google, Yahoo, NASA, Cern, etc. Python is being used to develop visual or graphical applications and is also used in scientific communities.

 

Installation of LAMP Stack

 

For windows OS, LAMP is easily available as downloadable tool in the binary form. We can download the LAMP software and install it with a single click. The following figure indicates post installation screen of WAMP in Windows.

Figure 5: WAMP in windows

 

Installation in Linux is bit tricky since we need to download each software sepearately and install them one after another. The installation may also require configuration of software to test whether it is being blocked by firewall or not. Let us see certain commands to download different software of LAMP stack for Linux. The following commands are to download LAMP for ubuntu:

A detailed installation instruction for Ubuntu is available on the website: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

Now let us see few commands that will be used to install LAMP in Centos 7. The following commands must be executed:

Detailed installation instructions for CentOS is given on the website: https://in.godaddy.com/help/build-a-lamp-stack-linux-apache-mysql-php-centos-7-17344.

Let us summarize the key concepts covered in this module

  • We understood what LAMP signifies
  • Overview of Apache Web Server
  • Overview of MySQL Databases
  • Overview of PHP/Perl/Python

Detailed installation instructions for CentOS is given on the website: https://in.godaddy.com/help/build-a-lamp-stack-linux-apache-mysql-php-centos-7-17344.

 

Let us summarize the key concepts covered in this module

  • We understood what LAMP signifies
  • Overview of Apache Web Server
  • Overview of MySQL Databases
  • Overview of PHP/Perl/Python
you can view video on LAMP Stack