I have installed fresh copy of lumen 5.6 on my ubuntu machine. I also upgrade my php version from php 5.6.* to 7.2.5. Now php 7.2.5 version is enabled on my system. But when I run the project I receive frollowing exceptoion
Parse error: syntax error, unexpected '?'
/home/example/apis/lumen/vendor/symfony/http-foundation/Response.php
Below is my php version
PHP 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 5 2018 04:59:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.5-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Guide to solve this problem or suggest any usefull link
If you create an info.php file inside your lumen public/ folder and open it on your server
<?php // info.php filename
phpinfo();
there is a good chance it is still referencing php 5.6?
You do not mention if you are serving the project via php -S, apache or nginx.
I am going to presume you are using apache as it mostly the default on Ubuntu. Disable the php 5.6 module for apache and enable the php 7.2 module. Something like the following will work.
Disable php 5
sudo a2dismod php5
Enable php 7.2
sudo a2enmod php7.2
Restart apache
sudo service apache2 restart
Related
I have installed PHP with homebrew, switch to PHP 8.0 but the browser phpinfo() is showing 7.4. I am on the latest version of Monterey.
brew services stop httpd is stopping the apache service.
% php -v
PHP 8.0.19 (cli) (built: May 12 2022 02:25:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.19, Copyright (c) Zend Technologies
with Zend OPcache v8.0.19, Copyright (c), by Zend Technologies
% which php
/opt/homebrew/bin/php
How would I get PHP 8.0 to work in the browser?
in your httpd config, you must hardwire the shipped php version (7.4), with apache, would look like this :
LoadModule php7_module /usr/local/opt/php#7.4/lib/httpd/modules/libphp7.so
Just change the httpd config to load the appropriate lib, and restart your httpd server. Also, php has multiple configs (cli, fpm) : make certain that you tailor the appropriate one in your configs , typically found in /usr/local/etc/php/8.N (monterey, brewed-in php)
I try to install Laravel 8 to vagrant. The install process works without problem. But the homepage shows the following error:
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0". You are running 7.2.34-8+ubuntu18.04.1+deb.sury.org+1. in /home/vagrant/code/7time/vendor/composer/platform_check.php on line 24
When I check the version, it shows 7.3
vagrant#homestead:~/code$ php -version
PHP 7.3.24-3+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct 31 2020 16:59:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.24-3+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
I tried these things:
I searched on Google for solution
I reinstalled PHP
I tried to install Laravel via Laravel installer and via Composer
What might be wrong?
Difference CLI / PHP-FPM
$ php -version gives the PHP CLI version, not the PHP-FPM version.
$ service php7.x-fpm status gives the php-fpm status/version.
CLI:
$ php artisan serve , Runs the application through your cli.
Homestead ( Vagrant box ):
Homestead ( Vagrant box ) is using NGINX by default. This means that the application will use PHP-FPM.
Duplicate of:
Change Laravel Homestead v7.0.1 with php 7.2 to php 7.1
How to roll back PHP version in Vagrant and Homestead?
I'm on Ubuntu 16.04 and I'm trying to install prestashop e-commerce CMS that requires php zip extension to unzip the main CMS folder.
I have installed php-zip and php7.2-zip and I also restarted the web server (apache2) but the CMS still displays the following message
An error has occured:
You must install PHP zip extension first
Here's the result of my installed php zip packages and my current php version:
eljaouhari#eljaouhari-HP-350-G1:/var/www/html$ php -v
PHP 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 5 2018 04:59:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.5-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
eljaouhari#eljaouhari-HP-350-G1:/var/www/html$ apt list --installed | grep php | grep zip
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
php-zip/xenial,xenial,now 1:7.2+60+ubuntu16.04.1+deb.sury.org+1 all [installé]
php7.2-zip/xenial,now 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installé]
I spent an hour and a half trying to figure out whether I need to activate the extestion on the php.ini file and also installing and reinstalling and restarting the web server but nothing seems to work.
I have tried a few solutions on the web that used to work for me but I can't seem to find a good solution.
Please help me with your experience!
I've found the solution after I printed the results of the phpinfo() function.
It seems that the version of php printed with the "php -v" command is not the version that actually apache is using. Apache ended up using the 7.0 version.
Thanks everyone.
When installing Drupal 8, just before database setup, I get a few errors and warnings, but I also see the following:
PHP
7.1.14-1+ubuntu16.04.1+deb.sury.org+1
However, doing php -v I get:
PHP 7.2.2-3+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb 6 2018 16:11:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.2-3+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Clearly, my web server is running 7.2 but Drupal thinks it's 7.1. This is causing a problem where I have gd installed on PHP 7.2, but Drupal doesn't see gd installed on PHP 7.1 (because it isn't, at least its php.ini file doesn't have the gd extension enabled). Same with a few of the other errors and warnings.
How can I get Drupal 8 to recognize the correct PHP version?
So I figured it out:
Runing sudo a2dismod php7.1 then sudo a2enmod php7.2 seems to work perfectly (after a restart of Apache).
Try To install using composer
This method creates a project in web folder and other files outside web folder
composer create-project drupal-composer/drupal-project:8.x-dev d8_test_project --stability dev --no-interaction
Or
This method creates a project in a normal folder structure
composer create-project drupal/drupal my_site_name 8.*#dev --no-dev
I don't think it's about "recognizing" version, but you most likely have 2 different versions, one for console and other for web server. Run phpinfo() and see what PHP version is used by web server.
I am having a problem AFTER installing a newer version of PHP with the Apache web server seeing the new version 5.6.23...it is still using 5.5.9. Where do I tell Apache to use 5.6.23 instead of 5.5.9?
I am running a local web server on Linux Mint 17.1
As reported by phpinfo (both BEFORE installing php 5.6.23 and AFTER)
Apache Version: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.17
Apache API Version: 20120211
PHP Version: 5.5.9-1ubuntu4.17
Configuration File (php.ini) Path: /etc/php5/apache2
Loaded Configuration File: /etc/php5/apache2/php.ini
Scan this dir for additional .ini files: /etc/php5/apache2/conf.d
Noticing that newer versions of PHP are available (such as 5.6.23) but, evidentily not from the default repositories for Linux Mint 17.1, I decided to do the following:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6
After restarting the web server (end even rebooting linux), I executed the following:
php -v
PHP 5.6.23-2+deb.sury.org~trusty+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
I verified the following:
5.5.9 is located here: /etc/php
5.6.23 is located here: /etc/php/5.6
Somewhere setting "Configuration File (php.ini) Path" will do the trick, but I do not know where to do this?
Thanks
Mike