LAMP Stack for Ubuntu 18.04 Bionic Beaver Server

The new LTS is out and its fantastic. While 17.10 was an excellent step out of the Unity disaster, 18.04 has made some real strides that were necessary to bring Ubuntu to the bleeding edge with Java9 , PHP7.2 , and so on. Its actually easier than ever before to install a solid, expansive, LAMP stack foundation. Some major improvements from 17.10 include the default configuration of a phpmyadmin user, an upgrade from PHP7.1, no need to enable servers automatically starting after reboot, and more. We’ll be covering the basics such as Apache PHP MariaDB and phpMyAdmin.

Before doing anything, you’ll want to update & upgrade your APT packages of course.

Apache

The defacto standard web server for the Internet, otherwise known as Apache2.

sudo apt install -y apache2 apache2-utils

Now check the version and if everything installed properly you should see some similar output.

apache2 -v

Server version: Apache/2.4.29 (Ubuntu)
Server built: 2018-04-25T11:38:24

You’ll also want to test your server using your browser

Apache2 Installed Correctly

Its also always a good idea to have everything in the webserver directory actually owned by the Apache2 user and usergroup. I also like to make sure that the Apache2 group permissions are inheritable.

​sudo  chown www-data:www-data /var/www/ -R
​sudo  chmod g+s /var/www/ -R
​sudo  chown 775 /var/www/

MariaDB

Once the poor love-child of the MySQL project, it has surpassed its Oracle-chained mother, and is now the superior Sun™ product it was always meant to be.

sudo apt install mariadb-server mariadb-client

sudo mysql_secure_installation

During this installation you’ll be asked to assign the new root password. Everything else, you’ll want to simply accept the default options (so get ready to hit Enter a bunch)

PHP7.2

If you haven’t upgraded to 7.2 on your other servers or development stations, its highly recommended. 7.2 has brought some really great advancements such as argument type declarations (i.e. type hints), object return type declarations, parameter type widening (allowing the omission of type in subclasses), includes libsodium into the core now, and much more.

sudo apt install php7.2 libapache2-mod-php7.2 php7.2-mysql php-common php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline php-pear

It should no longer be necessary to do this, as the configuration should automatically detect Apache2 and enable the Apache2 module for PHP. However, just in case you may want to enable it yourself to be sure (and it can’t hurt anything). You should actually get messages that everything was already enabled.

​sudo a2enmod php7.2

Create a test file

sudo echo "<?php phpinfo(); ?>" > /var/www/html/info.php

You should restart the Apache2 server at this point

sudo systemctl restart apache2

Now check your info.php script and you should see a similar result.

PHP7.2 Installed Correctly

 

phpMyAdmin

One of the truly greatest web tools for an SQL server. While originally intended for MySQL It works near flawlessly with MariaDB and is far superior to other tools like the one available in webmin (a great general purpose all-in-one tool in itself).

sudo apt-get install phpmyadmin libgd-tools php-gmp php-imagick

You should have two major dialogs popup. The first will ask what webserver the application will run off of. Select the Apache2 server by hitting the space bar and then select the OK text or hitting return/enter should work as well.

Configuring phpMyAdmin

The second dialog will ask for confirmation about dbconfig. Simply agree with Yes to finish the installation and configuration.

In previous versions it was required to create a new user to access the webapp because root access is denied by default/design. However, the very latest incarnation now automatically creates and configures a default user making this a real breeze. The username will be phpmyadmin and you’ll have been (or should’ve been) asked for a password during installation.

Now navigate to your new server at yourdomain/phpmyadmin and you’re all set!

phpMyAdmin Installed Successfully

Leave a Reply