What should I do if php5 is displayed after installing php7?
In recent years, with the rapid development of Internet technology, more companies have begun to turn to online business. As the portal for corporate online business, websites are also receiving more and more attention. Among them, PHP as a scripting language has an increasingly wide range of applications.
When installing PHP, we may encounter various problems, such as encountering the wrong version, resulting in the installation of PHP5 instead of PHP7. So, how to solve this problem? This article will detail how to solve version problems encountered when installing PHP.
Why does the installation version problem occur?
Before we go to solve this problem, we need to first understand the cause of this problem. Sometimes, when we install PHP, we encounter the wrong PHP version. This is mainly caused by the incompatibility of PHP series versions. For example, the compatibility between PHP5 and PHP7 is not very good.
In addition, if we do not follow the correct steps when installing PHP, it may also cause problems with the version. For example, we may encounter situations where the old version of PHP is not uninstalled cleanly due to misoperation, and the configuration of PHP in the new version conflicts with the old version.
Under normal circumstances, we should follow the steps provided by the official documentation when installing PHP. This can avoid version inconsistencies to the greatest extent. But when a problem occurs, how should it be solved?
How to solve the installation version problem?
The following are several solutions summarized based on personal experience for your reference:
1. Uninstall the old version
Since the old version of PHP has not been uninstalled cleanly result, then we can start from here. If you are sure that you have completely uninstalled the old version, you can skip this step.
We can use the command sudo apt-get remove php5
to uninstall PHP5. Note that other possible parameters and auxiliary commands are omitted here. In addition, we can also delete the PHP5 configuration file at the same time by adding the -P
parameter, such as sudo apt-get remove php5 -P
.
2. Install PHP7
After uninstalling the old version, we need to install the correct version of PHP7. For specific installation steps, please refer to the following command:
sudo apt-get install php7.0
This command will start the process of upgrading the system with apt-get and installing PHP7.0. In addition, if you need to install a higher version of PHP7, you can try the following command:
sudo apt-get install php7.2
With the above command, we successfully installed PHP7.
3. Modify the configuration file
When we install the correct version of PHP, the configuration file installation will also change accordingly. They are located at /etc/php5
and /etc/php/7.0
respectively.
We can use the following command to find the location of PHP's configuration file:
sudo find / -name 'php.ini'
Here, the find
command will start from the root directory to find php.ini
file and returns its path to the terminal. You can open it in the terminal as follows:
sudo nano /etc/php5/apache2/php.ini
At this point, our work is basically done. However, if you have both Apache and Nginx and other web servers installed in your system, some additional configuration items are required. This usually requires us to change packages or regenerate configuration files.
Summary
There are many solutions to the problem of inconsistent PHP versions. No matter which method you adopt, be sure to back up files and record commands to prevent unforeseen circumstances.
When using a Linux system, maintaining a cautious attitude can reduce a lot of unnecessary troubles. If you encounter other problems when installing PHP, you can try to find relevant information or ask for help in the community. Have fun working on your issues!
The above is the detailed content of What should I do if php5 is displayed after installing php7?. 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



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

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

The article discusses symmetric and asymmetric encryption in PHP, comparing their suitability, performance, and security differences. Symmetric encryption is faster and suited for bulk data, while asymmetric is used for secure key exchange.

The article discusses implementing robust authentication and authorization in PHP to prevent unauthorized access, detailing best practices and recommending security-enhancing tools.

Article discusses retrieving data from databases using PHP, covering steps, security measures, optimization techniques, and common errors with solutions.Character count: 159

The article discusses the mysqli_query() and mysqli_fetch_assoc() functions in PHP for MySQL database interactions. It explains their roles, differences, and provides a practical example of their use. The main argument focuses on the benefits of usin

The article discusses strategies to prevent CSRF attacks in PHP, including using CSRF tokens, Same-Site cookies, and proper session management.
