Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
627 changes: 0 additions & 627 deletions content/doc/applications/php.md

This file was deleted.

218 changes: 218 additions & 0 deletions content/doc/applications/php/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
---
type: docs
linkTitle: PHP with Apache
title: PHP with Apache application runtime
description: Deploy PHP applications on Clever Cloud with Apache, PHP-FPM, Composer dependencies, and framework support
keywords:
- php hosting
- apache
- composer
- laravel
- symfony
- wordpress
aliases:
- /applications/php
- /deploy/application/php/php-apps
- /doc/deploy/application/php
- /doc/deploy/application/php/php-apps
- /doc/doc/php
- /doc/php
- /doc/php/php-apps
- /doc/doc/php/php-apps
- /doc/getting-started/by-language/php
- /doc/partials/language-specific-deploy/php
- /getting-started/by-language/php
- /php
- /php/php-apps
---

## Overview

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded

Check failure on line 31 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L31

[Google.LyHyphens] 'widely-used' doesn't need a hyphen.
Raw output
{"message": "[Google.LyHyphens] 'widely-used' doesn't need a hyphen.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 31, "column": 10}}}, "severity": "ERROR"}

Check notice on line 31 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L31

[Google.Contractions] Use 'that's' instead of 'that is'.
Raw output
{"message": "[Google.Contractions] Use 'that's' instead of 'that is'.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 31, "column": 57}}}, "severity": "INFO"}

Check notice on line 31 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L31

[Google.Passive] In general, use active voice instead of passive voice ('be embedded').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be embedded').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 31, "column": 111}}}, "severity": "INFO"}
into HTML.

The HTTP server is [Apache 2](https://httpd.apache.org/), and the PHP code is executed by [PHP-FPM](https://php-fpm.org/).

Check notice on line 34 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L34

[Google.Passive] In general, use active voice instead of passive voice ('is executed').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is executed').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 34, "column": 76}}}, "severity": "INFO"}

## Create your PHP application

To create a new PHP application, use the [Clever Cloud Console](https://console.clever-cloud.com) or [Clever Tools](https://github.com/CleverCloud/clever-tools):

```bash
clever create --type php
```
- [Learn more about Clever Tools](/doc/cli/)
- [Learn more about Clever Cloud application deployment](/doc/quickstart/#create-an-application-step-by-step)

## Configure your PHP application

### Mandatory needs

PHP runtime requires a working web application. The HTTP server is Apache 2 with PHP-FPM. If you need to serve files from a specific directory, set the `CC_WEBROOT` environment variable (e.g. `/public`).

Check failure on line 50 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L50

[Google.Latin] Use 'for example' instead of 'e.g.'.
Raw output
{"message": "[Google.Latin] Use 'for example' instead of 'e.g.'.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 50, "column": 188}}}, "severity": "ERROR"}

```shell
clever env set CC_WEBROOT /public
```

- [Learn more about environment variables on Clever Cloud](/doc/reference/reference-environment-variables/)

### Build phase

Composer build is supported out of the box. If a `composer.json` file is present at the root of your repository, dependencies are installed automatically during the build phase.

Check notice on line 60 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L60

[Google.Passive] In general, use active voice instead of passive voice ('is supported').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is supported').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 60, "column": 16}}}, "severity": "INFO"}

Check notice on line 60 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L60

[Google.Passive] In general, use active voice instead of passive voice ('are installed').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('are installed').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 60, "column": 127}}}, "severity": "INFO"}

- [Learn more about Composer on Clever Cloud](/doc/applications/php/composer/)
- [Learn more about Deployment hooks](/doc/develop/build-hooks/)

### PHP version

Set the `CC_PHP_VERSION` environment variable to one of the following versions.

{{< runtimes_versions php >}}

All new PHP applications are created with a default `CC_PHP_VERSION`. You can change it whenever you want then redeploy your application to use the version you want. Only values based on the first two digits (`X` or `X.Y`, not `X.Y.Z`) are supported.

Check notice on line 71 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L71

[Google.Passive] In general, use active voice instead of passive voice ('are created').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('are created').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 71, "column": 26}}}, "severity": "INFO"}

