Cara memasang PHP7 pada Linux Centos: 1. Pasang sumber EPEL, sumber REMI dan alat pengurusan sumber Yum melalui arahan "yum -y install" 2. Gunakan "yum -y" arahan Pasang PHP; 3. Semak pakej pemasangan PHP; 4. Ubah suai konfigurasi php.ini; 5. Mulakan semula "php74-php-fpm" melalui "systemctl restart php74-php-fpm".
1 Pasang sumber EPEL dahulu
yum -y install epel-release
2 3 .Pasang alat pengurusan sumber Yum
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
2 Pasang PHP
yum -y install yum-utils
2
yum -y --enablerepo=remi install php74-php php74-php-fpm php74-php-bcmath php74-php-ctype php74-php-curl php74-php-dom php74-php-gd php74-php-hash php74-php-iconv php74-php-intl php74-php-mbstring php74-php-pdo_mysql php74-php-simplexml php74-php-soap php74-php-xsl php74-php-zip php74-php-xml php74-php-sockets php74-php-session php74-php-snmp php74-php-mysql php74-php-cli php74-php-json php74-php-mcrypt php74-php-mysqlnd php74-php-pecl-crypto php74-php-pecl-mcrypt php74-php-pecl-geoip php74-php-recode php74-php-xmll
reboot
systemctl start php74-php-fpm systemctl enable php74-php-fpm
[root@VM-0-5-centos ~]# rpm -qa | grep php oniguruma5php-6.9.7.1-1.el7.remi.x86_64 php74-php-common-7.4.24-1.el7.remi.x86_64 php74-php-7.4.24-1.el7.remi.x86_64 php74-php-xml-7.4.24-1.el7.remi.x86_64 php74-php-pdo-7.4.24-1.el7.remi.x86_64 php74-php-pecl-mysql-1.0.0-0.23.20190415.d7643af.el7.remi.x86_64 php74-php-fpm-7.4.24-1.el7.remi.x86_64 php74-php-bcmath-7.4.24-1.el7.remi.x86_64 php74-php-pecl-recode-1.0.0~DEV.20190723-4.el7.remi.x86_64 php74-runtime-1.0-3.el7.remi.x86_64 php74-php-mysqlnd-7.4.24-1.el7.remi.x86_64 php74-php-pecl-crypto-0.3.2-1.el7.remi.x86_64 php74-php-soap-7.4.24-1.el7.remi.x86_64 php74-php-intl-7.4.24-1.el7.remi.x86_64 php74-php-pecl-zip-1.19.5-1.el7.remi.x86_64 php74-php-json-7.4.24-1.el7.remi.x86_64 php74-php-cli-7.4.24-1.el7.remi.x86_64 php74-php-sodium-7.4.24-1.el7.remi.x86_64 php74-php-pecl-geoip-1.1.1-11.el7.remi.x86_64 php74-php-snmp-7.4.24-1.el7.remi.x86_64 php74-php-pecl-mcrypt-1.0.4-1.el7.remi.x86_64 php74-php-gd-7.4.24-1.el7.remi.x86_64 php74-php-mbstring-7.4.24-1.el7.remi.x86_64
[root@VM-0-5-centos ~]# rpm -ql php74-php-fpm-7.4.24-1.el7.remi.x86_64/etc/logrotate.d/php74-php-fpm/etc/opt/remi/php74/php-fpm.conf/etc/opt/remi/php74/php-fpm.d/etc/opt/remi/php74/php-fpm.d/www.conf/etc/opt/remi/php74/sysconfig/php-fpm/etc/systemd/system/php74-php-fpm.service.d/opt/remi/php74/root/usr/sbin/php-fpm/opt/remi/php74/root/usr/share/doc/php74-php-fpm-7.4.24/opt/remi/php74/root/usr/share/doc/php74-php-fpm-7.4.24/php-fpm.conf.default/opt/remi/php74/root/usr/share/doc/php74-php-fpm-7.4.24/www.conf.default/opt/remi/php74/root/usr/share/fpm/opt/remi/php74/root/usr/share/fpm/status.html/opt/remi/php74/root/usr/share/licenses/php74-php-fpm-7.4.24/opt/remi/php74/root/usr/share/licenses/php74-php-fpm-7.4.24/fpm_LICENSE/opt/remi/php74/root/usr/share/man/man8/php-fpm.8.gz/usr/lib/systemd/system/php74-php-fpm.service/var/opt/remi/php74/lib/php/opcache/var/opt/remi/php74/lib/php/session/var/opt/remi/php74/lib/php/wsdlcache/var/opt/remi/php74/log/php-fpm/var/opt/remi/php74/run/php-fpm
[root@localhost src]# find /etc/opt/remi/php74 -name php.ini/etc/opt/remi/php74/php.ini
[root@localhost src]# vim /etc/opt/remi/php74/php.ini cgi.fix_pathinfo=0
4. Sediakan sambungan lembut PHP dan pembolehubah persekitaran
1. Wujudkan sambungan lembut untuk program PHP
systemctl restart php74-php-fpm
systemctl restart php74-php-fpm #重启 systemctl start php74-php-fpm #启动 systemctl stop php74-php-fpm #关闭 systemctl status php74-php-fpm #检查状态
ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php
#如果是使用bash作为shell vim ~/.bashrc #增加一行环境变量 export PATH=/opt/remi/php74/root/usr/bin:$PATH #刷新一下环境变量 source ~/.bashrc
vim /etc/profile export PATH=/opt/remi/php74/root/usr/bin:$PATH
Atas ialah kandungan terperinci Bagaimana untuk memasang PHP7 pada Linux Centos. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!