Upgrading Fedora and Installing AMP

Apache PHP MySQL

At the beginning of May 2018, Fedora 28 was released.  I have run through the upgrading process, and can happily report that the information from Fedora Magazine works like expected.  So rather than replicating their information, I’ll just link directly to them.

As with any significant system change, be sure to back up your information before you go through the process.

AMP Installation

AMP stands for Apache MySQL and PHP.  Usually it is referred to as LAMP (with Linux making up the L), but as Fedora is already installed, that part is kind of redundant.

There are three steps to the set-up: installation of the programs, configuring the programs and configuration of the system  By the end of the process, you will have a web development environment, fully enclosed within your laptop.  Let’s get going with the installation.

AMP Component Installation

While researching the information in this article, I noticed a couple of sites had a “one-line installation”, but would only install a single component of the software.  So here is a true, installs-everything-you-need command that you need to run as root:

dnf install httpd mariadb mariadb-server php php-common php-mysqlnd php-gd php-cli php-mbstring

This command installs (in order):

  • Apache
  • MySQL and associated server component
  • PHP and associated components

With the installation out of the way, let’s get to the configuration of the applications.

Configure MySQL

The configuration of MySQL is relatively easy, given the script they provide.  Simply run (as root):


It will ask for a root password – this is the root password for MySQL, which doesn’t exist yet.  So just hit [Enter] and you will be prompted to create a new MySQL root password.  The rest of the process is to answer questions which make the MySQL installation more secure – you can safely answer Y to all the questions.

Configure PHP

Configuring PHP is more to run a script to test it works, and we will confirm the test later on.  The single-line script to run (as root) is:

echo -e "<?php\nphpinfo();\n?>" > /var/www/html/phpinfo.php

We will use the results of this script further down this post.

Configure Fedora

Now we get to configure Fedora itself, so the firewall allows the various pieces of software to share information, and to ensure the processes fire up at start-up.  To configure the firewall, enter these lines as root:

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-service=mysql
firewall-cmd --reload

By default, root owns the folder that Apache uses to present web pages.  We are going to set the user known as apache and a group known as apache as the new owners of the folder.  We will also give the group write access to the folder.  Finally, add yourself to the apache group, so your native account has write permissions to the folder.  Run the following commands as root:

chown -R apache:apache /var/www/html
chmod +775 -R /var/www/html
usermod -a -G apache yourfedorausername

Then run the following lines as root to restart the applications and configure the application start-up behaviours:

systemctl restart httpd
systemctl restart mariadb
systemctl enable httpd
systemctl enable mariadb

That’s it for the installation and configuration!  Now we just need to test what we have done.

Testing the AMP

There are two tests we can do which check if Apache and PHP are working properly.

The first is to open a a web browser in Fedora and head to http://localhost. You should get an Apache test screen.

Apache test screen in Fedora 28
Apache test screen in Fedora 28

The next test is to go to http://localhost/phpinfo.php.  This is the script we ran earlier, and should provide information about the installed PHP environment.

PHP info on Fedora 28
PHP info on Fedora 28

If you scroll down, you should see information about MySQLi as well:

MySQLi information within PHP info on Fedora 28
MySQLi information within PHP info on Fedora 28

Next Steps

We have Apache, PHP and MySQL installed and running.  If you want a nice front-end for the MySQL environment, you will have to hold on until MySQL release a version of MySQL Workbench for Fedora 28.  If you want, you can install the official MySQL YUM repository for Fedora 28 by running the following command as root:

rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-fc28-1.noarch.rpm

You can then check to see if MySQL Workbench is available by running the following command as root:

dnf install mysql-workbench-community

To generate HTML / PHP files, simply save your files in /var/www/html.  I like to use BlueFish as my HTML / PHP editor, which you can install by following the instructions on the Bluefish wiki.

Enjoy your very own, personal, self-contained LAMP stack and web development environment!


I know it has been a while since I last posted.  Fortunately (or unfortunately for the blog) it is hockey season here in Australia, and I’m pretty heavily involved in that (check out aihlstatsnews.com for more info).