In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to install different versions of PHP in Ubuntu". In daily operation, I believe many people have doubts about how to install different versions of PHP in Ubuntu. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to install different versions of PHP in Ubuntu". Next, please follow the editor to study!
In this article, we will show how to install all supported versions of PHP for the most requested PHP extensions for Apache and Nginx Web servers in Ubuntu and its derivative versions using the Ond ej Sur arrow PHP. We will also show how to set the default version of PHP used on Ubuntu systems.
Note that PHP 7.x is a supported stable version of the Ubuntu software repository, which you can confirm by running the following apt command.
Linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt show php or linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt show php-a
To install the default PHP version from the Ubuntu software library, use the following command.
Linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt install php
Install PHP using PPA on Ubuntu (5.6,7.x, 8.0)
1. First add Ond ej Sur arrow PPA and install different versions of PHP-PHP 5.6, PHP 7.x and PHP 8.0 on the Ubuntu system.
Linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt install python-software-properties linuxmi@linuxmi:~/www.linuxmi.com$ sudo add-apt-repository ppa:ondrej/php
two。 Next, update the system as follows.
[linuxmi@linux:~/www.linuxmi.com] $sudo apt-get update
3. Now, install the different supported versions of PHP as follows.
For Apache Web server
[linuxmi@linux:~/www.linuxmi.com] $sudo apt install php5.6 [PHP 5.6] [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.0 [PHP 7.0] [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.1 [PHP 7.1] [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.2 [PHP 7.2] [linuxmi@linux:~/www.linuxmi.com ] $sudo apt install php7.3 [PHP 7.3] [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.4 [PHP 7.4] [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php8.0 [PHP 8.0]
For Nginx Web server
[linuxmi@linux:~/www.linuxmi.com] $sudo apt install php5.6-fpm [PHP 5.6] [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.0-fpm [PHP 7.0] [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.1-fpm [PHP 7.1] [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.2-fpm [PHP 7.2] [linuxmi@linux : ~ / www.linuxmi.com] $sudo apt install php7.3-fpm [PHP 7.3] [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.4-fpm [PHP 7.4] [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php8.0-fpm [PHP 8.0]
4. To install any PHP module, simply specify the PHP version and use the autocomplete feature to view all modules, as shown below.
-Press the Tab key to complete automatically-[linuxmi@linux:~/www.linuxmi.com] $sudo apt install php5.6 [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.0 [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.1 [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.2 [linuxmi] @ linux:~/www.linuxmi.com] $sudo apt install php7.3 [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.4 [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php8.0
5. You can now install most of the required PHP modules from the list.
-install PHP module-[linuxmi@linux:~/www.linuxmi.com] $sudo apt install php5.6-cli php5.6-xml php5.6-mysql [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.0-cli php7.0-xml php7.0-mysql [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.1-cli Php7.1-xml php7.1-mysql [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.2-cli php7.2-xml php7.2-mysql [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.3-cli php7.3-xml php7.3-mysql [linuxmi@linux:~/www.linuxmi.com] $sudo apt install php7.3-cli php7.4-xml php7.4-mysql [linuxmi@linux:~/www.linuxmi .com] $sudo apt install php7.3-cli php8.0-xml php8.0-mysql
6. Finally, verify the default version of PHP used on the system, as shown below.
[linuxmi@linux:~/www.linuxmi.com] $php-v
Set the default PHP version in Ubuntu
7. You can use the update-alternatives command to set the default PHP version used on the system, and after setting it, check the PHP version to confirm, as shown below.
-set default PHP version 5.6-[linuxmi@linux:~/www.linuxmi.com] $sudo update-alternatives-- set php / usr/bin/php5.6
-set default PHP version 7.0-[linuxmi@linux:~/www.linuxmi.com] $sudo update-alternatives-- set php / usr/bin/php7.0
-set default PHP version 7.1-[linuxmi@linux:~/www.linuxmi.com] $sudo update-alternatives-- set php / usr/bin/php7.1
-set default PHP version 8.0-[linuxmi@linux:~/www.linuxmi.com] $sudo update-alternatives-- set php / usr/bin/php8.0
8. To set the PHP version that works with the Apache web server, use the following command. First, use the a2dismod command to disable the current version, and then use the a2enmod command to enable the version you want.
-disable PHP version-[linuxmi@linux:~/www.linuxmi.com] $sudo a2dismod php5.6 [linuxmi@linux:~/www.linuxmi.com] $sudo a2dismod php7.0 [linuxmi@linux:~/www.linuxmi.com] $sudo a2dismod php7.1 [linuxmi@linux:~/www.linuxmi.com] $sudo a2dismod php7.2 [linuxmi@linux:~/www.linuxmi] .com] $sudo a2dismod php7.3 [linuxmi@linux:~/www.linuxmi.com] $sudo a2dismod php7.4 [linuxmi@linux:~/www.linuxmi.com] $sudo a2dismod php8.0- enable PHP version-[linuxmi@linux:~/www.linuxmi.com] $sudo a2enmod php5.6 [linuxmi@linux:~/www.linuxmi.com] $sudo a2enmod php7.1 [ Linuxmi@linux:~/www.linuxmi.com] $sudo a2enmod php7.2 [linuxmi@linux:~/www.linuxmi.com] $sudo a2enmod php7.3 [linuxmi@linux:~/www.linuxmi.com] $sudo a2enmod php7.4 [linuxmi@linux:~/www.linuxmi.com] $sudo a2enmod php8.0- restart the Apache server-[linuxmi@linux:~/www.linuxmi.com] $sudo systemctl restart apache2
9. After switching from one version to another, you can find your PHP configuration file by running the following command.
-For PHP 5.6-[linuxmi@linux:~/www.linuxmi.com] $sudo update-alternatives-- set php / usr/bin/php5.6 [linuxmi@linux:~/www.linuxmi.com] $php-I | grep "Loaded Configuration File"-For PHP 7.0-[linuxmi@linux: ~ / www.linuxmi.com] $sudo update-alternatives-- set php / usr/bin/php7.0 [linuxmi@linux:~/www.linuxmi.com] $php-I | grep "Loaded Configuration File"-For PHP 7.1-[linuxmi@linux:~/www.linuxmi.com] $sudo update-alternatives-- set php / usr/bin/php7.1 [linuxmi@linux:~/www. Linuxmi.com] $php-I | grep "Loaded Configuration File"-For PHP 7.2-[linuxmi@linux:~/www.linuxmi.com] $sudo update-alternatives-- set php / usr/bin/php7.2 [linuxmi@linux:~/www.linuxmi.com] $php-I | grep "Loaded Configuration File"-For PHP 7.3-- -[linuxmi@linux:~/www.linuxmi.com] $sudo update-alternatives-- set php / usr/bin/php7.3 [linuxmi@linux:~/www.linuxmi.com] $php-I | grep "Loaded Configuration File"-For PHP 7.4-[linuxmi@linux:~/www.linuxmi.com] $sudo update-alternatives-- set php / usr/ Bin/php7.4 [linuxmi@linux:~/www.linuxmi.com] $php-I | grep "Loaded Configuration File"-For PHP 8.0-[linuxmi@linux:~/www.linuxmi.com] $sudo update-alternatives-- set php / usr/bin/php8.0 [linuxmi@linux:~/www.linuxmi.com] $php-I | grep "Loaded Configuration File" so far The study on "how to install different PHP versions in Ubuntu" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.