Configure Tideways In NGINX Virtual Hosts

If you are running multiple PHP applications on an NGINX webserver, then you might want to configure them individually using NGINX virtual hosts (vhost). The Location block inside an NGINX vhost allows setting additional environment variables, which the Tideways extension can interpret. The following example shows how to do this.

location ~ \.php {
    fastcgi_index  index.php;
    include        fastcgi_params;
    fastcgi_pass   unix:/var/run/php/php7.1-fpm.sock
    fastcgi_param  TIDEWAYS_APIKEY "<YOUR_API_KEY>";
    fastcgi_param  TIDEWAYS_SAMPLERATE "25";
    fastcgi_param  TIDEWAYS_SERVICE "web";
}
Don’t forget to restart your webserver after making changes to the vhost configuration.

These three environment variables are the equivalent of the following INI variables, that you can configure in a PHP INI file:

  • tideways.api_key

  • tideways.service

  • tideways.sample_rate

Still need help? Email [email protected]