Skip to content

Web server setup

David Lundgren edited this page May 16, 2019 · 2 revisions

NOTE: These are minimal configurations that I use on production servers.

php-fpm

/path/to/php-fpm.d/phagrancy.conf

[phagrancy]
user = www
group = www
listen = 127.0.0.1:9000
;listen = /var/lib/php-fpm/phagrancy.sock
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
catch_workers_output = yes

Apache + php-fpm

/etc/apache2/sites-enabled/phagrancy.conf

    DocumentRoot /srv/www/phagrancy/web
    <Directory /srv/www/phagracny/web>
        SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
        <FilesMatch "\.php$">
            SetHandler "proxy:fcgi://127.0.0.1:9000"
        </FilesMatch>
    </Directory>
</VirtualHost>

If you are using the unix socket version you'd use proxy:unix:/var/lib/php-fpm/phagrancy.sock

Nginx + php-fpm

/etc/nginx/sites-enabled/phagrancy.conf

    listen 80;
    root /srv/www/phagrancy/web;
    index index.php index.html;
    error_log /var/log/nginx/phagrancy-error.log;
    access_log /var/log/nginx/phagrancy-access.log main;

    server_name phagrancy.example.com;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

    location = /50x.html {
        root /usr/local/share/nginx/www;
    }

    location / {
        client_max_body_size 7G;
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
                return 404;
        }

        fastcgi_pass    127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}```