So installieren Sie PHP7 auf Linux Centos

WBOY
Freigeben: 2023-05-15 20:16:04
nach vorne
1957 Leute haben es durchsucht

linux Centos安装PHP7的方法:1、通过“yum -y install”命令安装EPEL源,REMI源以及Yum源管理工具;2、使用“yum -y”命令安装PHP;3、查看PHP安装包;4、修改php.ini配置;5、通过“systemctl restart php74-php-fpm”重启“php74-php-fpm”即可。

一、安装前库文件和工具准备

1、首先安装 EPEL 源

yum -y install epel-release
Nach dem Login kopieren

2.安装 REMI 源

yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Nach dem Login kopieren

3.安装 Yum 源管理工具

yum -y install yum-utils
Nach dem Login kopieren

二、安装PHP

1.安装PHP

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
Nach dem Login kopieren

2.重启一下计算机,不然有可能无法启动php

reboot
Nach dem Login kopieren

3.设置开机启动、运行服务

systemctl start php74-php-fpm
systemctl enable php74-php-fpm
Nach dem Login kopieren

三、设置PHP

1.查看PHP安装包

[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
Nach dem Login kopieren

2.找到:php74-php-fpm-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
Nach dem Login kopieren

3.查找php.ini位置:

[root@localhost src]# find /etc/opt/remi/php74 -name php.ini/etc/opt/remi/php74/php.ini
Nach dem Login kopieren

4.编辑/etc/opt/remi/php74/php.ini,替换 ;cgi.fix_pathinfo=1 为 cgi.fix_pathinfo=0 ;

[root@localhost src]# vim /etc/opt/remi/php74/php.ini
cgi.fix_pathinfo=0
Nach dem Login kopieren

5.重启php74-php-fpm

systemctl restart php74-php-fpm
Nach dem Login kopieren

6.更多操作

systemctl restart php74-php-fpm #重启
systemctl start php74-php-fpm #启动
systemctl stop php74-php-fpm #关闭
systemctl status php74-php-fpm #检查状态
Nach dem Login kopieren

四、设置PHP软连接和环境变量

1.建立php程序的软连接

ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php
Nach dem Login kopieren

2.修改rc文件
1.当前用户的环境变量

#如果是使用bash作为shell
vim ~/.bashrc
#增加一行环境变量
export PATH=/opt/remi/php74/root/usr/bin:$PATH
#刷新一下环境变量
source ~/.bashrc
Nach dem Login kopieren

2.修改全局环境变量

vim /etc/profile
export PATH=/opt/remi/php74/root/usr/bin:$PATH
Nach dem Login kopieren

查看 PHP
验证一下是否安装成功:

[root@VM-0-5-centos ~]# php -v
PHP 7.4.24 (cli) (built: Sep 21 2021 11:23:11) ( NTS )Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Nach dem Login kopieren

上面安装 的PHP 只是安装了部分 PHP 拓展,更多的软件可见:

yum search php74
Nach dem Login kopieren

Das obige ist der detaillierte Inhalt vonSo installieren Sie PHP7 auf Linux Centos. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Verwandte Etiketten:
Quelle:yisu.com
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!