Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AbdulBazith's avatar

php version problem when deploying laravel project

Guys i need to deploy a laravel project in cpanel.

i deployed. but i got error http error 500

i found many solutions and at lasti found that php version is the problem.

when i am developing the project in local i used php 5.6.4 version

"require": {
        "php": ">=5.6.4",


now i deployed the project.

my cpanel php version is 5.4.

so i changed the version 5.4 to 7.2 in my cpanel. my apllication started working in live.

but other project which are hosted got error because those projects are developed with php 5.4 version.

so for those project it showing error.

Call to undefined function mysql_connect()

this error is because of in php 7 it is changed to mysqli_connect.

but i cant change all the projects.

if i change the cpanel php version to 5.6. all other projects running correctly, but my laravel showing error

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)

syntax error, unexpected ':', expecting ';' or '{'

what can i do?? can i reduce my laravel application to lower version of php?? is it possible??

the main problem is if my cpanel php version is 7 and above my laravel works correctly, but other projects not.

if i change my php version in cpanel to 5.4 all other works correct but my laravel shows error http error 500

ig i change my php version in cpanel to 5.6 all other works correctly but my laravel shows error Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN) syntax error, unexpected ':', expecting ';' or '{'

now what should i do??

i think better to reduce my laravel php version.

but how, will it affect any functionality of the application??

Kondly suggest you ideas please

0 likes
9 replies
Snapey's avatar
Snapey
Best Answer
Level 122

You should not consider doing anything with 5.x.x - certainly not adding any new sites.

Even php 7.0 is end of life

Put your application on a new server with php 7.2

Start projects to move or take down all 5.x sites as they are no longer considered secure and definately not supported

AbdulBazith's avatar

@snapey thank you so much for you response..

ya i understood. hereafter the applications which we develop will be php 7.

but now there are few projects which have php 5.4..

i cant remove that.

just now i checked my laravel applciation php version in cmdprmpt.

by giving /projectdirectory/$ php -v

it shows

PHP 7.2.6 (cli) (built: May 23 2018 20:51:04) ( ZTS MSVC15 (Visual C++ 2017) x86
 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies


now what should i do??

is there any solution to deploy my project??

diegoaurino's avatar

Hello, @abdulbazith ! Does your server allow you to add "AddHandler" to your .htaccess? If so, you can change the PHP version there.

Snapey's avatar

when i am developing the project in local i used php 5.6.4 version

"require": {
        "php": ">=5.6.4",

no you didn't. You told composer that php must be greater or equal to 5.6.4 - which 7.2 is !

Snapey's avatar

If these were genuinely different projects then you would have a cpanel for each project and can set the PHP version individually on each project.

This is not going to work if you just put all the 'projects' on the same web server instance.

Nash's avatar

A little off topic but since you mentioned cPanel and multiple projects, I just want to make sure that you are not on shared hosting and uploading all your projects directly under public_html? Because that would leave your .env file (and all other application files) exposed.

AbdulBazith's avatar

@snapey thank you so much for your response. ya you are right i have given the composer greater than. i ididnt notice that.

as per your solution i changed my other projects too in 7.2 version.

that worked fine..

AbdulBazith's avatar

@diegoaurino thank you so much for you response.

i changed my cpanel to version 7.2.

its better to have that.

AbdulBazith's avatar

@nash thank you so much for your response,

how to make safe the .env file??

is there any way??

Please or to participate in this conversation.