Base System: Ubuntu16.4; Bundled with a bitnami Wordpress installation
Goal:
Properly install PHP7.4
Status
Behaviour of the system after apt-get install php7.4:
find / -name php7* => all Files I find are 7.4-related (their name includes php7.4)
sudo a2enmod php7* => reports errors for any version except for php7.4
sudo /usr/bin/php7.4 -v => PHP 7.0.30 (cli) (built: May 11 2018 16:56:24) ( ...
BUT
php -v => PHP 7.0.30 (cli) (built: May 11 2018 16:56:24)...
Wordpress-Plugin to display version => Running PHP version: 7.0.30
How is this even possible? O_o
Bitnami Engineer here,
We do not provide WordPress deployments with PHP 7.4 but you can follow these steps to achieve it:
Launch a new instance in LightSail with LAMP 7.3 (do not worry, we will remove its content and install LAMP 7.4). Please note that you will install a Bitnami stack so the 512MB or 1GB of RAM instance types will probably have problems during the installation.
Install LAMP 7.4 in your instance (this will remove the LAMP 7.3 data as well)
cd /tmp
sudo /opt/bitnami/ctlscript.sh stop
sudo rm -rf /opt/bitnami
wget "https://downloads.bitnami.com/files/stacks/lampstack/7.4.7-0/bitnami-lampstack-7.4.7-0-linux-x64-installer.run
chmod +x ./bitnami-lampstack-7.4.7-0-linux-x64-installer.run
sudo ./bitnami-lampstack-7.4.7-0-linux-x64-installer.run --prefix /opt/bitnami
Deploy WordPress following the steps explained in this other Stack Overflow post
and then migrate the data from one installation to the other one using the All in One WordPress Migration plugin.
Once you confirm everything works as expected, you can stop your previous instance of WordPress.
Happy to help!
Related
I have a requirement where I need to update the PHP and PHP-fpm to the latest version of the server. this server is hosted using Nginx and WordPress. We are using amazon Linux 2 when I disable php7.4 and enable php8 in amazon-Linux-extras and install I'm getting an error.
php error
I have a couple of questions:
what happens when I uninstall and install PHP to the latest version does it after the site?
Do we have any workaround for this PHP error?
Thanks in advance.
I'm expecting a solution to update my PHP to the latest version without any issues. I have just started learning DevOps. I'm not familiar with these errors
I removed php-json by sudo yum remove php-json and installed of php
sudo yum install php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip}
Still the application works.
php-json is available in Amazon Linux Extra topic "php7.4"
$ sudo amazon-linux-extras install php7.4
So I'm using AWS with bitnami using a linux terminal for my php application. But I need to switch my PHP version from 7.2 to 5.6, and I can't figure out how. I've never used Linux so I'm having trouble, can anyone help?
I've tried this link: https://tecadmin.net/switch-between-multiple-php-version-on-ubuntu/
unfortunately none of those commands worked
If anyone is able to help I'd appreciate it very much!
Thank you!
Bitnami deployments don't support multiple versions of the same component. You will need to install a different stack, in this case the LAMP 5.6 stack (which is not supported anymore) and deploy your PHP code on top of it as you did in the instance you have.
You can download the last version of the Bitnami LAMP solution by running these commands
cd /tmp
curl -LO "https://downloads.bitnami.com/files/stacks/lampstack/5.6.40-1/bitnami-lampstack-5.6.40-1-linux-x64-installer.run
chmod +x ./bitnami-lampstack-5.6.40-1-linux-x64-installer.run
sudo ./bitnami-lampstack-5.6.40-1-linux-x64-installer.run
This new installation will use different ports to configure Apache, MySQL, ... if you have another Bitnami installation in the instance. If you want to use the default ports, just stop the default installation.
sudo /opt/bitnami/ctlscript.sh stop
sudo mv /opt/bitnami /opt/bitnami.back
First of all you need to install the version of PHP you need so you can run these commands :
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install phpx.x (ex : php7.4)
Then to switch between versions run this :
update-alternatives --config php
now you'll get to choose you desired PHP version
Backup your current website.
Deploy a new Bitnami WordPress instance.
Update your DNS records.
Install a SSL certificate on new Bitnami WordPress Instance.
Modify the php.ini file to increase upload size.
Import backed up the website on a new Bitnami WordPress website.
OK so I am experiencing something quite odd. My phpinfo() shows one version while php -v shows another.
I am running locally on a MacBook Air (Mojave), with Laravel and Valet.
phpinfo():
PHP Version 7.2.13
Configuration File (php.ini) Path /usr/local/etc/php/7.2
Loaded Configuration File /usr/local/etc/php/7.2/php.ini
Scan this dir for additional .ini files /usr/local/etc/php/7.2/conf.d
While in my terminal, it shows:
php -v
PHP 7.3.0 (cli) (built: Dec 7 2018 11:00:11) ( NTS )
Now, if I do a which php I get this:
/usr/local/bin/php
In my ~/.bash-profile, I have this:
export "PATH=~/.composer/vendor/bin:$PATH"
I have tried to:
Restart Nginx
Restart Valet
Unlink PHP#7.2 and link PHP#7.3with Homebrew:
Olivers-MacBook-Air:~ oliverbusk$ brew unlink php#7.2
Error: No such keg: /usr/local/Cellar/php#7.2
How can I get my actual valet site to use php#7.3?
Below simple fix worked for me.
rm ~/.config/valet/valet.sock
valet restart
In my case it worked after forcing the specific PHP version:
valet use php#7.4 --force
Good news, please upgrade to latest valet version, you can easily switch php version.
Source: https://laravel.com/docs/5.8/valet
PHP Versions
Valet allows you to switch PHP versions using the valet use php#version command. Valet will install the specified PHP version via Brew if it is not already installed:
valet use php#7.2
valet use php //without any specification, it will be using latest version
Something so basic as rebooting my Macbook solved this issue. Once rebooted, the correct version 7.3 showed in my phpinfo();
From MacBook pro (Mojave), with Laravel and Valet:
valet use php#7.2
To be able to effectively change the version of php on my machine I use the following script:
Add to your user's .bash_profile
Then use the following command to switch
switch-php7.x
switch-php() {
valet stop
brew unlink php#7.2 php#7.3 php#7.4
brew link --force --overwrite php#$1
brew services restart php#$1
composer global update
rm -f ~/.config/valet/valet.sock
valet install
}
https://gist.github.com/r1tt3r/e0f199eb274d5ff186b73956af594316
I am running linux valet on Ubuntu 20.04 , The following command works for me
valet use 8.0
Here, 8.0 refers to the php version.
NB: Tested this solution on Ubuntu 20.04 Desktop
If you are using Valet Linux Plus(Has more features than Valet Linux) Just do valet use {your PHP version} --update-cli. For instance to use php8.0 just run:
valet use 8.0 --update-cli
This will update both php-fpm version plus php-cli version too.
Basically the php valet uses and the one used by your macbook is different.
But as already mentioned by #Shiro and #Israel Alexis Palma Quezada, in newer versions valet use php73 would solve your problem.
If it's not working, try running composer global update to update your global packages, thus updating valet
To update the mac php version, execute the following lines:
export PATH="your/path/to/php#7.3/bin:$PATH"
export PATH="your/path/to/php#7.3/sbin:$PATH"
or simply add these two lines to your ~/.profile or ~/.bash_profile
Don't forget to run source ~/.profile or source ~/.bash_profile or whatever file you chose to edit.
Yesterday I encountered the same problem on Ubuntu 18.
At first I changed the PHP version:
$ sudo a2dismod php7.2
$ sudo a2enmod php7.3
$ sudo update-alternatives --set php /usr/bin/7.3
But valet was still showing the wrong PHP version. Rebooting did not work. In fact, phpinfo() was displaying PHP 7.1.
After run ps -aux | grep php I noticed few instances of php-fpm (5.6, 7.1 and 7.2) running.
I stopped them
$ sudo service php5.6-fpm stop
$ sudo service php7.1-fpm stop
$ sudo service php7.2-fpm stop
Then started 7.3
$ sudo service php7.3-fpm start
And now my phpinfo() display the correct version of PHP
I ran into this same problem while using valet plus today. When I switched PHP versions it was showing the previous one in my browser but the correct one in my terminal. Looking at the my brew services list:
brew services list
It showed that one of the valet-php services (valet-php#7.2) was not in the service list but somehow my valet was able to switch to it. Valet didn't install this PHP properly and that's what was causing the issue. I did the following to uninstall that PHP and reinstall it with brew.
brew uninstall valet-php#7.2
sudo rm -rf /usr/local/Cellar/valet-php#7.2/7.2.34_1
brew install valet-php#7.2
The PHP version that was once not showing in the brew services list now showed and I was able to "stop" that php version's service:
brew services stop valet-php#7.2
which made everything work properly again without a restart.
I have installed ubuntu/trusty64 using vagrant on my windows pc. I have installed all the required package for php development environment.
Now problem is while I check php version on browser it's showing different from terminal.
From application browser showing :
PHP Version 5.5.9-1ubuntu4.20
Terminal showing:
PHP 5.6.27-1+deb.sury.org~trusty+1 (cli)
Why different version showing on my application?
Please let me know how can I sync up application with php 5.6.27 ?
//php 7.0 to php 7.2 switcher
sudo a2dismod php7.0
sudo a2enmod php7.2
sudo systemctl restart apache2
sudo ln -sfn /usr/bin/php7.2 /etc/alternatives/php
If I understood your question correctly, then the difference between your terminal and the application is the PHP source that they are getting the information from. If you had installed PHP apart from your application, that's why is showing different versions.
To change this (for example that you want to have only the PHP that your terminal is displaying:PHP 5.6.27-1+deb.sury.org~trusty+1 (cli), then change the pointer from your application to point to the directory where PHP 5.6 is installed (For Ubuntu: /usr/share/php5).
I just installed php 5.6 on a test box, and the normal cli php interpreter doesn't appear to exist:
$ -> php -v
-bash: php: command not found
$ -> php56 -v
PHP 5.6.13 (cli) (built: Sep 3 2015 13:41:04)
If I try to do a yum install php --enablerepo=remi then it tries to install php 5.4.
So it's obvious that php56 is a cli interpreter, but I've always been used to just typing php vs php56. Is this the new norm, or is there another step for installing php56 on CentOS (6.7)? Is it as simple as creating a symlink? ln -s /usr/bin/php56 /usr/bin/php
Steps to upgrade:
$ -> yum remove php* --enablerepo=remi
$ -> yum install php56* --enablerepo=remi
Thx to Remi for the push in the right direction, here's what my repo config looks like:
[upstream_remi54]
name=Remi - CentOS - $releasever/$arch
baseurl=http://mirrors.mediatemple.net/remi/enterprise/$releasever/remi/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://rpms.famillecollet.com/RPM-GPG-KEY-remi
[upstream_remi56]
name=Remi - CentOS - $releasever/$arch
baseurl=http://mirrors.mediatemple.net/remi/enterprise/$releasever/php56/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://rpms.famillecollet.com/RPM-GPG-KEY-remi
This works well if you want to completely replace existing PHP, vs running versions in parallel. I have to keep PHP 5.4 in place for Roundcube and Postfix Admin, as some of the modules necessary for those to work have not yet been ported, so that server has to stay 5.4 for now.
php-* are base packages, 1 repository per version
"remi" => php 5.4
"remi-php55" => php 5.5
"remi-php56" => php 5.6
"remi-php70" => php 7.0 (Release Candidate, not ready for prod)
php56-* packages are Software Collections, parallel installation allowing to run multiple versions of PHP.
See : http://blog.remirepo.net/pages/English-FAQ
So, if you only want a single php version 5.6
yum --enablerepo=remi-php56 install php-cli (and other needed modules)
And you can also enable the repository for future update (as the "remi-php56" is safe and only provides php 5.6 and its extension)
yum-config-manager --enable remi-php56