Install PHP 5.6 on Cent OS 7.0:
Install epel-release:
- sudo yum install epel-release
If the above fails, add the following repo:
- 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:
- wget https://centos7.iuscommunity.org/ius-release.rpm && sudo rpm -Uvh ius-release.rpm
Update packages:
- sudo yum update
Install PHP packages:
- sudo yum install php56u \
- php56u-devel \
- php56u-fpm \
- php56u-gd \
- php56u-mbstring \
- php56u-mcrypt \
- php56u-mysql \
- php56u-pdo \
- php56u-opcache \
- php56u-pear \
- php56u-xml \
- php56u-xmlrpc \
- php56u-mhash \
- php56u-curl \
- php56u-cli \
- php56u-soap
Add Redis Extension:
- sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
- sudo yum --enablerepo=remi,remi-php56 install redis php-pecl-redis
Confirm addition of module:
- php -m | grep redis
Configure php-fpm:
Edit php.ini and set the cgi.fix_pathinfo attribute to 0.
- cgi.fix_pathinfo=0
Update the php-fpm config file (/etc/php-fpm.d/www.conf) to reflect the following values:
- listen = /var/run/php-fpm/php-fpm.sock
- listen.owner = nginx
- listen.group = nginx
- user = nginx
- group = nginx
Change the permissions on the following files to Nginx:
- sudo chown nginx:nginx /var/lib/php-fpm/session
- sudo chown nginx:nginx /var/lib/php-fpm/wsdlcache
Restart php-fpm for changes to take effect:
- sudo systemctl start php-fpm
Enable php-fpm to run on start:
- 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.
- 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:
- sudo setsebool -P httpd_can_network_connect 1
Add Redis port to SELinux:
- sudo semanage port -a -t http_port_t -p tcp 6379
Check to confirm port exception:
- 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.)