Change the PHP version for Plesk to PHP 7 - php

I'm running Plesk Version 17.0.17 Update #16 on Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux
My problem is that I cant figure out how to update the global PHP version to 7.1 through Plesk
I need to do this as it is required by a package I am trying to install with Composer.
I cannot remove it because it says that "Plesk is using the old version to run" and I cant seem to change the version that Plesk uses. I can only set it for individual websites and I'm not interested in running more than one PHP version.
I have already installed the new version and I am able to run it when I create a symbolic link like this:
ln -s /opt/plesk/php/7.1/bin/php /usr/bin/php
When I do this everything works fine and the problem only occurs when Plesk updates it and overwrites the path causing me to have to do it again.
I cant just remove the old version through Plesk as it says it conflicts with Plesk itself as it uses it to run.
Summary:
I want Plesk to run PHP version 7.1 and remove the old version completely.
How can I do this?

Use this:
apt-get update; apt-get install php{X};
where {X} = version ex. 5
For PHP 5.5, PHP 5.6 and PHP 7.0:
apt-get update; apt-get install php{X};
Then update the package lists and perform the upgrade:
sudo apt-get update

Well you should make sure that no website is using the old php version. After that you should be able to remove the old php version from Plesk. You should not have to create a symbolic link manually. That can cause problems with Plesk.

Maybe better to said composer use specific PHP binary?
For example you can just add the following line into the .bashrc file from your user folder:
export PATH=/opt/plesk/php/7.1/bin:$PATH
Or
echo 'PATH=/opt/plesk/php/7.1/bin:$PATH' >> ~/.bashrc
To verify you have to relogin/recreate bash session and check $PATH variable:
echo $PATH
/opt/plesk/php/7.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Related

How to install and use PHP on macOS via brew

it seems like a little bit stupid question, but Google for one hour and cannot find it:
How to install php on macOS via brew and use in in shell.
Install is simple (if you have brew already installed):
brew install php
But after installation, when i use php -v i still see default php on mac os and not the brew's one. Shoud I Add brew php binary into PATH, bash profile, or what?
Thank you!
homebrew creates symbolic links in /usr/local/bin to pretty much every binary it installs. So the answer to your question is to add that to your path in your login profile. That will probably be $HOME/.profile and you can add a line like:
export PATH=/usr/local/bin:$PATH
Then it will be set each time you login or open a new Terminal.
So in my case, the trouble was with some access permissions on specific folders on my Mac OS, so just sharing what I learned: if it's not working, carefully examile log / error feed, there can be a hint for you!
On April 1, 2018 Homebrew discontinued the Homebrew/php tap and went with a core install approach, which means many of the extensions now must be installed with PECL. I have written a two part blog series to help with installing Apache and PHP w/ PECL on later versions of MacOS. You can find it at the link below, I hope it helps!
https://medium.com/#crmcmullen/how-to-install-php-on-macos-10-13-high-sierra-and-10-14-mojave-using-homebrew-and-pecl-ef2276db3d62
Step 1: Install Homebrew
The first step is to install Homebrew and this is a tool (package manager for macOS) that will allow us to install easily PHP and basically any other package/tools.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install PHP
To install PHP we can use the command below. The first command will automatically install the latest version of PHP which is at the current moment of writing this post version 8.
brew install php
If other versions may be preferred we can specify the PHP version and the code will look like the following.
brew install php#7.4
Step 3: The php.ini Config
The default PHP configuration should be sufficient to get started but if there are any other configurations, we can change them through the php.ini located on this path. Do note the PHP version number which in this case is version 8.
/usr/local/etc/php/8.1/php.ini
Step 4: Check if PHP is running
To check if PHP is already running we can make use of the brew services command. First, we can list the services that we have installed.
brew services list
If PHP is not started we can then run the command below to start the service in the background.
brew services start php#8.1
Step 5: Checking PHP Version
Lastly to check the PHP version do run:
php -v
By now you will have PHP running on the background process and every time you logged in to the system it will start by default. Thanks for reading and have a good try.

Deleting PHP7.2.7 in ubuntu

I want to delete PHP 7.2.7 in ubuntu I used:
apt-get purge php7.2.*
I get like around 50 I guess from these message:
Note, selecting 'php7.2-sybase' instead of 'php7.2-pdo-dblib'
Package 'libapache2-mod-php7.2' is not installed, so not removed
However when I want to install magento on the server it says at readiness check:
PHP Version Check
Your PHP version is 7.2.7. The required PHP version is 7.0.2|7.0.4|~7.0.6|~7.1.0. Hide detail
Download and install PHP from www.php.net using this PHP Documentation.
For additional assistance, contact your hosting provider.
I deleted it but there were some errors because of file permissions now I changed it. but I think some remaining files stayed behind.
How can I get rid of them?
try to use sudo command:
sudo apt-get purge php7.2.*