Check notice on line 71 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L71

[Google.Passive] In general, use active voice instead of passive voice ('are supported').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('are supported').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 71, "column": 237}}}, "severity": "INFO"}

### Custom PHP configuration

Most PHP settings can be changed using a `.user.ini` file.

Check notice on line 75 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L75

[Google.Passive] In general, use active voice instead of passive voice ('be changed').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be changed').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 75, "column": 23}}}, "severity": "INFO"}

If you want the settings to be applied to the whole application, you should put this file in your `webroot`. If you did not change it, then your `webroot` is the root of the repository.

Check notice on line 77 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L77

[Google.Passive] In general, use active voice instead of passive voice ('be applied').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be applied').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 77, "column": 29}}}, "severity": "INFO"}

Check notice on line 77 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L77

[Google.Contractions] Use 'didn't' instead of 'did not'.
Raw output
{"message": "[Google.Contractions] Use 'didn't' instead of 'did not'.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 77, "column": 117}}}, "severity": "INFO"}

If you put the `.user.ini` file in a subdirectory, settings will be applied recursively starting from this subdirectory.

Check warning on line 79 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L79

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 79, "column": 61}}}, "severity": "WARNING"}

Check notice on line 79 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L79

[Google.Passive] In general, use active voice instead of passive voice ('be applied').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be applied').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 79, "column": 66}}}, "severity": "INFO"}

You can review the [available directives](https://www.php.net/manual/en/ini.list.php); all the `PHP_INI_USER`, `PHP_INI_PERDIR`, and `PHP_INI_ALL` directives can be set from within `.user.ini`.

Check notice on line 81 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L81

[Google.Semicolons] Use semicolons judiciously.
Raw output
{"message": "[Google.Semicolons] Use semicolons judiciously.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 81, "column": 86}}}, "severity": "INFO"}

Check notice on line 81 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L81

[Google.Passive] In general, use active voice instead of passive voice ('be set').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be set').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 81, "column": 163}}}, "severity": "INFO"}

- [Learn more about .user.ini](https://www.php.net/manual/en/configuration.file.per-user.php)

#### Same configuration between PHP-CLI and PHP-FPM

`.user.ini` files are not loaded by the PHP CLI by default.

Check notice on line 87 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L87

[Google.Contractions] Use 'aren't' instead of 'are not'.
Raw output
{"message": "[Google.Contractions] Use 'aren't' instead of 'are not'.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 87, "column": 19}}}, "severity": "INFO"}

However, some PHP applications may want to check for the PHP-FPM configuration pre-requisites, `post_max_size` or `upload_max_filesize` values for example.

To load the PHP-FPM `.user.ini` file during a PHP-CLI process, in a [hook](/doc/develop/build-hooks/), use the `PHP_INI_SCAN_DIR` environment variable to load the additional file.

Assuming the script runs at the root-folder of the application:

```bash
#!/usr/bin/env bash

export PHP_INI_SCAN_DIR=":."
php myscript.php
```

This appends the current directory while still loading the default configuration.

> [!NOTE]
> The `:` at the beginning of the string is mandatory. It indicates defaults files must still load.

A specific `.ini` file can be loaded with:

Check notice on line 107 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L107

[Google.Passive] In general, use active voice instead of passive voice ('be loaded').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be loaded').", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 107, "column": 28}}}, "severity": "INFO"}

```bash
#!/usr/bin/env bash

export PHP_INI_SCAN_DIR=":.php-configuration/"
php myscript.php
```

This loads every `.ini` files in the `php-configuration/` directory.

#### Timezone configuration

All instances on Clever Cloud run on the UTC timezone. We recommend to handle all your dates in UTC internally, and only handle timezones when reading or displaying dates.

Check notice on line 120 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L120

[Google.Acronyms] Spell out 'UTC', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'UTC', if it's unfamiliar to the audience.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 120, "column": 42}}}, "severity": "INFO"}

Check warning on line 120 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L120

[Google.We] Try to avoid using first-person plural like 'We'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'We'.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 120, "column": 56}}}, "severity": "WARNING"}

