How to install Linux, Apache, MariaDB, PHP stack (LAMP) on CentOS 7?

Not happy with your web hosting service provider?

TRY YOUSTABLE

How to install Linux, Apache, MariaDB, PHP stack (LAMP) on CentOS 7?

Web hosting servers require a software to create, edit, and manager a website and it consumes very less resources compared to Windows Server OS. LAMP stand for Linux operating system, and it applies to Apache, MariaDB and PHP scripts as well. Now, installing Apache, MariaDB, and PHP Stack on CentOS 7 is very easy.

Main Server Setup

First, we have to configure the server with CentOS 7, then the scripts are eligible to work on CentOS 7.

Step 1: Server users have to access the root by using the below command.

local$ ssh [email protected]_IP_ADDRESS

Step 2: Create a new user by using the command mentioned below.

# adduser example

Now, add a new password to login & logout from the account.

# passwd example

Step 3: Add root administrator privileges to perform admin level tasks. Super user priority account helps the website to run smoothly because the account does not have any restrictions.

# gpasswd -a demo wheel

Step 4: We have to create a new Public Key to increase the security of the server. I am assuming “local user” and entering local command to create SSH Key pair. Users have to open the terminal and type the following command to create a new Public Key.

local$ ssh-keygen

Keep in mind, you have to enter the computer name in terminal instead of “local$ > Youstable$“! It should look something like this on your screen.

ssh-keygen output 
Generating public/private rsa key pair. 
Enter file in which to save the key (/Users/exampleuser/.ssh/id_rsa):

1. Installing Apache on CentOS 7

Apache also known as HTTP server is a popular solution implemented by millions of web experts in the world. Install Apache on your server by entering following commands on CentOS terminal.

# yum --enablerepo=epel,remi install httpd

Users have to start the httpd service and enable it using command line.

# systemctl enable httpd.service 
# systemctl start httpd.service

Users cannot risk loss of internet connection or it can lead to errors in the server, so make sure that you have an active internet connectivity.

2. Installing MariaDB

We have use a different command line to install MariaDB because it is a Debain based script. We are going to use “SUDO” command in the MariaDB installation.

Step 1: Press “Y” to begin the confirmation to install, and click on “Yes” to proceed. Type the following command line in terminal.

$sudo yum install mariadb-server

Step 2: Let us start the Daemon with the following command line, so enter the command in terminal.

$sudo systemctl start mariadb

Step 3: Systemctl does not view all services management commands.

$sudo systemctl status mariadb

Step 4: If the script MariaDB installed on your serrver successfully, then check the following information in your terminal.

Feb 21 17:07:30 centos-4gb-sfo2-01 systemd[1]: Started MariaDB database server.

Step 5: In the final step, you can create a Symlinks by entering following command.

$sudo systemctl enable mariadb

You can start testing the MariaDB server for errors and performance.

3. Installing PHP

Users can install PHP scripts by adding EPEL and REMI repositories.

# yum --enablerepo=epel,remi-php73 install php

The time has come to install the PHP modules to make the server functional for daily operations.

# yum --enablerepo=remi-php73 list php-* 
# yum --enablerepo=remi-php73 install php-mysql php-xml php-xmlrpc php-soap php-gd

We have successfully installed PHP modules and PHP script, and it’s time to restart the server.

# systemctl restart httpd.service

A quick restart should be enough to set everything in the place. Make sure to test the PHP based server for errors and issues.

Bottom Line

CentOS is a powerful software for web servers to manage websites on another level. Millions of people utilizing it because it consumes very less resources leaving a ton of CPU, RAM, and HDD for the website.

Leave a Comment