CentOS 7 configure php language development environment

CentOS 7 configure php language development environment#

Initial setting reference: http://blog.csdn.net/wh211212/article/details/52923673

Install PHP 5.6

It can be installed from the CentOS SCLo software collection. Even if 5.4 is installed, it can be installed because 5.6 is located on another PATH.

# install from SCLo
[ root@linuxprobe ~]# yum --enablerepo=centos-sclo-rh -y install rh-php56
# load environment variables
[ root@linuxprobe ~]# scl enable rh-php56 bash
[ root@linuxprobe ~]# php -v
PHP 5.6.5(cli)(built: Mar 23201619:17:38)Copyright(c)1997-2014 The PHP Group
Zend Engine v2.6.0,Copyright(c)1998-2014 Zend Technologies
[ root@linuxprobe ~]# which php
/opt/rh/rh-php56/root/usr/bin/php
[ root@linuxprobe ~]# vi /etc/profile.d/rh-php56.sh
#! /bin/bash
source /opt/rh/rh-php56/enable
export X_SCLS="`scl enable rh-php56 'echo $X_SCLS'`"

Install PHP 7.0

Can be installed from Remi's repository

[ root@linuxprobe ~]# yum --enablerepo=remi-safe -y install php70
[ root@linuxprobe ~]# php70 -v
PHP 7.0.8(cli)(built: Jun 22201610:57:20)( NTS )Copyright(c)1997-2016 The PHP Group
Zend Engine v3.0.0,Copyright(c)1998-2016 Zend Technologies
[ root@linuxprobe ~]# which php70
/bin/php70
[ root@linuxprobe ~]# ll /bin/php70
lrwxrwxrwx 1 root root 32 Jul 609:58/bin/php70 ->/opt/remi/php70/root/usr/bin/php
# load environment variables with SCL tool
[ root@linuxprobe ~]# scl enable php70 bash
[ root@linuxprobe ~]# php -v
PHP 7.0.8(cli)(built: Jun 22201610:57:20)( NTS )Copyright(c)1997-2016 The PHP Group
Zend Engine v3.0.0,Copyright(c)1998-2016 Zend Technologies
[ root@linuxprobe ~]# vi /etc/profile.d/php70.sh
#! /bin/bash
source /opt/remi/php70/enable
export X_SCLS="`scl enable php70 'echo $X_SCLS'`"

Install PHP 7.1

Can be installed from Remi's repository

[ root@linuxprobe ~]# yum --enablerepo=remi-safe -y install php71
[ root@linuxprobe ~]# php71 -v
PHP 7.1.3(cli)(built: Mar 14201716:22:48)( NTS )Copyright(c)1997-2017 The PHP Group
Zend Engine v3.1.0,Copyright(c)1998-2017 Zend Technologies
[ root@linuxprobe ~]# which php71
/bin/php71
[ root@linuxprobe ~]# ll /bin/php71
lrwxrwxrwx 1 root root 32 Jul 611:10/bin/php71 ->/opt/remi/php71/root/usr/bin/php
# load environment variables with SCL tool
[ root@linuxprobe ~]# scl enable php71 bash
[ root@linuxprobe ~]# php -v
PHP 7.1.3(cli)(built: Mar 14201716:22:48)( NTS )Copyright(c)1997-2017 The PHP Group
Zend Engine v3.1.0,Copyright(c)1998-2017 Zend Technologies
[ root@linuxprobe ~]# vi /etc/profile.d/php71.sh
#! /bin/bash
source /opt/remi/php71/enable
export X_SCLS="`scl enable php71 'echo $X_SCLS'`"

Use PHP7.1 on Httpd, configure php-fpm

# install Apache httpd
[ root@linuxprobe ~]# yum install httpd -y
# install from Remi
[ root@linuxprobe ~]# yum --enablerepo=remi-safe -y install php71-php-fpm
[ root@linuxprobe ~]# vi /etc/httpd/conf.d/php.conf
# line 5: change like follows
< FilesMatch \.php$>
# SetHandler application/x-httpd-php
 SetHandler "proxy:fcgi://127.0.0.1:9000"</FilesMatch>[root@linuxprobe ~]# systemctl start php71-php-fpm
[ root@linuxprobe ~]# systemctl enable php71-php-fpm
[ root@linuxprobe ~]# systemctl restart httpd
# install from Remi
[ root@linuxprobe ~]# yum --enablerepo=remi-safe -y install php71-php
# rename and disable the old version if it exists
[ root@linuxprobe ~]# mv /etc/httpd/conf.modules.d/15-php71-php.conf /etc/httpd/conf.modules.d/15-php71-php.conf.org
[ root@linuxprobe ~]# systemctl restart httpd
# create phpinfo to verify working
[ root@linuxprobe ~]# echo '<?php phpinfo(); ?>'>/var/www/html/info.php
[ root@linuxprobe ~]# curl http://localhost/info.php | grep 'PHP Version'| tail -1| sed -e 's/<[^>]*>//g'% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
        Dload  Upload   Total   Spent    Left  Speed
10020100200016010--:--:----:--:----:--:--1666

Recommended Posts

CentOS 7 configure php language development environment
CentOS 7 configure Java language development environment
CentOS 7 configure Ruby language development environment
CentOS 7 configure Python language development environment
Centos7 configure nodejs environment
Configure CentOS7 GPU environment
CentOS 7.2 deploy Node.js development environment
Configure python3 environment on centos7 and
Configure Java development environment in Ubuntu20.04 LTS
Linux environment construction: CentOs + Apache + MySQL + PHP
[PHP] Build a PHP operating environment under CentOS
Configure Nginx + PHP 7.0 + MySQL environment under Ubuntu 16.04
CentOS install PHP
Centos7 configure JDK
01 CentOS 7.6 switch system language
CentOS6.7 build LNMP environment
Build a basic environment for Java development under Centos7
Configure Ocserv on CentOS 6
Install php in centos
Hadoop environment construction (centos7)
Ubuntu configuration development environment
Centos7.6 build LNMP environment
Embedded Linux development environment to build and configure Ubuntu
lamp (centos7) installation lamp environment
Install PHP in yum under CentOS, configure php-fpm service
Ubuntu development environment configuration
Centos6.9 install npm environment
Configure lamp under centos6.8
Centos7 configure IP address
Ubuntu18.10 configure Java environment
CentOS 7 build LNMP environment
[CentOS environment deployment] Java7/Java8 deployment under CentOS
Build docker environment under Centos6.5
SkyWalking study notes (CentOS environment)
Centos7 set up GitBook environment
CentOS install nginx+tomcat+java+mysql operating environment
Configure static IP under CentOS 7
Centos6.5 install and configure mongodb
Centos configure multiple virtual IP
Configure swap space on CentOS7
Centos6 set up GitBook environment
CentOS environment installation of Docker
ubuntu build python development environment
ubuntu builds common development environment
Centos7 deploys python3 virtual environment
Centos7.4 environment installation lamp-php7.0 tutorial
CentOS 7 yum install PHP7.3 tutorial
Centos configure multiple virtual IP