Mailing List Archive

Implementing mpm_event with php-fpm has broken my codeigniter app
Hi Team,

My software: ubuntu 20.04, apache 2.4.41, php 7.4, codeigniter 3.1.16

I have an app which works fine with mpm_prefork and mod_php7.4. However,
in anticipation of a lot of concurrent
sessions I have just looked at improving performance and using memory
more efficiently by changing to
mpm_event with php-fpm and fastcgi.

Following DigitalOcean instructions it all appeared to install ok.

apachectl -t showed Syntax OK.

I can see the socket being created (owned by www-data) and the
php7.4-fpm service starts successfully.

However when I try to run my app it fails to show my home page. It does
run codeigniter because it renders a screen from
one of the autoloaded files. But when it gets to index.php nothing
happens. I can see in the browser tools and server fpm pool
log a "GET /index.php" so something appears to be stopping it!

I read an article that suggested url rewriting was "tricky" with fastcgi
and the recommended .htaccess (in docroot) is:

===================================
Options -Indexes +FollowSymLinks

RewriteEngine On
#RewriteBase /

# exclude any paths that are not codeigniter-app related
RewriteCond %{REQUEST_URI} !^/server-status
RewriteCond %{REQUEST_URI} !^/server-info
RewriteCond %{REQUEST_URI} !^/docs

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
============================================

Still no joy. Having run out of ideas I am seeking any advice on what I
might be missing please?
Hopefully it is something simple so I can take advantage of the fpm
solution.

Thx Paul




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Implementing mpm_event with php-fpm has broken my codeigniter app [ In reply to ]
> # the following is for rewritting under FastCGI
> <IfModule !mod_php5.c>
> RewriteRule ^(.*)$ index.php?/$1 [L]
> </IfModule>

I don't know what this is supposed to do, but it doesn't pass the
request to php-fpm. There's no information about where php-fpm is
listening there. I suggest a different guide.
Since you are working in htaccess, your final config should look like
one of the SetHandler snippets in
https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Implementing mpm_event with php-fpm has broken my codeigniter app [ In reply to ]
On 12/11/2021 20:58, Eric Covener wrote:
>> # the following is for rewritting under FastCGI
>> <IfModule !mod_php5.c>
>> RewriteRule ^(.*)$ index.php?/$1 [L]
>> </IfModule>
>
> I don't know what this is supposed to do, but it doesn't pass the
> request to php-fpm. There's no information about where php-fpm is
> listening there. I suggest a different guide.
> Since you are working in htaccess, your final config should look like
> one of the SetHandler snippets in
> https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org

Hi Eric thanks for quick response.

The php7.4-fpm.conf (enabled) is as follows:

# Redirect to local php-fpm if mod_php is not available
<IfModule !mod_php7.c>
<IfModule proxy_fcgi_module>
# Enable http authorization headers
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>

<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler
"proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
<FilesMatch ".+\.phps$">
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(ar|p|ps|tml)$">
Require all denied
</FilesMatch>
</IfModule>
</IfModule>


Do I have some sort of conflict when applying the .htaccess?

Thx Paul


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org