Check notice on line 120 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L120

[Google.Acronyms] Spell out 'UTC', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'UTC', if it's unfamiliar to the audience.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 120, "column": 97}}}, "severity": "INFO"}

Additionally, you can set PHP's time zone setting with `.user.ini`. For instance, to use the french time zone, edit `.user.ini` to add this line:

```ini
date.timezone=Europe/Paris
```

#### Memory Limit

When php-fpm spawns a worker it allocates a smaller part of the application's memory to the worker, here is the allocated memory for each flavor:

| Flavor | Memory Limit |
|----------|--------------|
|Pico | 64M |
|Nano | 64M |
|XS | 128M |
|S | 256M |
|M | 384M |
|L | 512M |
|XL | 768M |
|2XL | 1024M |
|3XL | 1536M |
|4XL+ | 2048M |

To change this limit you can define `MEMORY_LIMIT` [environment variable](/doc/reference/reference-environment-variables#php).

If you define a limit exceeding the application memory it will use the default one.

Check warning on line 147 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L147

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 147, "column": 59}}}, "severity": "WARNING"}

## Frameworks and CMS

Check notice on line 149 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L149

[Google.Acronyms] Spell out 'CMS', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CMS', if it's unfamiliar to the audience.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 149, "column": 19}}}, "severity": "INFO"}

The following is the list of tested CMS by our team.

Check notice on line 151 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L151

[Google.Acronyms] Spell out 'CMS', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CMS', if it's unfamiliar to the audience.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 151, "column": 37}}}, "severity": "INFO"}

Check warning on line 151 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L151

[Google.We] Try to avoid using first-person plural like 'our'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'our'.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 151, "column": 44}}}, "severity": "WARNING"}

It's quite not exhaustive, so it does not mean that other CMS can't work on the Clever Cloud platform.

Check notice on line 153 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L153

