Installing LAMP (Linux, Apache, MariaDB and PHP) on Fedora 22

Fedora 22 has been released just a few days ago and you can now install LAMP on it. LAMP is a suite of tools needed to build your web server with support for relational database such as MariaDb with the new package manager (DNF) in Fedora 22, there is a slight difference from the usual steps you have to perform the install.

The LAMP abbreviations is taken from the first letter of each package that it has – Linux, Apache, MariaDB and PHP . Since you already have Fedora installed, the Linux part is complete, else you can follow the following guides to install Fedora 22.

  1. Fedora 22 Server Installation Guide
  2. Fedora 22 Workstation Installation Guide

Once Fedora 22 has been installed, you will need to do a full system update by issuing the following command:

# dnf update
Update Fedora 22
Update Fedora 22

Now we are ready to continue. I will separate the installation process in 3 different steps to make the whole process easier for you.

Step 1: Setup Apache Web Server

1. Apache web server powers millions of websites across the web. It is very flexible in terms of customization and its security can be greatly improved with modules such as mod_security and mod_evasive.

To install Apache in Fedora 22 you can simply run the following command as root:

# dnf install httpd
Install Apache on Fedora 22
Install Apache Web Server

2. Once the install is complete you can power on Apache by issuing the following command:

# systemctl start httpd 
Start Apache Web Server
Start Apache Web Server

3. To verify that Apache is working properly open your server’s IP address in a web browser. You can find your IP address with command such as:

# ifconfig | grep inet
Check IP Address
Check IP Address

4. Once you know the IP address, you can enter your IP address in the browser you should see the default Apache page:

Note: In case you are not able to reach the page, it could be that the firewall is blocking connection on port 80. You can allow connections on the default Apache ports (80 and 443) by using:

# firewall-cmd --permanent –add-service=http
# firewall-cmd --permanent –add-service=https
Open Apache Ports on Firewall
Open Apache Ports on Firewall
Fedora 22 Apache Default Page
Fedora 22 Apache Default Page

5. To ensure that Apache will start upon sytem boot run the following command.

# systemctl enable httpd
Enable Apache at Boot
Enable Apache at Boot

Note: The default Apache directory root for your website files is /var/www/html/, make sure to place your files in there.

Step 2: Install MariaDB

6. MariaDB is an open source fork of the famous MySQL relational database. MariaDB has been forked by the MySQL creators due to concerns of Oracle acquisition. MariaDB is meant to remain free under the GNU GPL. It is slowly becoming the preferred option for a relational database engine.

To complete the install of MariaDB in Fedora 22 issue the following commands:

# dnf install mariadb-server 
Install MariaDB in Fedora 22
Install MariaDB Server

7. Once mariadb installation complete, you can start and enable MariaDB to auto start at system boot by issuing the following commands:

# systemctl start mariadb
# systemctl enable mariadb
Start Enable MariaDB Server
Start Enable MariaDB Server

8. By default the root user will not have a root password set, you need to run mysql_secure_installation command to set new root password and secure mysql installation as shown below.

# mysql_secure_installation 

Once executed, you will be asked to enter the MySQL root password – simply press enter as there is no password for that user. The rest of the options depend on your choice, you can find a sample output and configuration suggestions in below screenshot:

Secure MariaDB Installation

Step 3: Install PHP with Modules

9. PHP is a powerful programming language can be used for generating dynamic content on websites. It is one of the most frequently used programming languages for web.

The installation of PHP and its modules in Fedora 22 is simple and can be completed with these commands:

# dnf install php php-mysql php-gd php-mcrypt php-mbstring
Install PHP with Modules
Install PHP with Modules

10. Once the install is complete you can test PHP by creating a simple PHP file info.php under Apache root directory i.e. /var/www/html/ and then restart Apache service to verify the PHP info by navigating your browser to the address http://server_IP/info.php.

# echo "<?php phpinfo(); ?>" > /var/www/html/info.php
# systemctl restart httpd
Restart Apache Service
Restart Apache Service
Check PHP Info
Check PHP Info

Your LAMP stack setup is now complete and you have all the tools to start building your projects.

If you have any questions or ideas how to improve the setup of your LAMP stack please do not hesitate to submit a comment in the comment section below.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Marin Todorov
I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

10 Comments

Leave a Reply
  1. Exactly what I needed, thank you for the clear instructions. I’m new to Linux and had LAMP up and running the first time through.

    Reply
  2. Hi, and thanks for clear instructions! I’m quite new to Linux and don’t know if this is new to anyone else, but found out that in my Fedora 22 installation I had to type #firewall-cmd –reload after opening firewall ports to get www-server working from outside localhost.

    Reply
  3. Thanks for an awesome, clear and precise manual.
    If it is for beginners as well (so it seems), an instruction to go ‘su’ is missing.
    Also, for convenience, I would recommend replacing ‘dnf’ with ‘dnf -y’ everywhere.

    Excellent!!!

    Reply
  4. I thing you have another processes that is already “installing” something. You can find what the process is by opening a console and then running

    ps auxf | grep 13533

    This will show what is the process that is preventing the installation. You can wait for the process to finish or kill it if the process is not important.

    Reply
  5. Never mind. The other process that was running and needed to be killed was PHPStorm. I should have figured that… Sorry!

    Reply
  6. Thanks for these instructions! I followed the directions here and everything is working perfectly. However, I’ve had no luck figuring out how to install PHPMyAdmin in Fedora 22.

    When I type at CLI:

    ‘dnf install phpmyadmin -y’

    the system locates the various packages to be installed or upgraded, but then states

    ‘Downloading Packages:
    Waiting for process with pid 13533 to finish.’

    and basically times out from there.

    Any ideas? I feel like I am overlooking something.

    Thanks.

    Reply
    • You simply has another dnf process running at the same time.
      You just need to wait some time for it to clear and run the command again.

      Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.