How to install PHP7 on Linux Centos
How to install PHP7 on Linux Centos: 1. Install the EPEL source, REMI source and Yum source management tool through the "yum -y install" command; 2. Use the "yum -y" command to install PHP; 3. View PHP installation package; 4. Modify the php.ini configuration; 5. Restart "php74-php-fpm" through "systemctl restart php74-php-fpm".
The operating environment of this tutorial: CentOS 7 system, PHP7.4 version, DELL G3 computer
How to install PHP7 on Linux Centos? LINUX (CentOS 7) Install PHP7.4
Tip: The following is the text of this article, the following cases are for reference
1. Preparation of library files and tools before installation
1. First install the EPEL source
yum -y install epel-release
2. Installation REMI source
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
3. Install Yum source management tool
yum -y install yum-utils
2. Install PHP
1. Install 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
2. Restart the computer, otherwise php may not be started
reboot
3. Set up startup and operation Service
systemctl start php74-php-fpm systemctl enable php74-php-fpm
3. Set up PHP
1. View the PHP installation package
[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
2 .Find: php74-php-fpm-7.4.24-1.el7.remi.x86_64 installation location
[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
3. Find the location of php.ini:
[root@localhost src]# find /etc/opt/remi/php74 -name php.ini/etc/opt/remi/php74/php.ini
4. Edit /etc/opt/remi/php74/php.ini and replace;cgi.fix_pathinfo=1 with cgi.fix_pathinfo=0;
[root@localhost src]# vim /etc/opt/remi/php74/php.ini cgi.fix_pathinfo=0
5 .Restart php74-php-fpm
systemctl restart php74-php-fpm
6. More operations
systemctl restart php74-php-fpm #重启 systemctl start php74-php-fpm #启动 systemctl stop php74-php-fpm #关闭 systemctl status php74-php-fpm #检查状态
4. Set PHP soft connections and environment variables
1. Establish a soft connection to the php program
ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php
2. Modify the rc file
1. The current user’s environment variables
#如果是使用bash作为shell vim ~/.bashrc #增加一行环境变量 export PATH=/opt/remi/php74/root/usr/bin:$PATH #刷新一下环境变量 source ~/.bashrc
2. Modify the global environment variable
vim /etc/profile export PATH=/opt/remi/php74/root/usr/bin:$PATH
Check PHP
to verify whether the installation is successful:
[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
The PHP installed above only installs some PHP extensions. More software can be seen:
yum search php74
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to install PHP7 on Linux Centos. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

This article details implementing message queues in PHP using RabbitMQ and Redis. It compares their architectures (AMQP vs. in-memory), features, and reliability mechanisms (confirmations, transactions, persistence). Best practices for design, error

This article examines current PHP coding standards and best practices, focusing on PSR recommendations (PSR-1, PSR-2, PSR-4, PSR-12). It emphasizes improving code readability and maintainability through consistent styling, meaningful naming, and eff

This article details installing and troubleshooting PHP extensions, focusing on PECL. It covers installation steps (finding, downloading/compiling, enabling, restarting the server), troubleshooting techniques (checking logs, verifying installation,

This article explains PHP's Reflection API, enabling runtime inspection and manipulation of classes, methods, and properties. It details common use cases (documentation generation, ORMs, dependency injection) and cautions against performance overhea

PHP 8's JIT compilation enhances performance by compiling frequently executed code into machine code, benefiting applications with heavy computations and reducing execution times.

This article explores strategies for staying current in the PHP ecosystem. It emphasizes utilizing official channels, community forums, conferences, and open-source contributions. The author highlights best resources for learning new features and a

This article explores asynchronous task execution in PHP to enhance web application responsiveness. It details methods like message queues, asynchronous frameworks (ReactPHP, Swoole), and background processes, emphasizing best practices for efficien

This article addresses PHP memory optimization. It details techniques like using appropriate data structures, avoiding unnecessary object creation, and employing efficient algorithms. Common memory leak sources (e.g., unclosed connections, global v
