How to install ngx_php7 NGINX module in CentOS/RHEL 7
by Danila Vershinin,
GetPageSpeed ships security updates for PHP versions nobody else patches, including every PHP from 5.4 to 8.4 on Enterprise Linux 7. The packages are free to install for personal, development and evaluation use; commercial production use requires GetPageSpeed Ultra, which covers up to 10 servers running your own services. Servers that host client websites, or larger fleets, are covered by Fleet.
See Everpatch coverage.
See Everpatch coverage.
What is ngx_php 7
ngx_php7 is an extension module of high-performance web server nginx, which implements embedded php7 script to process nginx location and variables.
Install with PHP 7.3
yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils
yum-config-manager --enable remi-php73
yum install nginx-module-php7
Enable in NGINX
Edit your nginx.conf and load the required modules at the top:
load_module modules/ndk_http_module.so;
load_module modules/ngx_http_php_module.so;
Now you can do fancy PHP stuff in your NGINX configuration:
location /php {
content_by_php '
echo "hello ngx_php7";
';
}
Caveats
- Our module build requires PHP 7.3 and does not support multiple PHP version installations
- PHP OPCache is not supported by this module (PHP embedded limitation)
For more information, refer to module’s documentation.