[Google.Contractions] Use 'doesn't' instead of 'does not'.
Raw output
{"message": "[Google.Contractions] Use 'doesn't' instead of 'does not'.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 153, "column": 34}}}, "severity": "INFO"}

Check notice on line 153 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L153

[Google.Acronyms] Spell out 'CMS', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'CMS', if it's unfamiliar to the audience.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 153, "column": 59}}}, "severity": "INFO"}

{{< cards >}}
{{< card link="/developers/guides/tutorial-drupal" title="Drupal" subtitle= "Deploy a Drupal-based website on Clever Cloud" icon="drupal" >}}
{{< card link="/developers/guides/tutorial-laravel" title="Laravel" subtitle= "Deploy a Laravel app on Clever Cloud" icon="laravel" >}}
{{< card link="/developers/guides/tutorial-symfony" title="Symfony" subtitle= "Deploy a Symfony application on Clever Cloud" icon="symfony" >}}
{{< card link="/developers/guides/tutorial-wordpress" title="WordPress" subtitle= "Deploy WordPress on Clever Cloud" icon="wordpress" >}}
{{< card link="/developers/guides/moodle" title="Moodle" subtitle="Full Moodle installation and configuration guide" icon="moodle" >}}

{{< /cards >}}

Others PHP frameworks tested on Clever Cloud:

- Prestashop

Check failure on line 166 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L166

[Vale.Spelling] Did you really mean 'Prestashop'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Prestashop'?", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 166, "column": 3}}}, "severity": "ERROR"}
- Dokuwiki

Check failure on line 167 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L167

[Vale.Spelling] Did you really mean 'Dokuwiki'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Dokuwiki'?", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 167, "column": 3}}}, "severity": "ERROR"}
- Joomla

Check failure on line 168 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L168

[Vale.Spelling] Did you really mean 'Joomla'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Joomla'?", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 168, "column": 3}}}, "severity": "ERROR"}
- SugarCRM
- Drupal
- Magento

Check failure on line 171 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L171

[Vale.Spelling] Did you really mean 'Magento'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Magento'?", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 171, "column": 3}}}, "severity": "ERROR"}
- Status.net
- Symfony
- Thelia

Check failure on line 174 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L174

[Vale.Spelling] Did you really mean 'Thelia'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Thelia'?", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 174, "column": 3}}}, "severity": "ERROR"}
- Laravel
- Sylius

Check failure on line 176 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L176

[Vale.Spelling] Did you really mean 'Sylius'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Sylius'?", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 176, "column": 3}}}, "severity": "ERROR"}

## Configure Monolog

A lot of frameworks (including Symfony) use Monolog to handle logging. The default configuration of Monolog doesn't allow to log errors into the console.

Here is a basic configuration of Monolog to send your application's logs into our logging system and access them into the Console:

Check warning on line 182 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L182

[Google.We] Try to avoid using first-person plural like 'our'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'our'.", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 182, "column": 79}}}, "severity": "WARNING"}

```yaml
monolog:
handlers:
clever_logs:
type: error_log
level: warning
```

You can change the level to whatever level you desire. For Symfony, the configuration file is `app/config/config_prod.yml`.

Laravel doesn't need Monolog to retrieve logs via Clever console or Clever CLI. Here, ensure that you have the following line in `config/app.php`:

```php
return [
// …
'log' => env('APP_LOG'),
// …
];
```

Then, set `APP_LOG=syslog` as Clever application environment variable.

{{% content "new-relic" %}}

{{% content "blackfire" %}}

## ProxySQL

{{% content "proxysql" %}}

You can learn more about ProxySQL on the [dedicated documentation page](/guides/proxysql)

{{% content "url_healthcheck" %}}

Check failure on line 216 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L216

[Vale.Spelling] Did you really mean 'url_healthcheck'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'url_healthcheck'?", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 216, "column": 14}}}, "severity": "ERROR"}
{{% content "redirectionio" %}}

Check failure on line 217 in content/doc/applications/php/_index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/_index.md#L217

[Vale.Spelling] Did you really mean 'redirectionio'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'redirectionio'?", "location": {"path": "content/doc/applications/php/_index.md", "range": {"start": {"line": 217, "column": 14}}}, "severity": "ERROR"}
{{% content "varnish" %}}
121 changes: 121 additions & 0 deletions content/doc/applications/php/apache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
type: docs
linkTitle: Apache
title: Apache web server configuration
description: Configure Apache 2 for PHP applications on Clever Cloud with htaccess, authentication, HTTPS redirection, and FastCGI settings
keywords:
- apache
- htaccess
- htpasswd
- fastcgi
- https redirect
---

## Configure Apache

Apache 2 is used as HTTP Server for PHP applications on Clever Cloud. You can configure it with `.htaccess` files and environment variables.

Check notice on line 16 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L16

[Google.Passive] In general, use active voice instead of passive voice ('is used').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is used').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 16, "column": 10}}}, "severity": "INFO"}

### htaccess

The `.htaccess` file can be created everywhere in your app, depending of the part of the application covered by directives.

Check notice on line 20 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L20

[Google.Passive] In general, use active voice instead of passive voice ('be created').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be created').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 20, "column": 26}}}, "severity": "INFO"}

However, directives who applies to the entire application must be declared in a `.htaccess` file to the application root.

Check notice on line 22 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L22

[Google.Passive] In general, use active voice instead of passive voice ('be declared').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be declared').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 22, "column": 64}}}, "severity": "INFO"}

### Basic authentication

You can configure basic authentication using [environment variables](/doc/reference/reference-environment-variables#php). You will need to set `CC_HTTP_BASIC_AUTH` variable to your own `login:password` pair. If you need to allow access to multiple users, you can create additional environment `CC_HTTP_BASIC_AUTH_n` (where `n` is a number) variables.

Check warning on line 26 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L26

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 26, "column": 127}}}, "severity": "WARNING"}

