apache switches from php-fpm to mod_php after update in centos 7.5
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
apache switches from php-fpm to mod_php after update in centos 7.5
Hi,
Ever since I've been using apache with php-fpm, after updating my apache from my centos repositories, mod_php is reenabled by default and another php.conf is created. Any idea how I can disable this behaviour and make apache use php-fpm by default?
Thanks
I'm using Centos 7.5.1804, apache 2.4.6-80, php-fpm 7.1.18.
after updating my apache from my centos repositories,
Just to be clear: did you always use packages from the same repo? I'm asking because 3rd party repos (no matter how well they're Q/A'ed) may have different packaging rules, not recognizing previously installed packages when updating or just not adhering to what one would see as sane replace-on-update rules.
Quote:
Originally Posted by vincix
mod_php is reenabled by default and another php.conf is created.
What do you mean exactly by "another conf is created"? I'm asking because when one builds an RPM using
Code:
%config(noreplace)
or
Code:
%config
in the .spec file governs how configuration files are handled on update: in the first case you get a new configuration file with the ".rpmnew" suffix, in the latter case you get the configuration file replaced but the old one saved with a ".rpmsave" suffix.
Quote:
Originally Posted by vincix
Any idea how I can disable this behaviour and make apache use php-fpm by default?
YUM has a plugin for merging configs on update. (AFAIK YUM doesn't provide triggering external post-update actions like some other package managers do, well, there is a "yum-plugin-universal-hooks" but that's not in the distro or any quality-assured 3rd party repo.) If that doesn't work for you and 0) you work with other automation like ansible, chef, puppet, salt, cfengine or whatever else you could use that, else 1) you could probably trigger a post-update that just patches the offending line using inotify elif 2) maybe run some post-upgrade script as part of your yum update process that just patches the offending line?..
Hi,
Thanks for the reply. I'm using several repos, such as elrepo, epel, or remi-php (for version 7), but when I run yum list httpd, I get only the httpd package from the base repository (version 2.4.6-80, which is the version I have currently installed).
First of I all I think it's important to note that this happened after upgrading from Centos 7.4 to Centos 7.5
One mistake that I've made regarding the apache configuration was that I renamed php.conf to php.conf~. So yum/rpm created a new configuration, because it thought there was no configuration there. I know I shouldn't have renamed the config, because this line:
is part of IfModule mod_php7.c block. Which means that apache isn't actually making use of this config, as far as how it should interpret php code is concerned (i.e. using mod_php or php-fpm).
I'm not sure if the fact that I renamed the config triggered yum/httpd rpm package to enable mod_php again. I doubt that.
I noticed this change because all of a sudden nextcloud wouldn't work - instead of interpreting php, it would show text. But now that I think about it, the fact that it recreated php.conf and enable mod_php shouldn't have altered my setup. It should have simply switch to mod_php. There might be a slight possibility that I don't remember what I did and that I had tried switching to mod_php before the upgrade (I find it unnecessary to use php-fpm given how little traffic goes through my server). Nonetheless, it still doesn't really explain why it didn't work like that. I might have missed something basic.
I updated Centos again (actually the update is automatic), that is to say, Apache and mod_php is again reënabled.
php.conf exists in /etc/httpd/conf.d, but, as I previously suggested (I think), given that there is a "<IfModule mod_php7.c>" condition in the configuration, it shouldn't make any difference, as long as the right modules are enabled - i.e. proxy, proxy_fcgi and so on.
So I don't see any problems with the existence of php.conf per se, but I see a problem with the fact that apache automatically reënables mod_php.
What I also don't understand is that mpm_event also remained enabled. I thought mod_php and mpm_event couldn't coexist, because mod_php presupposed forking for apache. Moreover, as it is, apache isn't able to interpret php. I expected it to work, even if it switched to mod_php.
Could the reason be that it ended up in this aberrant situation where mpm_event and mod_php are both enabled?
I couldn't fix it again manually, but I'm trying to understand what is going on exactly. The reason why I stopped insisting last time was because I wasn't sure if this scenario actually happened as I had previously described it. Now I'm certain of it.
yum history info httpd says that httpd was last updated on 22 May. yum history info php says that php was updated on 25 June. So I think it might be related to the php package rather than httpd.
First of all, I'm not sure if, when enabling php7-zts (of which only now I'm hearing and which is a so-called 'thread-safe module'), apachectl -M will simply show php7_module or would clearly specify "zts".
This php (7.1) comes from the remi repo. Centos 7 still uses php 5 by default, so that's why I needed to install the remi repository.
I'm guessing that this time the file won't be overwritten when the php package is updated, as it will see that it exists, so the comment should remain. Even so, I don't understand why zts wouldn't work by default, even if stopped using php-fpm. In /etc/httpd/modules there is a libphp7-zts.so, so that shouldn't be a problem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.