Install php 7 on mac with Homebrew

Hi just got a new fresh mac and I want to use the last version of php7.
So I have instal php 7.1 with homebrew successfully. But the php -v command show that I have the 5.6 version witch is the default version installed on mac.
How can I target the new version of php installed with homebrew.
I have followed this tutorial to do it : https://developerjack.com/blog/2016/installing-php71-with-homebrew/
You need to set your PATH environment variable to have /usr/local/bin at the start because that is where homebrew puts your installed binaries:
export PATH=/usr/local/bin:$PATH
Put that in your login profile too, so it works on future logins.
You may also need to rehash with:
hash -r
which causes your shell to forget where commands are, so it has to search afresh.

PHP 7.0 installed, but version doesn't change

I'm trying to install PHP 7.0, which works. But when I check my php -v in the cmd, it still says 5.5.36.
I tried it via php-liip, homebrew, install manually and via cmd. Nothing works. When I change version of PHP in MAMP (which I work with to try and install composer in a directory, that I need PHP 5.6 or higher for) i still doesn't matter.
The PHP 5.5 you're seeing was installed by Apple and is a default on your computer. It was installed at /usr/bin/php.
All of the installers you've used will not overwrite Apple's default installation - they will instead opt to create their own directories or use /usr/local/bin/ instead (thus the PHP interrupter would be installed at /usr/local/bin/php). In other words, you almost certainly have multiple php's ready to use right now. The next thing you need to do is tell bash (the default terminal/cmd on a Mac) to use the newly installed PHP interrupter.
When you run $ php on your command line, bash checks for an executable file on each of paths stored in the PATH environment variable. Once it finds one, it decides that that executable is the one you're looking for and runs that program. As of now, it's finding Apple's PHP 5.5 before it finds your fresh install of PHP 7.0 - assuming it finds PHP 7.0 at all.
You can fix this by updating PATH to check wherever PHP 7 is installed first. Instructions to do so can be found on SuperUser.StackExchange:
How should I set the PATH variable on my Mac so the Homebrew-installed tools are found?
To change php version in Ubuntu, try to use this comand
sudo update-alternatives --config php
and then select version what you need

Composer use MAMP PHP Version

I'm trying to install a package via Composer that requires PHP 5.6.0. My MAC is running PHP 5.5.31 but MAMP runs PHP 7.0. The package will not download because of the PHP requirement is not met since it's looking at my macOS version, not the version I actually use with MAMP. How can I get around this?
MAMP's PHP is located here:
/Applications/MAMP/bin/php/php7x.x/bin/
The default OSX PHP is located in
/usr/bin/php
/usr/bin is in PATH variable by default.
When you want OSX to use the MAMP version instead, you need to add /Applications/MAMP/bin/php/php7.x.x/bin/ to your PATH variable.
Simply edit ~/.bash_profile in your terminal and type
vim ~/.bash_profile
if you cannot find ~/.bash_profile then you have to create one with
touch ~/.bash_profile
and add the following line to end of the file:
export PATH=/Applications/MAMP/bin/php/php7.x.x/bin/:$PATH
You just have to look at the correct version of your MAMP's php and replace the x.x from the example above with that correct number. (e.g. 7.0.2)
If that went fine, relaunch your terminal.app and do php -vagain. Now you have to see the new version.
After that try to install the composer package again! Good luck
Help source: how-to-override-the-path-of-php-to-use-the-mamp-path
This was easy to me:
First backup system php sudo mv /usr/bin/php /usr/bin/~php
Then crate a symbolic link from /Applications/MAMP/bin/php/phpX.x.x/bin/php to /usr/bin/php using this: sudo ln -s /Applications/MAMP/bin/php/phpX.x.x/bin/php /usr/bin/php. Now you have your mamp php (with its config) available everywhere.
If you type 'which php' into Terminal it'll show you where it's looking for PHP. I'm guessing there are 2 different versions of PHP installed into different directories. In which case you might be able to use a bash script to set the correct path to the PHP version you want?
I've had similar issues on my Mac where I've installed software like git, but it's looking elsewhere for it (e.g. the version bundled with Xcode)

Categories