### HTTP timeout

You can define the timeout of an HTTP request in Apache using the `HTTP_TIMEOUT` [environment variable](/doc/develop/env-variables).

**By default, the HTTP timeout is set to 3 minutes (180 seconds)**.

Check notice on line 32 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L32

[Google.Passive] In general, use active voice instead of passive voice ('is set').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is set').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 32, "column": 32}}}, "severity": "INFO"}

### Header size

Default Apache header size is `8k`. If you need to increase it, you can set `CC_APACHE_HEADERS_SIZE` environment variable, between `8` and `256`. Effective value depends on deployment region. [Ask for a dedicated load balancer](https://console.clever-cloud.com/ticket-center-choice) for a specific value.

### Force HTTPS traffic

Load balancers handle HTTPS traffic ahead of your application. You can use the `X-Forwarded-Proto` header to know the original protocol (`http` or `https`).

Place the following snippet in a `.htaccess` file to ensure that your visitors only access your application through HTTPS.

```conf
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
```

### Prevent Apache to redirect HTTPS calls to HTTP when adding a trailing slash

`DirectorySlash` is enabled by default on the PHP scalers, therefore Apache will add a trailing slash to a resource when it detects that it is a directory.

Check notice on line 53 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L53

[Google.Passive] In general, use active voice instead of passive voice ('is enabled').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is enabled').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 53, "column": 18}}}, "severity": "INFO"}

Check warning on line 53 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L53

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 53, "column": 77}}}, "severity": "WARNING"}

Check notice on line 53 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L53

[Google.Contractions] Use 'it's' instead of 'it is'.
Raw output
{"message": "[Google.Contractions] Use 'it's' instead of 'it is'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 53, "column": 138}}}, "severity": "INFO"}

E.g. if foobar is a directory, Apache will automatically redirect `http://example.com/foobar` to `http://example.com/foobar/`.

Check failure on line 55 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L55

[Google.Latin] Use 'for example' instead of 'E.g.'.
Raw output
{"message": "[Google.Latin] Use 'for example' instead of 'E.g.'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 55, "column": 1}}}, "severity": "ERROR"}

Check warning on line 55 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L55

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 55, "column": 39}}}, "severity": "WARNING"}

Unfortunately the module is unable to detect if the request comes from a secure connection or not. As a result it will force an HTTPS call to be redirected to HTTP.

Check warning on line 57 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L57

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 57, "column": 115}}}, "severity": "WARNING"}

Check notice on line 57 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L57

[Google.Passive] In general, use active voice instead of passive voice ('be redirected').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be redirected').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 57, "column": 143}}}, "severity": "INFO"}

In order to prevent this behavior, you can add the following statements in a `.htaccess` file:

```conf
DirectorySlash Off
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ %{HTTP:X-Forwarded-Proto}://%{HTTP_HOST}/$1/ [R=301,L,QSA]
```

These statements will keep the former protocol of the request when issuing the redirect. Assuming that the header `X-Forwarded-Proto` is always filled (which is the case on our platform).

Check warning on line 68 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L68

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 68, "column": 18}}}, "severity": "WARNING"}

Check warning on line 68 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L68

[Google.We] Try to avoid using first-person plural like 'our'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'our'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 68, "column": 174}}}, "severity": "WARNING"}

If you want to force all redirects to HTTPS, you can replace `%{HTTP:X-Forwarded-Proto}` with `https`.

### Change the FastCGI module

