How to install Apache PHP 7.2 on centos 7

install php ubuntu, install php mysql, php configuration centos

Install and configuration PHP 5.6 - 7.2 on centos

Install all the necessary repos and packages

             # yum install httpd -y
             # yum install
             # yum install
             # yum install yum-utils -y
             # yum install php56 -y
             # yum install php72 -y

Make script wrapper to call php56-cgi and php72-cgi

              #cat > /var/www/cgi-bin/php56.fcgi << EOF
                  exec /bin/php56-cgi
              #cat > /var/www/cgi-bin/php72.fcgi << EOF
                 exec /bin/php72-

Make them executable by apache

             #chmod 755 /var/www/cgi-bin/php56.fcgi
             #chmod 755 /var/www/cgi-bin/php72.fcgi

Create php configuration for apache. by default it runs php56-fcgi handler
    #cat > /etc/httpd/conf.d/php.conf << EOF
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
    AddHandler php56-fcgi .php
    Action php56-fcgi /cgi-bin/php56.fcgi
    Action php72-fcgi /cgi-bin/php72.fcgi
    <Directory /var/www/html/php56>
        DirectoryIndex index.php
        AllowOverride all
        Require all granted
    <Directory /var/www/html/php72>
        DirectoryIndex index.php
        AllowOverride all
        Require all granted

Make test pages, create .htaccess to use php72-fcgi

            #mkdir -p /var/www/html/php56
            #mkdir -p /var/www/html/php72
            #echo "<?php phpinfo(); ?>" > /var/www/html/php56/index.php
            #echo "<?php phpinfo(); ?>" > /var/www/html/php72/index.php
            #echo "AddHandler php72-fcgi .php" > /var/www/html/php72/.htaccess

Now you should start httpd service on a server.

            #service httpd restart

Now you should be able to test it


Thanks for visit us!

# Install php centos 7 # Install apache on centos 7

Add new comment

Authored By

swati sharma

Am working in HCL since 2 yr. i am RHCE certified engineer, working since 4 yr as a Network Admin.

Follow us on

Facebook​  Twitter  LinkedIn  Google+