
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.
To follow along with this guide, you need the following:
SSH 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 192.0.2.1 with the public IP address of your server or domain name.
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.
You 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.
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 test_database database.
MySQL server.
MariaDB server.
Output.
Next, list the databases in the server by running the SHOW DATABASES command.
MySQL server.
MariaDB server.
Your test_database should be in the list below.
Create a test_user and assign full privileges to the database you've just created. You'll require the details of this user when testing database connectivity with PHP. Replace EXAMPLE_PASSWORD with a strong value.
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 info.php file in the root directory of your web server.
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 192.0.2.1 with your server's correct public IP address.
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 192.0.2.1 with your server's correct public IP address.
You should get the output below that shows that the script has successfully connected to the database.
Your 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:
0 Comments
Be the first to comment and share your perspective with the community.