LAMP is an acronym for Linux, Apache2, MySQL and PHP. However, this post is going to show you another LAMP setup with MariaDB instead of MySQL. Previous LAMP setup always included MySQL, until MariaDB was introduced and more Linux distributions began using it instead of MySQL.
Although MariaDB is rapidly replacing MySQL server, they both are the same in many aspects. In fact, MariaDB can be a drop-in replacement for MySQL. This means, you can rip out MySQL server from your Linux systems, replace it with MariaDB and installed applications won’t know the difference.
They both function in the same manner and work the same. The big difference between the MySQL and MariaDB is the terms of their licenses governing the software. There might be other minor differences, but not as important as the licenses they used to protect the software.
This brief tutorial is show to show you how to get LAMP without MySQL.
Step 1 Installing Ubuntu Linux
The L in LAMP represents Linux and Ubuntu is a great place to start with learning to use Linux. It’s probably the most used Linux distribution or operating system out there today. To install Ubuntu Linux, read the post below:
What are the Steps with Screenshots to Installing Ubuntu Minimal Servers?
After installing Ubuntu, your first task should be updating the system. To do that, run the commands below:
sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove
The commands above update Ubuntu Linux and remove absolute packages from the system. You may want to reboot your systems after running the above command.
Step 2: Installing Apache2
After Ubuntu is installed, you may want to to install Apache2 webserver next. To do that, run the commands below
sudo apt-get install apache2
When Apache2 is installed, the default default root directory on Ubuntu Linux systems is at /var/www/html and its main configuration file is at /etc/apache2/apache2.conf
The commands below are used to manage Apache2
sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service
Step 3: Installing MariaDB
After installing Apache2, go and install MariaDB database server. To do that, run the commands below
sudo apt-get install mariadb-server mariadb-client
After installing MariaDB, the commands below can be used to manage the server.
sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service
To secure MariaDB server, use the included security script below:
This should prompt you to answer series of questions as shown below.. use the guide to complete and you’re done.
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): Press Enter since you haven't created a password
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
Remove anonymous users? [Y/n] y
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
- Removing privileges on test database...
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Step 4: Installing PHP
At this point, you should have Ubuntu Linux, Apache2 and MariaDB installed. The final component of LAMP (without MySQL) is PHP. At the time of this post, PHP 7 was the latest version included in Ubuntu default repositories.
To install PHP 7 on Ubuntu, run the commands below:
sudo apt-get install php7.0
The commands above just install PHP main package. To include other PHP modules that are very important for most PHP based applications, run the commands commands
sudo apt-get install libapache2-mod-php7.0 php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-imagick php7.0-mcrypt php7.0-pspell php7.0-recode php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring
After installing PHP and other important PHP modules, restart Apache2 web server
sudo systemctl restart apache2.service.
This is how to install LAMP with MariaDB instead of MySQL.