Home / Linux / PHP / PHP 5.6

PHP 5.6


Install PHP 5.6 on Cent OS 7.0:
Install epel-release:
  1. sudo yum install epel-release

If the above fails, add the following repo:

  1. wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.norarch.rpm && sudo rpm -Uvh epel-release-7*.rpm

Add IUS repo for PHP 5.6:

  1. wget https://centos7.iuscommunity.org/ius-release.rpm && sudo rpm -Uvh ius-release.rpm

Update packages:

  1. sudo yum update

Install PHP packages:

  1. sudo yum install php56u \
  2.  php56u-devel \
  3.  php56u-fpm \
  4.  php56u-gd \
  5.  php56u-mbstring \
  6.  php56u-mcrypt \
  7.  php56u-mysql \
  8.  php56u-pdo \
  9.  php56u-opcache \
  10.  php56u-pear \
  11.  php56u-xml \
  12.  php56u-xmlrpc \
  13.  php56u-mhash \
  14.  php56u-curl \
  15.  php56u-cli \
  16.  php56u-soap

Add Redis Extension:

  1. sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
  2. sudo yum --enablerepo=remi,remi-php56 install redis php-pecl-redis

Confirm addition of module:

  1. php -m | grep redis

Configure php-fpm:

Edit php.ini and set the cgi.fix_pathinfo attribute to 0.

  1. cgi.fix_pathinfo=0

Update the php-fpm config file (/etc/php-fpm.d/www.conf) to reflect the following values:

  1. listen = /var/run/php-fpm/php-fpm.sock
  2. listen.owner = nginx
  3. listen.group = nginx
  4. user = nginx
  5. group = nginx

Change the permissions on the following files to Nginx:

  1. sudo chown nginx:nginx /var/lib/php-fpm/session
  2. sudo chown nginx:nginx /var/lib/php-fpm/wsdlcache

Restart php-fpm for changes to take effect:

  1. sudo systemctl start php-fpm

Enable php-fpm to run on start:

  1. sudo systmctl enable php-fpm

Configure Nginx to Process PHP:

Modify the Nginx config file (/etc/nginx/conf.d/default.conf) to:

  • Add index.php options as first value of the index directive to allow PHP index files to be served when a directory is requested;
  • Modify server_name directive to point to server's domain name or public ip address;
  • Add error processing;
  • Specify PHP processor and define a try_files directive to prevent bad requests from being passed on to the PHP processor.
  1. server {
            listen  80;
            server_name     www.centos.dev centos.dev;

            root    /usr/share/nginx/html;
            index index.php index.html index.htm;

            location / {
                    try_files $uri $uri/ =404;
            }

            error_page 404 /404.html;
            error_page 500 502 503 504 /50x.html;
            location = /50x.html {
                    root /usr/share/nginx/html;
            }

            location ~ \.php$ {
                    try_files $uri =404;
                    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    include fastcgi_params;
            }
    }

Enable CURL calls by updating SELinux:

  1. sudo setsebool -P httpd_can_network_connect 1

Add Redis port to SELinux:

  1. sudo semanage port -a -t http_port_t -p tcp 6379

Check to confirm port exception:

  1. sudo semanage port -l | egrep '(^http_port_t|6379)'

Disable Xdebug:

Find the extension ini file (/etc/php.d/15-xdebug.ini) and comment out the top line. Restart php-fpm (if using php-fpm.)




    Post a comment

    Your Name or E-mail ID (mandatory)

     

    Note: Your comment will be published after approval of the owner.




     RSS of this page