You can choose between two FastCGI modules, `fastcgi` and `proxy_fcgi`, using the `CC_CGI_IMPLEMENTATION` environment variable. If you don't set it `proxy_fcgi` is used as default value. `proxy_fcgi` is recommended, as `fastcgi` implementation is not maintained anymore.

Check notice on line 74 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L74

[Google.Passive] In general, use active voice instead of passive voice ('is used').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is used').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 74, "column": 162}}}, "severity": "INFO"}

Check notice on line 74 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L74

[Google.Passive] In general, use active voice instead of passive voice ('is recommended').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is recommended').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 74, "column": 201}}}, "severity": "INFO"}

Check notice on line 74 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L74

[Google.Contractions] Use 'isn't' instead of 'is not'.
Raw output
{"message": "[Google.Contractions] Use 'isn't' instead of 'is not'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 74, "column": 245}}}, "severity": "INFO"}

If you have issues with downloading content, it could be related to the `fastcgi` module not working correctly in combination with the `deflate` module, as the `Content-Length` header is not updated to the new size of the encoded content. To resolve this issue, use `proxy_fcgi`.

Check notice on line 76 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L76

[Google.Passive] In general, use active voice instead of passive voice ('be related').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be related').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 76, "column": 55}}}, "severity": "INFO"}

Check notice on line 76 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L76

[Google.Contractions] Use 'isn't' instead of 'is not'.
Raw output
{"message": "[Google.Contractions] Use 'isn't' instead of 'is not'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 76, "column": 185}}}, "severity": "INFO"}

## Header injection

### With .htaccess

To inject headers on HTTP responses, add this configuration to `.htaccess` file:

```sh
Header Set Access-Control-Allow-Origin "https://www.example.com"
Header Set Access-Control-Allow-Headers "Authorization"
```

> [!NOTE]
> You can use a `.htaccess` file to create or update headers, but you can't delete them.

### With PHP

You can also do it from PHP:

```php
header("Access-Control-Allow-Origin: https://www.example.com");
header("Access-Control-Allow-Headers: Authorization");
```

If you want to keep this separate from your application, you can configure the application to execute some code on every request.

In `.user.ini`, add the following line (you need to create `inject_headers.php` first):

```ini
auto_prepend_file=./inject_headers.php
```

- [Learn more about .user.ini directives](https://www.php.net/manual/en/configuration.file.per-user.php)

## Using HTTP authentication

Using basic HTTP authentication, PHP usually handles the values of user and password in variables named `$_SERVER['PHP_AUTH_USER']` and `$_SERVER['PHP_AUTH_PW']`.

At Clever Cloud, an Apache option is enabled to pass directly the Authorization header, even though FastCGI is used; still, the header is not used by PHP, and the aforementioned variables are empty.

Check notice on line 115 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L115

[Google.Passive] In general, use active voice instead of passive voice ('is enabled').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is enabled').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 115, "column": 35}}}, "severity": "INFO"}

Check notice on line 115 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L115

[Google.Passive] In general, use active voice instead of passive voice ('is used').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is used').", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 115, "column": 109}}}, "severity": "INFO"}

Check notice on line 115 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L115

[Google.Semicolons] Use semicolons judiciously.
Raw output
{"message": "[Google.Semicolons] Use semicolons judiciously.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 115, "column": 116}}}, "severity": "INFO"}

Check notice on line 115 in content/doc/applications/php/apache.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/applications/php/apache.md#L115

[Google.Contractions] Use 'isn't' instead of 'is not'.
Raw output
{"message": "[Google.Contractions] Use 'isn't' instead of 'is not'.", "location": {"path": "content/doc/applications/php/apache.md", "range": {"start": {"line": 115, "column": 136}}}, "severity": "INFO"}

You can do this to fill them using the Authorization header:

```php
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':' , base64_decode(substr($_SERVER['Authorization'], 6)));
```
Loading
Loading