Nginx phpinfo() shows php 7.0.x whereas cli shows php 7.3.x

Hi folks,

I am using homestead_improved to do php development. I see the latest php version (7.3.x) installed when I do php -v on command line. However, when I run phpinfo() from inside a php script in the ‘public’ folder I see the php version being used as 7.0.x.
I see the option of going into /etc/nginx/sites-enables and changing the php version in each app that I have created. But that is cumbersome.
Question is: How do / what do / where do I make changes so that the nginx server uses the latest php version by default?

Much appreciated.

You can always use sed to do a find a replace across all the files.

For example, when the sites have:

proxy_pass unix://var/run/php7.0-fpm.sock

you could run:

cd /etc/nginx/sites-enabled
find . -type f -exec sed 's/php7.0/php7.3/g' {} \;

Which basically means "across all files (-f) in the current directory (.) run (-exec) sed to replace (s/) all (/g) occurrences of php7.0 with php7.3".


Hi @rpkamp, thanks for replying.
I tried that, halted the vm, restarted it and checked; still php 7.1 ( I had said 7.0 by mistake)
Additionally, when I do nano (one of the sites) it says file is not writable!

Also, my nginx.conf is a sym-link to “/home/vagrant/.config/nginx/nginx.conf” … and when I open that, it is completely empty!

I assume you changed php7.0 to php7.1 in the command I posted?

Also, if the files are not writable, you might want to use sudo:

cd /etc/nginx/sites-enabled
sudo find . -type f -exec sed 's/php7.0/php7.3/g' {} \;
1 Like

Yes, I did change the command to ‘s/php7.1/php7.3/g’ … and did use sudo … still, no go.
On one of the sites I read a suggestion to modify “” in the scripts folder. I did that but I can’t seem to execute the .sh script within vagrant/homestead_improved. It says permission denied. If I try with “sudo” it says command not found. If I try to go root with “su” it is asking for the password and I can’t seem to figure out the password.

May I ask you this; I am at the learning stage in php development. nginx is using php 7.1.33. Are there any significant differences / disadvantages to using php 7.1.33 over php 7.3.6? In other words, if I use the setup as is, will I be missing out on something important?

Appreciate your help, especially your explaining the parts of the script.

Oh! Hello! Your hint on using ‘sudo’ to modify the unwritable files did the trick!
I did ‘sudo nano’ and changed the line manually to 7.3.
Is that a good-enough solution?
phpinfo(); is now showing “PHP Version”

Many thanks @rpkamp

AFAIK, there is no comprehensive “7.1 to 7.2” but there are incremental “7.1 to 7.2” and “7.2 to 7.3”

IMHO they’re worth at least a quick scan but rather that trying to “learn” them a better approach is to always develop with full error reporting enabled.


Thanks @Mittineague.
Valuable advice from both of you. Folks at BostonPHP Meetup rate the sitepoint forums highly. I can see why.

1 Like

You might want to keep in mind that 7.1 goes EOL (End Of Life) later in year (Dec 1st 2019). What that basically means is the PHP Group (who create and maintain PHP versions) won’t be offering any support for 7.1 after that date


Thanks @SpacePhoenix for the heads up. I will be sure to check the versions on all apps from now on.

Trying to solve this issue also made me realize I should have some knowledge of shell scripting as well. I do use Linux Mint as my main machine but never bothered to go beyond the basic commands. If I am going to be using Linux VMs to develop, might as well learn to deal with scripts.

Thanks everybody!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.