Setting up a web development enviornment on Linux Mint i.e. the LAMP Server


LAMP setup


LAMP is a popular open-source software stack used to build dynamic websites and web applications. 

What is the LAMP Server?

The acronym stands for Linux (the operating system), Apache (the web server), MySQL (or MariaDB, the relational database management system), and PHP (or sometimes Python/Perl, the programming language).

This combination or stack provides a platform for developing, testing and hosting web applications.

  • Linux is obviously the operating system on top of which the following will run. The OS will also provide basic setup for connecting to net, firewall for security, user access control etc.
  • Apache serves as the HTTP server, processing requests and delivering content to clients.
  • MySQL handles data storage and retrieval
  • PHP is used to create dynamic content on the server side. 

Setting up the LAMP Server

In this post we will see how to setup the LAMP server in a shortcut way.  We already assume that you are using Linux mint or Ubuntu or a Debian based distro.  The commands mentioned are suitable for the said systems.

The main requirements is the installation of packages Apache, MySQL and PHP. Optionally we can install phpMyAdmin - a web based interface to manage databases.

Update System Packages

  • Before starting, it's a good idea to update your system packages. Open a terminal and run:
    1. sudo apt update
    2. sudo apt upgrade

Setting  system of managing software sources and secure downloads

Second setup would be to install a set of packages that are commonly required for managing software sources, securely downloading packages, and ensuring system reliability, especially when dealing with third-party repositories.

  • sudo apt install software-properties-common apt-transport-https ca-certificates gnupgp2 wget
    1. The above basically installs:
      1. software-properties-common: provides essential tools for managing additional software repositories on a Linux system
      2. apt-transport-https: enables APT (the package manager) to handle package installations from repositories that are accessed over HTTPS
      3. ca-certificates: package contains a collection of trusted Certificate Authority (CA) certificates used by applications to verify the authenticity of secure connections.
      4. gnupg2: GPG is used to check the digital signatures of packages and repositories to ensure their integrity and authenticity.
      5. wget: A command line file downloading tool (probably is already installed)

 Install LAMP stack and phpMyAdmin together.

  • sudo apt-get install lamp-server^ phpmyadmin
    • The above command is used to install both the LAMP stack and phpMyAdmin together on a Debian-based system like Linux Mint.
    • The `lamp-server^` metapackage installs the entire LAMP stack (Linux, Apache, MySQL, PHP) with one command. The caret symbol (`^`) indicates a *task* package (a metapackage) that installs multiple related packages (Apache, MySQL, PHP, etc.).
    • The `phpmyadmin` package is a web-based application that allows you to manage MySQL databases through a GUI.
    • This will finally install
      • Apache
      • MySQL
      • PHP
      • And phpMyAdmin

Configuring the setup

  • During the installation of phpMyAdmin, you may be prompted to configure it.
    • You'll need to select Apache as the web server during the process.
    • You'll also be asked to configure a database for phpMyAdmin.
      • If you are prompted to set up a MySQL application password for phpMyAdmin
        • make sure to enter one (and not forget it) or leave it blank if you don’t need it).

Enable phpMyAdmin to be accessible via Apache

  •   After installation, ensure that phpMyAdmin is correctly linked to Apache. (This step may be optional)
    • Sometimes, it might be configured automatically.
      • You can manually do it by creating a symlink to phpMyAdmin in your web server's root directory:
    • sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
      • This ensures that you can access phpMyAdmin via the URL `http://localhost/phpmyadmin`.

Apply all changes Restart Apache

  • Finally, restart Apache to apply all changes:
    • sudo systemctl restart apache2

Verifying Installation:

  • Apache:
    • Open your browser and go to `http://localhost`. You should see the Apache2 Ubuntu Default Page.
  • PHP
    • To check if PHP is working, create a file called `test.php` in the `/var/www/html` directory with the following content:
      • <?php  phpinfo();   ?>
    • Open `http://localhost/test.php` in your browser. If you see the PHP configuration page, PHP is working.
  • MySQL
  • Access phpMyAdmin
    • Once the installation is complete, you can access phpMyAdmin through your web browser at:
    • http://localhost/phpmyadmin
    • Log in with the MySQL root username and password (or the user you configured).

Your LAMP stack along with phpMyAdmin should be fully installed and accessible.

Main category
Address

OpenSourceCook.in
"Natraj"  Bungalow,
Colony No.7,  Sr.No. 38.
(Lane Behind Sai Baba Mandir)
Kale Borate Nagar, Hadapsar,
Pune - 411028.
Get Directions