×



LAMP stands for Linux OS, with Apache web server, Data store in a MySQL database, and dynamic content is processed by PHP. It is a group of open-source software and and widely used for hosting websites.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related LAMP queries.

In this context, we shall look into how to install LAMP stack on CentOS 7.


How to Install LAMP stack on CentOS ?

Before proceeding with this Installation procedure, ensure that you are using a user account with sudo privileges.


1. How to Install Apache on CentOS ?

In CentOS and RHEL Apache service is known as httpd. Apache is available in default CentOS 7 repositories so installation is pretty easy. To install the package run the following command:

$ sudo yum install httpd

Once the installation is finished, you need to start and enable the Apache service by typing:

$ sudo systemctl start httpd
$ sudo systemctl enable httpd

You can confirm installation by checking the status of service by below command:

$ sudo systemctl status httpd


2.  How to Install MariaDB on CentOS ?

Now we are going to install MariaDB on your CentOS system. To install type following:

$ sudo yum install mariadb-server

If you want to install MySQL instead of MariaDB, check this tutorial for installation guide.

When the MariaDB installation completed, you should start and enable the service with:

$ sudo systemctl start mariadb.service
$ sudo systemctl enable mariadb.service

Also, check the status of service by typing:

$ sudo systemctl status mariadb.service


3. How to Install PHP on CentOS ?

By default, CentOS 7 ships with PHP version 5.4 so we are going to use Remi repository to install PHP 7.2.

Run the following command to install the Remi repository to your system:

$ sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Now you have to install yum-utils package and enable remi repository on your CentOS system using below command:

$ sudo yum install yum-utils
$ sudo yum-config-manager --enable remi-php72

Next, install the PHP and required extensions along with it by typing:

$ sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql

You should now restart the Apache service to take effect. Use below command to restart Apache service:

$ sudo systemctl restart httpd


How to Verify PHP Installation on CentOS ?

1. Create a info.php file at /var/www/html/info.php and add below lines to it and save:

<?php
phpinfo();
?>

2. Now, open your favorite browser and open info.php file with your server public ip address as given below:

http://SERVER_IP_ADDRESS/info.php

This will display the PHP information page.


[Need assistance in fixing Apache configuration issues? We can help you. ]


Conclusion

This article covers how to install LAMP stack on CentOS 7. LAMP is a stack of applications that work together on a web server to host a website. With that being said, each individual program serves a different purpose.

In LAMP: 

  • Linux serves as the server's operating system that handles all the commands on the machine.
  • Apache is a web server software that manages HTTP requests to deliver your website's content.
  • MySQL is a relational database management system (RDBMS) whose function is to maintain user's data on a server.
  • PHP is a scripting language for server-side communication.


To install Apache easily using CentOS's package manager, yum:

1. Run the command.

$ sudo yum install httpd

2. Once it installs, you can start Apache on your server.

$ sudo systemctl start httpd.service

3. You can do a spot check right away to verify that everything went as planned by visiting your server's public IP address in your web browser.

http://your_server_IP_address/


Important PHP Modules:

  • php-bcmath.x86_64 : A module for PHP applications for using the bcmath library.
  • php-cli.x86_64 : Command-line interface for PHP.
  • php-common.x86_64 : Common files for PHP.
  • php-dba.x86_64 : A database abstraction layer module for PHP applications.
  • php-devel.x86_64 : Files needed for building PHP extensions.
  • php-embedded.x86_64 : PHP library for embedding in applications.
  • php-enchant.x86_64 : Enchant spelling extension for PHP applications.
  • php-fpm.x86_64 : PHP FastCGI Process Manager.
  • php-gd.x86_64 : A module for PHP applications for using the gd graphics library.

More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com