N
N
NewSantaClaus2021-08-16 11:40:36
linux
NewSantaClaus, 2021-08-16 11:40:36

How to change the version of php that the webserver is using?

ubuntu server 18.04 nginx

Installed all dependencies via composer
But the application swears that php version is needed >= 7.3

The command php -vshows php 7.4.22
phpinfo()shows 7.2.24 Can

you please tell me how can I change the php version?

Tried:

sudo a2dismod php7.2 ; sudo a2enmod php7.4 ; sudo service apache2 restart


Answer:
Module php7.2 already disabled
Considering dependency mpm_prefork for php7.4:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php7.4:
Module php7.4 already enabled
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.


As you can see, the old version is turned off and the new version is turned on. But Apache won't restart. It is possible that I work through nginx
The command journalctl -xedisplays
Aug 16 08:44:53 my.site sudo[23332]: pam_unix(sudo:session): session closed for user root
Aug 16 08:45:01 my.site CRON[23344]: pam_unix(cron:session): session opened for user root by (uid=0)
Aug 16 08:45:01 my.site CRON[23345]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Aug 16 08:45:01 my.site CRON[23344]: pam_unix(cron:session): session closed for user root
Aug 16 08:45:11 my.site sshd[23347]: Invalid user ubuntu from 111.111.11.111 port 60734
Aug 16 08:45:11 my.site sshd[23347]: pam_unix(sshd:auth): check pass; user unknown
Aug 16 08:45:11 my.sitesshd[23347]: pam_unix(sshd:auth): authentication failure; logname=uid=0 euid=0 tty=ssh ruser=
Aug 16 08:45:13 my.site sshd[23347]: Failed password for invalid user ubuntu from 111.111.11.111 port 60734
ssh2 60734:11: Bye Bye [preauth]
Aug 16 08:45:13 my.site sshd[23347]: Disconnected from invalid user ubuntu 111.111.11.111 port 60734 [preauth]
Aug 16 08:45:22 my.site sshd[23349 ]: Invalid user musikbot from 222.22.22.222 port 58808
Aug 16 08:45:22 my.site sshd[23349]: pam_unix(sshd:auth): check pass; user unknown
Aug 16 08:45:22 my.site sshd[23349]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser=
Aug 16 08:45:24 my.site sshd[23349]: Failed password for invalid user musikbot from 101.32.14.126 port 58808 ssh2
Aug 16 08:45:24 my.site sshd[23349]: Received disconnect from 222.22.22.222 port 58808:11: Bye Bye [preauth]
Aug 16 08:45:24 my.site sshd[23349]: Disconnected from invalid user musikbot 222.22.22.222 port 58808 [preauth]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sand, 2021-08-16
@NewSantaClaus

Nginx does not know how to process php on its own, so it uses an "intermediary" (for example, fastcgi php-fpm). You can view the current "intermediary" through the phpinfo output (Server API field). You can configure the version by specifying the path to the desired socket in the fastcgi_pass directive.

S
Stalker_RED, 2021-08-16
@Stalker_RED

Obviously, you have several versions of php installed at the same time, and the server uses a different version than the one you have in the console.
The php -i command will give you a console analogue of phpinfo, where you can see the path to php.ini . Commands like or , or constant
can also help (in the php console -r "echo PHP_BINARY;") . Most likely they will give out Then in the nginx config, specify the same binary that is used in the cli. whereis phpwhich phpPHP_BINARY

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question