What should I do if php5 is displayed after installing php7?

PHPz
Release: 2023-03-31 09:33:44
Original
561 people have browsed it

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
Copy after login

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
Copy after login

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'
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!