Introduction A LAMP stack is a group of four open-source software components that form the foundation of building and running high-performance dynamic websites and web applications. It's an acronym for Linux, Apache, MySQL/MariaDB and PHP. The LAMP stack is simple, stable, and powerful, and its first layer is comprised of the popular Linux Operating System with flexible configuration options and tight security. Apache is the second layer in the pile and offers you compiled module support for major scripting languages such as PHP, Perl, Python, Node.js, etc. This HTTP web server delivers web content through the internet. When it comes to the database layer, you've two options when deploying a LAMP stack. You can either use MySQL or MariaDB as an Relational Database Management System (RDMS) for your web applications. The last package in the list is PHP. This is a scripting language that you can easily embed in HTML documents to create static or dynamic websites. The majority of modern Content Management Systems (CMS) such as WordPress, Joomla, Drupal, and Magento require a LAMP stack to work. Therefore, in this guide, you'll learn how to configure the right environment for them. The same setup will also work for any custom web application that you may intend to build with the LAMP stack technology. PrerequisitesTo follow along with this guide, you need the following:
1. Install Apache WebserverSSH to your Ubuntu server as a non-root user, then update the package information index and upgrade your packages.
Next, run the command below to install the Apache Web server.
Visit the URL below on a web browser and replace the
You should see the default Apache web page as shown below. After setting up the web server, you'll install a database in the next step. 2. Install a Database ServerYou can either install MySQL or MariaDB server when deploying a LAMP stack. To install the MySQL server, run the command below.
To set up a MariaDB server, execute the command below.
Irrespective of the database that you've chosen, run the command below to secure it.
Enter the below choices and press ENTER in each prompt to proceed. MySQL Server
MariaDB Server
Once you've secure the installation, login to the RDMS as root:
Enter your database server root password and press ENTER to proceed. Then, type the command below to create your first MySQL server.
MariaDB server.
Output.
Next, list the databases in the server by running the MySQL server.
MariaDB server.
Your
Create a MySQL server.
MariaDB server.
Your database server is now ready and you can move ahead to installing a scripting language. In this step, you'll install the PHP package. Run the command below.
Since most web applications rely on some PHP extensions, install the most common ones using the command below.
Restart the Apache webserver to load PHP.
To test PHP, create an
Then, enter the information below into the file.
Save
and close the file by pressing CTRL + X, then Y and ENTER. Then, in a web browser, visit the URL below and replace
You should get a detailed PHP page as shown below. Next, test PHP connectivity with the database that you created earlier. Open a new file for editing using nano.
Then, enter the information below into the file.
Save and close the file. Then, visit the address below in a web browser and replace
You should get the output below that shows that the script has successfully connected to the database.
ConclusionYour LAMP stack is now ready on Ubuntu 20.04, and you can now go ahead and build a dynamic website or cloud-based web application. From here, consider reading about One-Click LAMP stack installation guides and securing your web server with Let's Encrypt.
For more information about the LAMP stack, see the official documentations:
|