LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-27-2018, 05:40 PM   #1
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
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.
 
Old 06-02-2018, 03:14 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by vincix View Post
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 View Post
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 View Post
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?..
 
Old 06-02-2018, 05:09 PM   #3
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
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:
Code:
<FilesMatch "^\.ph(ar|p|ps|tml)$">
        SetHandler application/x-httpd-php
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.
 
Old 06-04-2018, 05:09 AM   #4
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
I've downloaded and etracted httpd rpm from centos repositories, but I couldn't find the the .spec file where "%config" resides. How can I find it?
 
Old 06-10-2018, 06:47 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by vincix View Post
I've downloaded and etracted httpd rpm from centos repositories, but I couldn't find the the .spec file where "%config" resides. How can I find it?
You need the "httpd-2.4.%{release}.*el7*centos*.src.rpm" source RPM (see http://vault.centos.org/ ?), then extract it:
Code:
umask 0027 && mkdir "/tmp/httpd.$$" && cd "/tmp/httpd.$$" && curl -s "http:// url /httpd-2.4. .el7.centos. .src.rpm" | rpm2cpio - | cpio -vdium && cat httpd.spec
 
Old 06-29-2018, 06:17 AM   #6
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
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.

Last edited by vincix; 06-29-2018 at 06:27 AM.
 
Old 06-29-2018, 08:57 AM   #7
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
Of course, /etc/httpd/conf/modules.d/15-php.conf says:
Quote:
<IfModule !mod_php5.c>
<IfModule prefork.c>
LoadModule php7_module modules/libphp7.so
</IfModule>
</IfModule>


<IfModule !mod_php5.c>
<IfModule !prefork.c>
LoadModule php7_module modules/libphp7-zts.so
</IfModule>
</IfModule>
However, prefork module is clearly not enabled:
Code:
apachectl -M
core_module (static)
 so_module (static)
 http_module (static)
 access_compat_module (shared)
 actions_module (shared)
 alias_module (shared)
 allowmethods_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_anon_module (shared)
 authn_core_module (shared)
 authn_dbd_module (shared)
 authn_dbm_module (shared)
 authn_file_module (shared)
 authn_socache_module (shared)
 authz_core_module (shared)
 authz_dbd_module (shared)
 authz_dbm_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_owner_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cache_module (shared)
 cache_disk_module (shared)
 data_module (shared)
 dbd_module (shared)
 deflate_module (shared)
 dir_module (shared)
 dumpio_module (shared)
 echo_module (shared)
 env_module (shared)
 expires_module (shared)
 ext_filter_module (shared)
 filter_module (shared)
 headers_module (shared)
 include_module (shared)
 info_module (shared)
 log_config_module (shared)
 logio_module (shared)
 mime_magic_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 remoteip_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 slotmem_plain_module (shared)
 slotmem_shm_module (shared)
 socache_dbm_module (shared)
 socache_memcache_module (shared)
 socache_shmcb_module (shared)
 status_module (shared)
 substitute_module (shared)
 suexec_module (shared)
 unique_id_module (shared)
 unixd_module (shared)
 userdir_module (shared)
 version_module (shared)
 vhost_alias_module (shared)
 dav_module (shared)
 dav_fs_module (shared)
 dav_lock_module (shared)
 lua_module (shared)
 mpm_event_module (shared)
 proxy_module (shared)
 lbmethod_bybusyness_module (shared)
 lbmethod_byrequests_module (shared)
 lbmethod_bytraffic_module (shared)
 lbmethod_heartbeat_module (shared)
 proxy_ajp_module (shared)
 proxy_balancer_module (shared)
 proxy_connect_module (shared)
 proxy_express_module (shared)
 proxy_fcgi_module (shared)
 proxy_fdpass_module (shared)
 proxy_ftp_module (shared)
 proxy_http_module (shared)
 proxy_scgi_module (shared)
 proxy_wstunnel_module (shared)
 ssl_module (shared)
 systemd_module (shared)
 cgid_module (shared)
 fcgid_module (shared)
 php7_module (shared)
 evasive20_module (shared)
 
Old 06-29-2018, 10:15 AM   #8
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
Only now did I see the last part of 15-php.conf, namely:
Code:
<IfModule !mod_php5.c>
<IfModule !prefork.c>
LoadModule php7_module modules/libphp7-zts.so
</IfModule>
</IfModule>
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.
 
  


Reply

Tags
apache, centos7, php-fpm



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Firewalld on CentOS 7 not letting PHP-FPM (+Apache 2.4) through gacanepa Linux - Newbie 7 11-20-2015 09:18 PM
LXer: How To Use Multiple PHP Versions (PHP-FPM & FastCGI) With ISPConfig 3 (CentOS 6.3) (Copy) LXer Syndicated Linux News 1 03-30-2015 03:14 PM
[SOLVED] PHP-FPM not working as PHP handler in Apache DarkSlayer Linux - Server 2 08-28-2013 02:25 AM
LXer: Using Multiple PHP Versions (PHP-FPM & FastCGI) With ISPConfig 3 (CentOS 6.3) LXer Syndicated Linux News 0 03-14-2013 08:10 PM
apache and php module mod_php.so kngharv Linux - General 1 11-21-2001 08:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration