Linux Server PHP update roll back - php

I have a dedicated server that hosts a number of websites currently running PHP 5.2. I need to upgrade the PHP version and I have been told I can do this via SSH using this command:
yum upgrade php
No I'm a little concerned about making an update and a website not being able to function any more, so is there a rollback command I can use so that if something does go wrong I can quickly change back to PHP 5.2?
Many thanks

You'd better know what has changes from php 5.2 to php 5.3 first, if you think the changes won't affect you scripts, then upgrade, if not, then stay with php 5.2 or make the necessary changes in your scripts first (Personnaly I do recommand you upgrading to PHP 5.3) , here is the list of changes Migrating from PHP 5.2 to 5.3
If you face some problems after making the upgrade, check the package repository if php 5.2 still exists in it (use the command "yum search php"), if it does then remove the current PHP you got (command "yum remove php") and then install the package you found ( for example : "yum install php-5.2")
Note : If you don't find the PHP 5.2 package in the repository, you may have to compile PHP 5.2 from source.

You can backup the old php version yourself but I cannot recommend this. Usually it's only phpize, php.ini, php.so and the php modules folder. Then you can make the update.

Related

Trying to get icu4c version 64 working with PHP 5.6 on Mac Catalina

I just got handed a big project running Symfony 3.4, and PHP 5.6, that I'm trying to get working on my "new" Mac Catalina (just purchased and installed, not upgraded from a previous macOS version), and I've gotten things working up to a certain point:
our-symfony-3-project $ bin/console server:start
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
Referenced from: /usr/local/opt/php#5.6/bin/php
Reason: image not found
zsh: abort bin/console server:start
I was able to fix a previous similar error with needing openssl 1.0.0 (I had to compile it from source using Homebrew then link it), and I think the solution is the same here, but it appears that I need to find the library or repo or download for icu4c version 64 (not sure I'm reading this right) to get brew extract to install it (it won't any other way), or figure out how to compile it and manually get it working for PHP 5.6, and I'm not finding the library I need apparently.
I've gone through pages and pages and probably a hundred command attempts trying to fix this error... and so far the recommendations have either been outdated (due to macOS/brew changes), or just didn't work.
I'd like to know where I can find the appropriate file/download/repo to just be able to install or compile this through brew or otherwise. PS: I know we shouldn't be using old versions but I just got this job and the company will not upgrade for a while.
I'm answering this by saying that I got the repo to work on a PHP 5.6 host using MAMP Pro (and Apache, not that that's relevant)... which already had the required libraries in question.
I went through the docs on the trial version (version 6.3.2):
https://documentation.mamp.info/en/MAMP-PRO-Mac/Settings/Hosts/General/
However, unlike Homebrew, switching PHP versions across hosts in MAMP Pro doesn't overwrite PHP symlinks like brew unlink and brew link does, I have to still edit my .zshrc file aliases and my PATH to have things like php (or pecl or pear etc) point to the MAMP Pro PHP version folders to get them to work correctly with the repos, as well as with composer (which runs the php command). Even MAMP's documentation says to modify the files yourself...
I can't tell yet if this difficulty is just natural to having multiple hosts with different PHP versions configured, as I could see how multiple variations running at the same time could conflict if they're using the same system files (like /usr/local files)... which sound like system software dependencies, and I don't know that these dependencies could be relegated to their own host folders (like /Applications/MAMP/bin/php/php5.6.40 folders), or maybe I just missed something somewhere. I'll update this answer if I learn better what to do here, or will add another answer if I find a way to do them using Homebrew better.

How to enable SSL extension for Composer?

I am trying to use the PayPal PHP SDK to make an online store, however the documentation tells me I need composer. When I try to install composer I get this error. I have no idea what this means, or how to fix it. What can I do to fix this? I
P.S. There are quite a few questions about this on SO, however, all of them that I have seen ask about using WAMP or something similar. I have no intention of using WAMP, or anything like that. The only thing I am trying to do is install composer properly.
EDIT: I am just using the Composer installer for Windows.
You need PHP installed whether you have a full test environment running or not. If you can't run PHP from the command line Composer stuff doesn't work. With a basic install of PHP the openssl extension is included so that error would go away.
You can install PHP manually on its own, or you could just install WAMP or any of the many others. I use Zend Server myself. It just installs everything for you so that it works without needing to mess with manual installation.
Once PHP in general is installed, though, that should get rid of this error.

