How to install PHP-fpm and MariaDB in CentOS 7

In the last article we installed Nginx in CentOS 7. In this article we will extend our previous how-to and add how to install PHP-fpm and MariaDB. The installation process will be quite easy. Login to your server and type:

sudo yum install mariadb-server mariadb php-mysql php php-fpm php-common php-pdo php-cli php-mbstring php-gd php-pear

This will install the basic php with few needed modules like pear, pdo etc. If you want more modules, you can install it later. Here are a few extra module i would install with the default installation:

sudo yum install php-xml php-odbc php-soap php-bcmath php-ldap php-imap mod_ssl php-mcrypt php-devel php-fileinfo pcre-devel

Now lets start PHP-fpm and MariaDB

sudo systemctl start php-fpm

sudo systemctl start mariadb

To enable these services at boot time:

sudo systemctl enable php-fpm

sudo systemctl enable mariadb

This will start the services automatically after rebooting the system.

To secure your MariaDB installation(MySQL):

sudo /usr/bin/mysql_secure_installation

It will set the root password for MariaDB, remove test db, anonymous users, disallow remote root login and reload table privileges.

For PHP-fpm, edit the file /etc/php.ini:

cgi.fix_pathinfo=0

Uncomment it if it is commented and set it to 0. This will be probably line 763(somewhere around) in php.ini.

After these changes restart PHP-fpm and MariaDB:

sudo systemctl restart php-fpm

sudo systemctl restart mariadb

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz