I need to upgrade my PHP version in WordPress, but when I try, it still returns me the older version, even the folder does not exist.
You need to follow the below steps for updating :
Add PPA repository for PHP
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
Update Ubuntu
Open terminal and run the following commands to update Ubuntu packages.
sudo apt-get update
Install PHP (Whichever version you wanna install like 7.4 8 etc)
sudo apt install php7.4
Check php version
sudo php -v
Install PHP Extensions (Optional)
PHP extensions are commonly used along with PHP. Install them with the following command.
sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y
Enable PHP 7.4 for Apache
Next you need to disable your old PHP (say 7.0) and enable new PHP 7.4.
sudo a2dismod php7.0
sudo a2enmod php7.4
Restart Apache Server
Restart Apache web server to apply changes
sudo service apache2 restart
Related
I have been trying to update PHP on my install of WordPress on Google Cloud.
I have followed these instructions: How do I upgrade from PHP 7.0 to 7.3 on google cloud platform?.
When I do a php -v command, it shows that it is updated, but within WordPress it is still showing version 7.0, not the updated version.
Your system appears to have two installations of PHP. One for the CLI and another Apache or you have not restarted Apache after the update. First restart Apache and recheck.
The command to install Apache PHP is sudo apt install libapache2-mod-php7.3.
Warning: Be careful with manual updates of PHP and other software that may have interdependencies. Make sure you have backed up your system (image) before so that you can recover is something goes wrong. Debian 4.9 is very old (obsolete) and might not be supported or even tested with the latest versions of third-party software.
The Linux command where php will tell you where PHP is installed. To figure out if you have a different installation for Apache, create a new web page, such as myphpinfo.php with the following contents. Then use your browser to view the page:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Your browser will display a page like this:
Use SSH commands:
Go to root
sudo -i
install latest version of php
apt-get install php7.4
update it
apt-get update
install packages
apt-get install ca-certificates apt-transport-https
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
check your php version
php -v
enable php7.4 and disable your current php7.0
sudo a2dismod php7.0
sudo a2enmod php7.4
install the libraries
sudo apt-get install phpmyadmin php-mbstring php-gettext
sudo apt-get install php-mysql
sudo apt-get install php-curl
sudo apt-get install php-xml
sudo apt-get install php-gd
restart apache
sudo service apache2 restart
i have a lampp stack on my Ubuntu 14.04 machine. It was installed from an apachefriends.org installer ages ago. As i can see in the binaries it has 2 PHP versions already installed with just a symlink for the actual php. Now i want to add a new PHP version (and keep the ones installed), in this case some 7.x on top of 5.x that are already present.
I think i could download and build/configure PHP but actually i have no idea how it would integrate into lampp with the existing versions. Particularly extensions, and possibly different config files. Would they use the same? Is it possible anyway?
For Ubuntu, follow:
Add PPA:
sudo add-apt-repository ppa:ondrej/php;
sudo apt-get update;
sudo apt-get upgrade;
Install Apache & MySQL (if not already installed):
sudo apt-get install apache2 mysql-server php-gettext php-xdebug;
Install PHP5.6 (if not already installed):
sudo apt-get install php5.6 php5.6-mysql php5.6-mbstring libapache2-mod-php5.6;
Install PHP7.1 (if not already installed):
sudo apt-get install php7.1 php7.1-mysql php7.1-mbstring libapache2-mod-php7.1;
Switching between PHP versions (via commands a2enmod & a2dismod):
Switch PHP Versions (7.1->5.6):
sudo a2dismod php7.1; sudo a2enmod php5.6; sudo service apache2 restart;
Switch PHP Versions (5.6->7.1):
sudo a2enmod php7.1; sudo a2dismod php5.6; sudo service apache2 restart;
I have a hard time to find exact method to install PHP intl extension in Ubuntu 14.04.
I tried with sudo apt-get install php5-intl but displays error Unable to locate package.
I really need this extension for Zend Framework 2 , because of above missing extension I am getting error like this
ERROR: Zend\I18n\Validator component requires the intl PHP extension
I am using PHP 5.5.9.
How can I install PHP-intl extension in a correct way ?
For php5 on Ubuntu 14.04
sudo apt-get install php5-intl
For php7 on Ubuntu 16.04
sudo apt-get install php7.0-intl
For php7.2 on Ubuntu 18.04
sudo apt-get install php7.2-intl
Anyway restart your apache after
sudo service apache2 restart
IMPORTANT NOTE: Keep in mind that your php in your terminal/command
line has NOTHING todo with the php used by the apache webserver!
If the extension is already installed you should try to enable it. Either in the php.ini file or from command line.
Syntax:
php:
phpenmod [mod name]
apache:
a2enmod [mod name]
install it from terminal
sudo apt-get install php-intl
May be universe repository is disabled, here is your package in it
Enable it
sudo add-apt-repository universe
Update
sudo apt-get update
And install
sudo apt-get install php5-intl
In Ubuntu 20.04, PHP 7.4 use the following command:
sudo apt-get install php7.4-intl
replace 7.4 with your PHP version
So, I have problem with it. If you can't install see below.
And previously you have to add repository.
sudo add-apt-repository ppa:ondrej/php
2.1) sudo apt-add-repository ppa:ondrej/apache2
or
2.2) sudo add-apt-repository ppa:ondrej/nginx
After that you can install
sudo apt-get install php7.4-intl
Where 7.4 your php version.
For php 5.6 on ubuntu 16.04
sudo apt-get install php5.6-intl
sudo apt-get install php-intl
then restart your server
This method works for me to install PHP intl extension in Ubuntu 18.04 and nginx
sudo apt install php7.2-intl -y
you could search with
aptitude search intl
after you can choose the right one, for example
sudo aptitude install php-intl
and finally
sudo service apache2 restart
good Luck!
I'm trying to update my php 5.5.9 to 5.6 in an Ubuntu machine.
But when I run:
sudo add-apt-repository ppa:ondrej/php5-5.6
I'm getting:
Cannot add PPA: 'ppa:ondrej/php5-5.6'.
Please check that the PPA name or format is correct.
How can I fix this?
EDIT
I ran:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5
But when I run:
php5 -v
I still get php 5.5.9:
PHP 5.5.9-1ubuntu4.20 (cli) (built: Oct 3 2016 13:00:37)
add the right ppa first, do the following
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip
i had the same issue in installing the php5.6 then i did the above steps.
While the answer of #tanveerahmaddar provides crucial information, here is the correct way to install the PHP 5.6 on Ubuntu 12.04:
Important: If you plan to use PHP5.6 in websites (which you probably wish to), you have to upgrade to Apache 2.4, which does not ship with Ubuntu 12.04 (will cover the upgrade of Apache below)
Step 1: Check versions
# check PHP version
php -v
# check Apache version
apache2 -v
If your Apache version is 2.2, follow Step 2; if version is 2.4, skip to Step 3
Step 2: Add PHP5.6+ repository and update package list
add-apt-repository ppa:ondrej/apache2
apt-get update
apt-get upgrade
This step will upgrade Apache from 2.2 to 2.4. Re-configure your Apache if needed. Backup your existing Apache configurations, enabled sites and mods. You might need to re-install / upgrade some of the mods.
Step 3: Add PHP5.6+ Repository
add-apt-repository ppa:ondrej/php
apt-get update
Step 4: Install PHP 5.6
apt-get install -y php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip libapache2-mod-php5.6
This will install PHP 5.6 and some common packages such as cURL (php5.6-curl) and GD (lib5.6-gd), as well as enable PHP 5.6 in Apache 2.4 (libapache2-mod-php5.6).
Apache will be restarted during the process.
That's all steps you have to do.
Hint: If you want to upgrade to PHP 7 instead (off-topic), just issue the following command after Step 3 (skip Step 4):
apt-get dist-upgrade
Final words: Not recommend to upgrade to PHP 5.6 in Ubuntu 12.04, as it involves upgrading Apache to 2.4. Ubuntu 14.04 comes with Apache 2.4, which is a lot easier to upgrade PHP 5.6.
This work for perfectly for me.
Add the right PPA first, by doing the following
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl
php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip
Disable php 5.5.3 or 5.5.9 module
a2dismod php5
Enable the just installed php5.6 module
a2enmod php5.6
Finally, you restart your apache
sudo service apache restart
#tanveer ahmad dar highlighted most of it.
This worked in my Ubuntu Server 14.04.5 LTS
a2dismod php5
a2enmod php5.6
apache2ctl restart
I want to Install php 5.3 or 5.4 on Ubuntu 16.04 Xenial and Apache.
A tutorial points me to use PPA but they are not helping me in what I need.
I know that PHP 5.3 and 4 are obsolete but I need this for a project and is this possible? If yes then please teach me how in a step by step procedure with Apache2.
you can use this package ppa:sergey-dryabzhinsky/php53 to install php 5.3, i managed with this package on ubuntu 16.
sudo add-apt-repository ppa:sergey-dryabzhinsky/php53
sudo apt-get update
sudo apt-get install php5
Before installing PHP 5.4 you need to read this notice:
Security support for PHP 5.4 has ended. You are using this repository knowing that there might be and probably are unfixed security vulnerabilities. Please upgrade to PHP 5.6 or PHP 7.0 as found in the main repository: ppa:ondrej/php
After understanding the risks , to install PHP 5.4 ,add the PPA to your sources.list:
sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo apt-get update
Install it:
sudo apt-get install -y php5
To be safe , the PHP 5.6 version can be installed as follows:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0
sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart
Update
All version prior to PHP 5.6 are unsupported
This page lists the end of life date for each unsupported branch of PHP. If you are using these releases, you are strongly urged to upgrade to a current version, as using older versions may expose you to security vulnerabilities and bugs that have been fixed in more recent versions of PHP.
*reference for PHP 5.6 downgrade from PHP 7
Install add-apt-repository
sudo apt-get install python-software-properties
Add repository for PHP 5
sudo add-apt-repository -y ppa:ondrej/php
Update
sudo apt-get update
Install php5-fpm
sudo apt-get install php5.6-fpm
Move files
sudo mv /usr/bin/php /usr/bin/php7
sudo mv /usr/bin/php5.6 /usr/bin/php
Check PHP version
php -v
Restart Apache
sudo service apache2 restart
Try to use php version switcher: phpbrew.
Supported versions
While this may not answer your problem, but PHP-5 can be installed on ubuntu 14.04 (I have tried on Amazon EC2)
You can use
sudo apt‐get install php5 libapache2‐mod‐php5 php5‐mcrypt
sudo service apache2 restart
This will install 5.5.9 as on 25-Apr-2017.