Skip to end of metadata
Go to start of metadata

You need to run yum in order to use PHP after setup your CentOS 7. Even though you have httpd, PHP may need to be installed manually. For compatibility with various applications like PHPMyAdmin, PHP-based server management, you will need to install additional libraries.

First of all, you need to check if you have httpd on your CentOS 7 server as following:

ls /usr/sbin/httpd

If it does not exist, you can install it simple as following:

sudo yum -y install httpd

If everything is okay, please run below commands to install PHP packages you need.

sudo yum -y update
sudo yum -y install epel-release yum-utils
sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y update
sudo yum -y install php php-common php-devel php-bcmath php-gd php-pdo php-pear php-mysqlnd php-pgsql php-mbstring php-pecl-redis php-xml tidy php-tidy php-soap php-zip php-pecl-zip php-pecl-apcu php-pecl-ssh2 mcrypt php-mcrypt php-pecl-memcache php-intl redis ImageMagick-devel
sudo yum -y install curl policycoreutils openssh-server openssh-clients postfix vim
sudo yum -y update

You may need to enable some servers just in case

sudo systemctl enable postfix
sudo systemctl enable sshd
sudo systemctl enable httpd

Once you install above, ssh connection will be blocked by firewall in some cases. If you want to stop firewalld, you should run:

sudo systemctl stop firewalld
sudo systemctl disable firewalld

To enable external connection,

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-service=mysql 
firewall-cmd --zone=public --permanent --add-service=ssh
firewall-cmd --reload

Regarding PHP settings, please refer PHP configuration I commonly use


In the PHP, error_reporting does not need to be detail necessarily for security purpose, and short_open_tag could cause coding error easily, but needs to be used for backward compatibility in some cases.

Below is what I am using for developing/operating PHP application in my servers:

error_reporting = E_ALL & ~E_NOTICE
display_errors = On
display_startup_errors = On
short_open_tag = On
register_argc_argv = On
include_path = ".:.."