Programming

Upgrade Apache to 2.4 from 2.2 on Arch Linux, using PHP-FPM

Since the first article, more than six weeks ago, Apache has been updated to version 2.4.9 which allows for a simpler configuration with php-fpm, mod_proxy_fcgi and mod_proxy_handler.

The following setup does not use mod_php, which requires mod_mpm_prefork and ProxyPassMatch directives as shown in my first article.

First, install php-fpm and mod_proxy_handler (the latter comes from AUR).

# yaourt -S php-fpm mod_proxy_handler

Then update /etc/php/php-fpm.conf:

listen = 127.0.0.1:9000
;listen = /run/php-fpm/php-fpm.sock
[...]
listen.allowed_clients = 127.0.0.1

In the main Apache configuration file located at /etc/httpd/conf/httpd.conf, no more need to use mpm_prefork_module and ProxyPassMatch. Just append the following:

LoadModule proxy_handler_module modules/mod_proxy_handler.so
<filesmatch .php="">
    SetHandler "proxy:fcgi://127.0.0.1:9000/"
</filesmatch>

Verify that the following line is active (uncommented) as it should be by default:

LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

Edit the dir_module directive:

<ifmodule dir_module="">
    DirectoryIndex index.php index.html
</ifmodule>

Remove or comment out the php module if you had it in your old config:

#LoadModule php5_module modules/libphp5.so
#Include conf/extra/php5_module.conf

Restart apache and php-fpm:

# systemctl restart httpd.service php-fpm.service

If it is your first installation of php-fpm and you use Apache often, you might want to start its daemon automatically:

# systemctl enable php-fpm.service

Source

Back


Comments

No comment yet.

A remark, a suggestion? Do not hesitate to express yourself below. Just be courteous and polite, please.

If this field is left blank, you will appear as Anonymous.