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

Channel: Fedora Linux
Abstract: Install Apache Web Server 2. Once the install is complete you can power on Apache by issuing the following commandInstall PHP with Modules 10. Once th

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

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 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

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

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 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

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 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

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:

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

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 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.

Ref From: tecmint
Channels: lampfedora 22

Related articles