User Tools

Site Tools


servers:linux:nginx:php_info

Information

Prerequisites

PHP File

sudo mkdir -p '/var/www/php-info' && sudo -e '/var/www/php-info/index.php'
<?php
phpinfo();
?>

nginx + PHP-FPM Configuration

PHP-FPM Socket

sudo -e '/etc/php/7.0/fpm/pool.d/php-info.conf' && sudo systemctl restart 'php7.0-fpm'
[php-info]
user = www-data
group = www-data
listen = /run/php/php-info.sock
listen.owner = www-data
listen.group = www-data
listen.allowed_clients = 127.0.0.1
pm = ondemand
pm.max_children = 8
pm.process_idle_timeout = 10s

FastCGI

sudo -e '/etc/nginx/snippets/php-info.conf'
location ~ \.php$ {
    try_files $uri =404;
    include fastcgi.conf;
    fastcgi_intercept_errors on;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param HTTPS on;
    fastcgi_pass unix:/run/php/php-info.sock;
}

Server Block

sudo -e '/etc/nginx/sites-available/php-info.conf'
server {
    listen '443' 'ssl' 'http2';
    server_name 'test.realmofespionage.xyz';
    root '/var/www/php-info';
    index 'index.php';

    include '/etc/nginx/snippets/php-info.conf';

    #access_log /var/log/nginx/php-info-access.log;
    #error_log /var/log/nginx/php-info-error.log info;
}

Enable

sudo ln -s '/etc/nginx/sites-available/php-info.conf' '/etc/nginx/sites-enabled/php-info.conf' && sudo systemctl reload 'nginx'

Verify

Cleanup

sudo unlink '/etc/nginx/sites-enabled/php-info.conf' && sudo rm -R '/etc/nginx/sites-available/php-info.conf' '/etc/nginx/snippets/php-info.conf' '/etc/php/7.0/fpm/pool.d/php-info.conf' '/var/www/php-info' && sudo systemctl restart 'nginx' 'php7.0-fpm'
/usr/local/www/wiki/data/pages/servers/linux/nginx/php_info.txt · Last modified: by 127.0.0.1