LAMP Server (Apache / MariaDB /PHP) on Fedora 19+ and Centos/RHEL 7

LAMP is a combination of operating system and open-source software stack. The acronym LAMP comes from the first letters of Linux, Apache HTTP Server, MySQL/MariaDB database, and PHP, Perl or Python (and sometimes PhpMyAdmin too.)

 

Installing Apache

Change to root (if not root already) user using the following command:

su -

and install apache using yum:

yum install httpd -y

Enable the httpd service to start automatically

systemctl enable httpd

Then start httpd service

systemctl start httpd

Adjust firewall to allow the httpd service to connect with remote clients.

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

 

Restart firewalld service:

firewall-cmd --reload

Testing Apache:

Open up your browser and enter http://your-ip-address/ in the address bar. You will see the Apache default page.

 

Installing MariaDB

MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements. The default database in Fedora 19 is MariaDB.

Install it using the following command:

yum install mariadb mariadb-server -y

Enable mysqld service at boot time with following command:

systemctl enable mysqld

And start mysqld service using command:

systemctl start mysqld

Set MariaDB root password:

By default mysql root user password is empty. So, to prevent unauthorized access to mysql databases, let us set a root user password:

mysql_secure_installation

 

Installing PHP

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.

Install PHP with following command:

yum install php -y

Test PHP:

Create a sample “testphp.php” file in Apache document root folder and append the lines as shown below:

vi /var/www/html/testphp.php

Add the following lines:

<?php
phpinfo();
?>

Restart httpd service:

systemctl restart httpd

Now, navigate to http://server-ip-address/testphp.php. It will display all the details about PHP such as version, build date and commands etc.

Install PHP Modules:

Search for the available PHP modules using the following command:

yum search php

Now install the required module of your choice, for example php-mysql, using the following command:

yum install php-mysql -y

Restart the httpd service.

systemctl restart httpd

To verify the modules, open your web browser and navigate to http://server-ip-address/testphp.php. You will able to see the installed PHP modules.

2 thoughts on “LAMP Server (Apache / MariaDB /PHP) on Fedora 19+ and Centos/RHEL 7”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.