Install php 5.4 on Ubuntu 16.04 Xenial - php

I want to install php5.4 on Ubuntu 16.04 (Xenial). I know it's obsolete but I came across an old application which I need test before updating the code to be compatible on php7.
When I do the following:
apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo apt-get update
sudo apt-get install -y php5
and check with php -v, it shows php5.6 installed.
This is the output from php -v:
PHP 5.6.28-1+deb.sury.org~xenial+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.5.0rc1, Copyright (c) 2002-2016, by Derick Rethans
(Steps followed as at http://tecadmin.net/install-php5-on-ubuntu/)
Is there a way I can force php5.4 to be installed instead of letting it chose whatever php5 package it finds?
I have tried with apt-get install -y php5.4 but that does not work.
Edit: Since the app was going to be used for a long time, I decided to change the whole application to php7-ready code instead. If anyone else wants to do this, be careful to test the application on different browsers and also on the OS you will be hosting the application (very important!). Took me some time but I guess it's worth it in the long run! Thanks for your help!

**EDIT:**Scratch My suggestion below. It doesn't declare the Ubu image in the Vagrantfile. Oops. Like I said, I'm a wee bit wet under the wings in all things *nix.
I'll still leave just in case it causes you to think of something.
If you run vagrant, you might be able to swap Trusty for Xeny in the scotch.io box Vagrantfile (github link) and spin it up. It's still on PHP 5.6. I've only been on linux for a month or so, so not sure how universal Vagrantfile scripts are across Ubu versions. I'm running Trusty in Azure and Xeny in Vultr and locally on desktop and laptop and haven't seen any big differences regarding web dev stuff.
https://box.scotch.io/
https://github.com/scotch-io/scotch-box
git clone https://github.com/scotch-io/scotch-box.git my-project
Features
Server Stuff
Ubuntu 14.04 LTS (Trusty Tahr)
PHP 5.6
Ruby 2.2.x
Vim
Git
cURL
GD and Imagick
Composer
Beanstalkd
Node
NPM
Mcrypt
Database Stuff
MySQL
PostreSQL
SQLite
MongoDB
Caching Stuff
Redis
Memcache and Memcached
Node Stuff
Grunt
Bower
Yeoman
Gulp
Browsersync
PM2
Laravel Stuff
Laravel Installer
Laravel Envoy
Blackfire Profiler
Mailcatcher
First: `vagrant ssh`
Run: `mailcatcher --http-ip=0.0.0.0`
Then visit: http://192.168.33.10:1080
Other Useful Stuff
WP-CLI
No Internet connection required
PHP Errors turned on
No Internet connection required
Laravel and WordPress ready
Operating System agnostic

Related

POPOS: How to revert PHP to 8.0

I use PopOs for work. PopOs has released version 22.4 but it comes with PHP 8.1 and our development project (Laravel) uses php_cs_fixer and it currently only supports PHP 8.0. I was tasked to test if we should upgrade to PopOs 22.4 yesterday. I tested phpbrew and homebrew. Neither of them worked well. phpbrew doesn't work once I upgrade to PHP 8.1 (it has a single deprecated function in it, everywhere). Homebrew didn't seem to work and recommended editing the apache2 httpd.conf file, but our project isn't using Apache. I currently have PHP 8.0 installed (found at /usr/bin/php8.0) but the cli still says I'm using PHP 8.1.7. I used update-alternatives --set php /usr/bin/php8.0 to try and change the version the cli is using but that doesn't seem to work although when I when I execute update-alternatives --display php it reports that my link is pointing to /usr/bin/php8.0. Yet, php -v returns:
PHP 8.1.7 (cli) (built: Jun 7 2022 18:21:38) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.7, Copyright (c) Zend Technologies with Zend OPcache v8.1.7, Copyright (c), by Zend Technologies
I'm desperate, this is my work computer and I need to get this working. How does one literally revert from PHP 8.1 back down to version 8.0?
You can uninstall the php 8.1 directly through the terminal.
sudo apt remove php8.1
sudo apt autoremove
Hope this help you.

Class Memcached Not Found Lumen 5.4

When trying to run artisan commands I get the following error
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Memcached' not found
I had recently been been working on another project that used Lumen 5.3 and had no problem running artisan commands. Both projects are on the same virtual box and apart from the Lumen versions there is no differences in server setup.
I've checked that Memcached is running and there is no problems.
I've tried composer dump-autoload, deleting the vendor folder and re-installing but none of these have made a difference.
I'd prefer not to have to go back to 5.3 if possible.
Is there a way to solve this issue?
Had the same problem.
Check if you have the memcached extension installed for the php version that you're using, and check also if it is correctly configured in the php.ini file (it could be looking in the wrong directory).
looks like your memcahed is not installed or not properly configured.
for quick solution ,
use file cache driver instead of memcached
CACHE_DRIVER=file
Ubuntu 16.04 LTS, try this:
sudo apt-get install php-memcached
Just to add to the os specific responses. Here is the one using OS/X and homebrew.
First you have to determine which version of PHP you're using locally.
$ php -v
PHP 7.0.19 (cli) (built: May 21 2017 11:56:11) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
$ brew search memcached
homebrew/php/php53-memcached homebrew/php/php70-memcached
homebrew/php/php54-memcached homebrew/php/php71-memcached
homebrew/php/php55-memcached libmemcached ✔
homebrew/php/php56-memcached memcached ✔
Since I'm running PHP 7.0 I chose to install homebrew/php/php70-memcached
$ brew install homebrew/php/php70-memcached
If you don't have homebrew installed go to https://brew.sh/ and install it to use these instructions. This was the command last time I used it.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Once I was done with all that then I tested by clearing the cache.
$ php artisan cache:clear
Cache cleared successfully.
$
Cheers, this fixed it for me for local development.
If you are on Mac OSX, you will need to install Memcached and its PHP dependencies via Homebrew.
brew update
brew doctor
brew install memcached
Then check your PHP version and install your relevant PHP hooks for Memcached.
php -v
in my case...
PHP 7.1.4 (cli) (built: Apr 14 2017 15:02:16) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
So I used:
brew install php71-memcached
But you can lookup your required version using
brew search memcached
Once you have performed these steps you will probably get a new error
No Memcached servers added.
So fire it up with
brew services restart memcached
Done!

failed to install php-integrator-base package in atom editor

I am new on this editor and I would like to try it for php project.
I am trying to configure this package php-integrator-base in my atom ide, but I have this error:
The socket connection with the PHP server could not be established.
This means the PHP server could not be spawned. This is most likely an
issue with your setup, such as your PHP binary not being found, an
extension missing on your system, ...
This is my setup for this package:
This my php verion on my ubuntu distrib:
Anyone else have the same issue with this package ? Where am I wrong ?
EDIT
Since I have make the update of the package today I always have the same error but another one occured.
Indeed, an error message appears to notice that:
Core installed failed
When I start the atom editor I have this message too:
If you are on Unix system then go to :
cd $HOME/.atom/packages/php-integrator-base/core/
then you should have a directory with num version as name like 2.X.X. So :
cd 2.1.0 and ../composer.phar install
I am relevantly new to this IDE as well and had errors with installation of php-integrator-base. I am using Windows and it turned out that it was an issue with my environmental path. Try the following steps:
Add your Git binary path to your environmental path
Enable sqlite on your php.ini file by adding these: extension=php_sqlite3.dll and extension=php_pdo_sqlite.dll
If above steps do not work, try posting an issue at their GitHub repo.
There is a better solution, which solves this "identified" issue and others only visible when running Atom in --dev mode.
Sadly nobody ever pointed to the fact (or noticed) this issue is caused by packages differences in between PHP 7.0 and PHP 7.1. For some reason, for PHP 7.1 some packages still reference items related to PHP5.6, while some other packages are expecting everything to be PHP 7.x related.
The solution is to upgrade the PHP 7.0x to PHP 7.1.
In Ubuntu environments you can do that by running these commands:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt remove php7.0 (optional, only if you want to uninstall PHP7.0)
sudo apt install php7.1
Simply restart Apache by running:
sudo service apache2 restart
Then check your PHP version to confirm it has been upgraded:
php -v
You should get an output like this:
PHP 7.1.8-2+ubuntu16.04.1+deb.sury.org+4 (cli) (built: Aug 4 2017 13:04:12) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.8-2+ubuntu16.04.1+deb.sury.org+4, Copyright
(c) 1999-2017, by Zend Technologies
You may have to re-enable some extensions after upgrading to PHP 7.1. Atom may complain about these in specific (mbString, SQLite and DOM). Simply run these commands to install/activate them:
sudo apt install php7.1-mbstring
sudo apt install php7.1-sqlite
sudo apt install php7.1-xml
Don't forget to reactivate your old extensions as well (if any). For PHP 7.1 in most cases it is the same "command" just changing "php7" (or "php") to "php7.1".
Once you are done with PHP, navigate to Atom's PHP Integrator folder and check if the folder "3.0.0" exist:
.atom/packages/php-integrator-base/core/3.0.0/
If it doesn't exist go to https://gitlab.com/php-integrator/core/tree/3.0.0, download it and extract the contents of the compressed file in the 3.0.0 folder (you may have to create it):
Then, from inside .atom/packages/php-integrator-base/core/ you run:
composer install
Now, finally, Composer will be able to find the right packages and install all required dependencies.
Simply say "good bye" to the PHP Integrator errors that have been haunting you lately and enjoy your Atom, once again fully functional as it should be.
I hope it helps some fellow friends stop wasting time with lots of proposed solutions that exist online which in reality won't fix the real core of the problem. ;)
Following #Rei suggestion, I make an issue on theri github repo here.
To solve my problem, I follow step by step a manual installation of the package and then use composer inside the package itself to install the core folder.
If ./composer.phar install fails with a "missing sqlite extension", install php-sqlite extension:
sudo apt-get install php-sqlite3

laravel class memcached not found

First of all , I have looked at all of these :
#1 , #2 , #3
and none of them is my case nor has really a soloution.
The problem is that I am developing a website by laravel 5.3.18 and here is the PHP info running on my server:
PHP 7.0.9-2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.9-2, Copyright (c) 1999-2016, by Zend Technologies
And also here is my server OS info if you need to take a look at:
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux stable-updates (sid)
Release: stable-updates
Codename: sid
I need to change CACHE_DRIVER to memcached in order to use this package(according to what they say in the GitHub issues about fixing the found bug).
Here is where all my problems started.
I have thses memcahed packages installed on my server(listed by dpkg --list):
I see everyone is talking avout installing php5-memcached but shockingly when I try to install php5-memcached I get this:
and tha's after running sudo apt-get update!
I even get this after entering sudo service memcached status:
After all of these when I change the CACHE_DRIVER to memcached, it keeps on showing this error:
While I am still struggling with this, Any ideas on this guys? I would be appreciative!
It's possible that the memcached.ini is being copied to the PHP5 module config directory.
Try this:
ln -s /etc/php/mods-available/memcached.ini /etc/php/7.0/fpm/conf.d/20-memcached.ini
You might copy msgpack.ini too:
ln -s /etc/php/mods-available/msgpack.ini /etc/php/7.0/fpm/conf.d/20-msgpack.ini
Class Memcached is also used by php 7 (PHP 7 with memcached)
Check this out - http://pecl.php.net/package/memcached
You may need to also install libmemcached see this - https://launchpad.net/libmemcached/+download
Or see the similar issue on - StackOverflow

Vagrant did not install Apache2 nor php

I just created a configuration file (it's a zip actually) for my vm on puphpet.com, downloaded the zip, extracted it. Then I run vagrant up in the folder where is located the vagrantfile. The vm is correctly setup under virtualbox, it runs well and the shared folders are working.
However when I access my vm from the host, using 127.0.0.1:7893 it displays : SSH-2.0-OpenSSH_6.0p1 Debian-4. Which is weired since I checked both install php and install apache on puphpet.
I decided to verify their existance on the vm : which apache2, whereis php etc.
Nothing was returned.
So appearently php and apache2 have not been installed, even though the config.yaml file (that I created on puphpet) did specify to install both php and apache2.
At this point, I don't really know what to do (I'm new to php/vagrant/puphpet) :
should I install them myself on the vm with apt-get ?
??
EDIT: during the installation process (vagrant up), I get errors like :
Err http://http.us.debian.org/debian/ wheezy/main linux-headers-3.2.0-4-amd64 am
d64 3.2.51-1
404 Not Found [IP: 64.50.233.100 80]
Fetched 238 kB in 1s (167 kB/s)
Failed to fetch http://http.us.debian.org/debian/pool/main/l/linux/linux-headers
-3.2.0-4-common_3.2.51-1_amd64.deb 404 Not Found [IP: 64.50.233.100 80]
EDIT2: I 'solved' the problem by using a differents virtual machine.
EDIT: during the installation process (vagrant up), I get errors like : ....
Check that you packages db in VM is up to date.
just run
sudo apt-get update
and then try again with apache2 and php installation.
I just ran the default config:
[01:26 PM]-[vagrant#packer-virtualbox]-[~]
$ php -v
PHP 5.5.10-1~dotdeb.1 (cli) (built: Mar 6 2014 18:55:59)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
Everything looks to be fine on my end.
A couple of things:
You can access the VM from your browser using the IP address you chose during initial config.
Looks like your main issue is that you couldn't connection to the Debian repos. Are you behind a firewall?
To try again, do:
$ vagrant destroy
$ rm -rf .vagrant
$ vagrant up
I had the same problems when I opted for CentOS.
Where did the choosing Debian, the problems stopped occur.

Categories