good practise to handle composer, shebang and self-compiled php-versions?

I've started a new project in which I like to used the current version of PHP (5.5.12). I compiled this version myself because the version of my distro is 5.3.
I need propel ORM so I installed it via composer.
Now, the propel-script uses this shebang:
#!/usr/bin/env php
which of course calls the main PHP (5.3) and not my self-compiled one. Unfortunately propel needs PHP >= 5.4 and I cannot execute the script without errors.
So my quick-and-dirty solution is to replace the first line in the propel-script with:
#!/opt/php-5.5.12/bin/php
which works, but is not update-safe. At least I think this could be replaced by doing a composer-update.I still need the 5.3-version for other projects, so using an alias is no solution for me.
It's maybe some petty problem, but is there a finer way to combine 3rd-party-libraries via composer with a self-compiled php executable?
I would encourage you to use vagrant and setup a virtual machine environment where php5.5 is installed. You could setup an Ubuntu 14.04 for example, it contains PHP version 5.5.
Developing on your physical machine is sooo yesterday! ;)

How to downgrade PHP version from 5.3 to 5.2 in Ubuntu 12.04?

I have freshly installed Ubuntu 12.04 and I have installed PHP as well. By default, it is installed with version 5.3.10 but my PHP project doesn't support PHP v5.3.10.
I want to downgrade PHP version to 5.2. How can I do it?
You would have to uninstall PHP and then reinstall an older version. However if your working on a project that your going to sell, or give to clients, or whatever the case my suggestion would be take out any functionality thats actually breaking between 5.2x and 5.3x and replace it with its new counter parts, as most people will not want to revert to older versions of PHP for any needs, and generally speaking php versions only goin in one direction, if you block yourself into 5.2 and your making software in one shape or another for people, what are you going to do next year when all the servers come stock with PHP 6? Not to mention a lot of hosted solutions try to provide the latest and greatest on there new machines, and will not revert for a single client especially on a shared hosting environment.
Anyway yea, back to your question again in your terminal under Ubuntu, you can try the following. sudo apt-get purge php5 which will then prompt you for a password, then proceed with removing PHP assuming you have the PHP package standalone and not bundled in with some preconfigured LAMP stack, but then again it should still work generally speaking so long as the version is right.
As for reinstalling it, remove purge from the command and use install. However you will need to look up the means of getting an archived version installed of PHP as apt-get will get you the latest

Upgrade PHP from version 5.2 to 5.3

I've been using PHP version 5.2 and now need to upgrade to version 5.3 (Windows/Apache). I have been using 5.2 for awhile now and have customized many things in php.ini and added some extra extensions.
How can I upgrade to version 5.3 without having to reconfigure everything? Or does upgrading require that I customize my PHP installation all over again?
Thanks, Brian
If you take a look at Upgrading to PHP 5.3 - an easy way, i think that will solve your problem, but if you're in a Linux machine that you can use apt-get the only thing that you need to do is:
$ sudo apt-get upgrade php php-* mysql-*
$ /etc/init.d/httpd restart
Regards.
The transition is not necessarily easy, but not hard also. PHP 5.3 brings some changes to the internal Zend API, so some PHP extension need to be upgraded (I had to upgrade xDebug). That means that you need to find the respective DLLs, which may not be that easy, depending on your current setup.
The config file, php.ini, is pretty much the same. You will actually have to take some things out actually (for example extension=php_pdo.dll is not needed anymore).
Just execute php -m from command line and see what errors are thrown. I have just copy-pasted the php.ini file from a 5.2 release and was done configuring 5.3 in a couple of minutes.
I mentioned xDebug a few lines above. If you use it, you should know that the line which activates xDebug is now:
zend_extension = "path\to\PHP 5.3.0\ext\php_xdebug.dll"
instead of:
zend_extension_ts = "path\to\PHP 5.3.0\ext\php_xdebug.dll"
The main thing I've run into is a mess of new E_DEPRECATED notices when doing anything from PEAR. Like the other comments, you'll want to adjust your error reporting levels appropriately.
Another thing to notice is that if you're upgrading from a package management system like macports or apt, some of the config layouts have changed and you'll have to adapt there.
Other than that, there aren't a lot of functional differences between 5.2 and 5.3.

Categories