The LAMP stack is one of the most popular server configurations in the world. These are individual software packages that are powerful alone, but form a super team when combined. IT nerds like me might call it the Justice League of open source software. From multi-layered content management systems to social networking portals supporting millions of users, the LAMP provides a stable foundation for some of the largest web applications. Read on to see how you can install LAMP server on Linux Mint 18 with one easy command line and then test its components.
The LAMP stack can be easily installed on any capable computer, essentially giving you your very own server. What are the benefits of running your own server? Here are a few:
Full System Control: When it comes to system customization, a server puts the ultimate power in your hands. Whether it’s business email with your own mail server or transferring files across the network with your own FTP server, the possibilities are endless.
Data privacy: A server can eliminate the need to store information in the cloud. With sound security practices on your side, it can provide an ideal safe haven for the data only you have access to.
Cost Effectiveness: Connectivity and add-ons aside, the cost of actually getting a server up and running is minimal. In the case of the LAMP, all the software needed to get started is available free of charge.
Peace of Mind: An in-house server helps you break free of third-party solutions and their contentious service level agreements. With the freedom to literally build the system from the ground up, your server can be as secure and reliable as you make it.
Inside the LAMP Server
Before diving in to installation, let’s take a closer look at each individual LAMP component.
Linux is at the helm of the LAMP as the operating system. While developers and IT managers have their favorites, most Linux distributions are capable of supporting the additional layers of the stack. The best OS for the job is always the distro that provides the functionality, performance, and admin-level comfort your project requires.
If Linux is the brains of the operation, then Apache is the heart. A web server delivers web pages to the user by processing HTTP requests, and Apache is the most widely used of its kind. There are alternatives such as Nginx, but Apache is never a bad choice. It has proven stability and long-running community support.
MySQL is a database server that not only allows you to create and manage databases, but provides back-end support for popular web applications such as WordPress, Joomla, and Drupal. The MySQL system is admired for its speed and reliability as well as flexibility that accommodates simple and complex applications alike. While MySQL offers a number of advantages, not all applications support all databases, so it’s important to keep compatibility in mind when planning your stack.
(P) PHP, Perl, Python
The last layer of the stack is where things start to get tricky. As the most popular programming language in the world, PHP usually holds down this spot. However, Perl and Python have shown that they are more than capable of standing in its place, all without blemishing the familiar acronym.
LAMP Server Installation
Now that we’ve got the background bases covered, it’s time to get the LAMP server up and running on our own system. For this installation, we’ll be working with Linux Mint 18 Cinnamon. Most guides take the approach of installing one component at a time, but I’ve stumbled upon a much easier way. That’s right. We’re gonna use one magical command to install the LAMP server stack in full. Sounds too good to be true, but I’ve tested it and it works.
Step 1: Update Linux
For the best results, it’s a good idea to update your OS first. There are a few ways to do this, but we’re gonna fire up the Terminal and enter the following command:
sudo apt-get update && sudo apt-get dist-upgrade -y
Next you’ll be prompted for a password. Take note that you won’t see anything when entering your password in the command line. Don’t freak out (like I did). This is for security purposes. Just go ahead, type it and press Enter.
We want to make sure the changes from the update take effect so we’ll restart our system with the following command:
Step 2: Install the LAMP Server
Once our system reboots, we’ll head back to the Terminal and start the installation process by entering the following command:
sudo apt-get install lamp-server^ -y
Step. 3: Setup MySQL
Immediately after the installation you’ll be need to configure MySQL. All you have to do here is enter a password for the root account. This step is optional, but I recommend it since you’ll need that password to add new users and handle other database management tasks. Enter your desired password, enter it a second time to confirm, and you’re done.
That’s it! This one command will successfully install the LAMP server stack in its entirety. For the remainder of this guide we’ll work on some configurations and testing to make sure everything is up to speed.
Step 4: Test Apache
The easiest way to make sure the installation went according to plan is to test our Apache web server. We can do this by simply opening a web browser and enter the following URL:
If all goes well you’ll see the default page for Apache in your browser.
Step 5: Test PHP
The “P” in the LAMP server stands for PHP, so we’ll run a quick test to make sure this language package is properly installed. We’ll do this by creating a simple PHP script we’re gonna call “info.php”. To do this, navigate back to the Terminal and enter the following command:
sudo nano /var/www/testing.php
Next, copy and paste the following code in the Terminal:
<?php phpinfo(); ?>
Hold down “CTRL” and “O” to write-out and save the file, then press “CTRL” and “X” to escape.
To make sure the changes take effect, let’s restart Apache by entering the following command:
sudo service apache2 restart
And to make sure all is right with PHP, we’ll navigate to our browser and enter the following URL:
What you see are essentially the PHP-based specs of your LAMP server.
Note: Different versions of Linux store files in different folders by default. If the PHP test throws a browser error, you probably need to investigate and find out exactly where the test file is stored.
MySQL is great, but without a basic knowledge of SQL commands, database management is going to be a chore to say the least. Luckily a more user-friendly alternative exists in PHPMyAdmin. Though it’s not a part of the stack, PHPMyAdmin simplifies MySQL database management and thanks to an intuitive GUI, is one of the best tools for the job.
We can install PHPMyAdmin by entering the following command:
sudo apt-get install phpmyadmin -y
On the next screen you will choose the web server you want to automatically configure to run PHPMyAdmin. Select “Apache 2” and hit Enter.
Next, you’ll set up a default database for PHPMyAdmin. Choose ‘Yes’ and press ‘Enter’ to proceed to the next step.
From there you will enter a password for the administrative account associated with your default database. Since there’s only one root user, we’ll enter the password we created for MySQL earlier.
On the very next screen we will create a password specifically to use with PHPMyAdmin. Confirm it and we’re done.
After setting up our database management tool we’ll restart Apache to make sure all changes take effect. Once Apache reboots, we’ll check to see if PHPMyAdmin is working properly. To do that, let’s head back to our browser and enter the following URL:
PHPMyAdmin Error Troubleshooting
If all went well you’ll see a gorgeously clean interface welcoming you to PHPMyAdmin. To login, simply enter “root” as the Username and the root password for MySQL. Once logged in you can play around by creating databases and adding new users.
Note: If your PHPMyAdmin test is resulting in error, it’s probably because Apache is looking for it in the wrong directory. For example, my PHPMyAdmin installation was in the “WWW” folder when it should’ve been in “HTML”. This goes back to different versions of Linux storing files in different locations.
If moving files around in the Terminal gives you anxiety, don’t worry. You can address this right from the desktop. Simply open the File System, navigate to “WWW”, and right-click to open as the root user. With your Elevated Privileges you can copy the PHPMyAdmin folder and paste it in the HTML directory. The URL above should now take you right to the PHPMyAdmin interface. Took me hours to figure this out. Some superuser I am. Haha.
That’s it, my friends. You have successfully installed your very own LAMP server. Now you’re free to create a local website and if you have the skill, build your own web apps. Victory is ours!