Knowledge base

1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!

Use PHP environment variables

Update 09/01/2026

This guide explains how to use PHP environment variables with Web Hosting plans that run on php-fpm.

 

Introduction

  • PHP environment variables are system variables used to store information about HTTP requests and redirects.
  • They are generally used in web servers to store details about previous requests or redirects that have been performed.
  • These variables can contain information such as previous URLs, HTTP methods, or other data related to the client's navigation on the web server.

 

Using environment variables

To use PHP environment variables:

  1. Define the PHP environment variables in a .htaccess file:
    • SetEnv EXAMPLEVARIABLE hello
  2. In your PHP file, the name of the variable to call must correspond to the same variable name defined in the environment variable:
    • <?php getenv('EXAMPLEVARIABLE');

In this example, the displayed result will be hello.

 

Go further with environment variables

It is possible to configure environment variables directly from the Manager for your entire website:

  1. Click here to access your website management in the Infomaniak Manager (need help?).
  2. Click directly on the name assigned to the website in question:
  3. Click on Manage advanced settings:
  4. Click on the PHP / Apache tab:
  5. Further down the page, click on the chevron to expand the Environment Variables section.
  6. Click on the Add icon.
  7. Enter the variable and its value.
  8. Click the button to save:

Has this FAQ been helpful?