Home >Backend Development >PHP7 >How to install php7 on centos yum
How to install php7 on centos yum: first install the EPEL source and source management tool; then install the REMI source; finally install PHP7 and extensions through "yum install -y php73-php-fpm...".
The operating environment of this article: windows7 system, PHP7.3 version, DELL G3 computer
How to install php7 on centos yum?
CentOS 7 yum install PHP7.3
Install PHP
Remi software source
Remi software source mainly provides the latest version of PHP software packages and some other PHP extension tool packages. It is for Fedora and RHEL branch variants (including: RHEL, CentOS, Oracle Linux, etc.) To install PHP, it is recommended to use Remi software source. Remi is very active in supporting and updating PHP, and can get support for new versions as soon as possible.
Install EPEL source and source management tools:
yum install epel-release yum-utils
Install REMI source:
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Install PHP7.3 and extensions:
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-pecl-swoole php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll
php73 -v # View version
systemctl enable php73-php-fpm #开启开机自启 systemctl restart php73-php-fpm #重启 systemctl start php73-php-fpm #启动 systemctl stop php73-php-fpm #关闭 systemctl status php73-php-fpm #检查状态
Configuration file path:
#查找php.ini位置: find /etc/opt/remi/php73 -name php.ini # The current PHP memory limit is below the recommended value of 512MB. vi /etc/opt/remi/php73/php.ini memory_limit = 512M #如果你运行的是 nginx 而不是 apache,修改 vi /etc/opt/remi/php73/php-fpm.d/www.conf user = apache group = apache # Replace the values with user = nginx group = nginx #查找 php 和扩展的安装包: rpm -qa | grep 'php' #查看 php73-php-pecl-swoole4-4.4.15-1.el7.remi.x86_64 的安装路径: rpm -ql php73-php-pecl-swoole4-4.4.15-1.el7.remi.x86_64
Setting php:
# 将php73链接到系统环境变量中,就可以使用 php -v ln -s /opt/remi/php73/root/usr/bin/php /usr/bin/php # 将 cgi.fix_pathinfo 设置为 0 sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/opt/remi/php73/php.ini
For cgi.fix_pathinfo options, please check (https://taobig.org/?p=650 )
Potential vulnerability risks, for questions about security risks, please see (http://www.laruence.com/2010/05/20/1495.html)
Install more extensions :
Currently only some PHP extensions are installed, more extensions can be seen:
yum search php73
Update PHP:
yum update #Update all updateable software, including PHP
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to install php7 on centos yum. For more information, please follow other related articles on the PHP Chinese website!