Integrate Mariadb and PHP with Apache web server on Centos 7
For a web server database system and a server side scripting is very important to manage a website with a very big amount of data in that. We usually use content management system (CMS) to maintain such website. As we all know that PHP is one of the most popular server side program now a day so we will discuss how to install PHP on our apache web server and for the database system we will discuss about installing mariadb former MySql. In case of Linux server this whole package usually calls LAMP which means Linux, Apache, MariaDB and PHP.
So let’s begin with installing MariaDB in our Linux operating system. To install MaridaDB we need to update our server.
#yum update –y
Once the update is complete we need to install the mariaDB, the upgraded version of MySql. To install mariaDB we need run the below command.
#yum install mariadb-server mariadb –y
Here mariadb package is the original database system and mariadb-server usually used for serving or the server package. Once that is installed let’s start the server.
#systemctl start mariadb.service
#systemctl enable mariadb.service
Now our database server is running. But we have to initialize the secure mariadb service. To do so, we need to run the below command.
This command will take us to a installation console and we need to put necessary information and our choice to install the database system. Let’s see the important issues to install the database system.
Enter current password for root (enter for none): press enter here.
Then find the below section.
Set root password? [Y/n]
New password: put the password
you want to set as your root password for the database.
Re-enter new password: put the same password here.
Now find the below section.
Remove anonymous users? [Y/n]: here the default option is Y. so just press enter.
Disallow root login remotely? [Y/n]: here the default option is Y. so just press enter.
This is also necessary to put “Yes” because of security reasons.
Remove test database and access to it? [Y/n]: here the default option is Y. so just press enter.
This option usually deletes the test database and the predefined privilege table. So that, a system administrator can administrates the database system without any issues. The last option to find is
Reload privilege tables now? [Y/n]: here the default option is Y. so just press enter.
This option will reload only the privilege of root user. so if we add any new user then we have to grant privilege for the user and we have to set the table that will be administrated by the user. Once these steps are done we need to restart the mariadb service.
Few notes about database administration is that we should not provide root user password to anyone who is not responsible about the administration of this server and we always should use an user who will have privilege for particular table.
Now we will discuss how we can install the PHP programming language and other necessary modules. If we want to install the latest versions of the PHP programming language then we have to install and enable two repositories and then we have to install it. So follow the steps below.
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Now we have to install another tool for yum which is given below.
#yum install yum-utils
Now we need to enable both of them and install the PHP version 7 in our server first.
# yum-config-manager –enable remi-php70
Now finally install the PHP in linux.
# yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
#systemctl restart httpd.service
Now restart the apache server and our work is done here. To restart apache server we need to run the below command.
# systemctl restart httpd.service
Our work is done here.