The correct way to install PHP7 on CentOS
1 |
|
1 2 3 4 |
|
rh- The prefix means RedHat, telling you that this is the official PHP provided and not provided by a third-party library. The author guesses that this prefix specification was formulated around 2015, and PHP5.4 & 5.5 were released before that. In order to ensure the compatibility of your program (for example, some of your programs have already written yum install php55, add a prefix The program hangs), without the rh- prefix.
Next, install PHP7.0:1 |
|
$PATH variable, so you cannot directly execute the software. of the command. You need to display the execution through the scl enable command:
First look at what software is installed by SCL:1 |
|
1 |
|
bash command, then the newly opened shell will automatically recognize php:
1 2 3 4 5 6 7 |
|
scl enable This method of management software adds a little trouble to use, but it absolutely guarantees system stability. And there is another advantage to doing this: multiple PHP versions can coexist on the system without conflicting with each other. It is convenient for you to test the compatibility of your code or framework on various versions of PHP.
In short, if you want to do a rigorous operation and maintenance, this article still highly recommends using SCL to manage the software on your system. The PHP version on CentOS is very old and cannot meet the PHP version requirements of some frameworks. As a result, many third-party software libraries have emerged, such as EPEL, RPM Fusion, Remi, etc., which provide new versions of PHP. Let our system keep pace with the times. However, third-party software libraries have several disadvantages: First, the software they provide has not been officially tested by CentOS. When installing the software, some core files of the system may be replaced, causing system instability. . Second, the software installed by third-party libraries may not guarantee compatibility, and upgrading the system may render certain software unusable. So this article recommends using the SCL (Software Collections) software library to install a higher version of PHP. SCL belongs to the official software library of CentOS. It has been fully tested and will not replace the core files of the system when installing the software, ensuring the stability of the system. Installing SCL is very simple, just one command is enough:1 |
|
1 2 3 4 |
|
rh- The prefix means RedHat, telling you that this is the official PHP provided and not provided by a third-party library. The author guesses that this prefix specification was formulated around 2015, and PHP5.4 & 5.5 were released before that. In order to ensure the compatibility of your program (for example, some of your programs have already written yum install php55, add a prefix The program hangs), without the rh- prefix.
Next, install PHP7.0:1 |
|
此时如果你运行php命令,系统依然会提示你command not found。这是因为,SCL的风格就是把软件对系统的影响减少到最小,甚至安装完PHP,php命令都不会被添加到 $PATH 变量中,所以你没法直接执行软件中的命令的。需要通过 scl enable 命令显示执行:
先看看SCL安装了哪些软件:
1 |
|
可以看到我们在系统安装了一个rh-php70,先启用它并执行命令:
1 |
|
命令成功执行了。要是每一条命令都要这么执行,太麻烦了!不要紧,你可以不用每次执行一条命令,而是直接执行 bash 命令,那么新开的shell就能自动识别php了:
1 2 3 4 5 6 7 |
|
SCL以 scl enable 方式管理软件,虽然在使用上增加了一点点的麻烦,但这绝对地保证了系统稳定性。而且这么做还有一个好处:就是系统上可以多个PHP版本共存而互相不冲突。方便你测试代码或者框架,在各个版本PHP上的兼容性。
总之,要做一个严谨的运维,本篇还是十分推荐用SCL管理你系统上的软件。
推荐教程:《php视频教程》
The above is the detailed content of The correct way to install PHP7 on 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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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





Backup and Recovery Policy of GitLab under CentOS System In order to ensure data security and recoverability, GitLab on CentOS provides a variety of backup methods. This article will introduce several common backup methods, configuration parameters and recovery processes in detail to help you establish a complete GitLab backup and recovery strategy. 1. Manual backup Use the gitlab-rakegitlab:backup:create command to execute manual backup. This command backs up key information such as GitLab repository, database, users, user groups, keys, and permissions. The default backup file is stored in the /var/opt/gitlab/backups directory. You can modify /etc/gitlab

Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

Complete Guide to Checking HDFS Configuration in CentOS Systems This article will guide you how to effectively check the configuration and running status of HDFS on CentOS systems. The following steps will help you fully understand the setup and operation of HDFS. Verify Hadoop environment variable: First, make sure the Hadoop environment variable is set correctly. In the terminal, execute the following command to verify that Hadoop is installed and configured correctly: hadoopversion Check HDFS configuration file: The core configuration file of HDFS is located in the /etc/hadoop/conf/ directory, where core-site.xml and hdfs-site.xml are crucial. use

Common problems and solutions for Hadoop Distributed File System (HDFS) configuration under CentOS When building a HadoopHDFS cluster on CentOS, some common misconfigurations may lead to performance degradation, data loss and even the cluster cannot start. This article summarizes these common problems and their solutions to help you avoid these pitfalls and ensure the stability and efficient operation of your HDFS cluster. Rack-aware configuration error: Problem: Rack-aware information is not configured correctly, resulting in uneven distribution of data block replicas and increasing network load. Solution: Double check the rack-aware configuration in the hdfs-site.xml file and use hdfsdfsadmin-printTopo

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.
