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!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

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.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

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 strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


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

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.