# Install PHP

Unlike Apache, Nginx does not contain native PHP processing. For that we have to install PHP-FPM (FastCGI Process Manager). FPM is an alternative PHP FastCGI implementation with some additional features useful for heavy-loaded sites.

You should add Ubuntu’s universe repository before installing php-fpm to ensure you get the correct package.

```
sudo add-apt-repository universe
```

If the prompt ask `Adding component(s) 'universe' to all repositories.`, press `ENTER`.

Now update the package lists and install PHP-FPM on Ubuntu 20.04. We will also install `php-mysql` to allow PHP to communicate with the MySQL database.&#x20;

```
sudo apt update && sudo apt install php-fpm php-mysql
```

Press `Y` and `ENTER` to continue installation.

Once installed, check the PHP version.

```
php --version
```

Output:

`PHP 7.4.3 (cli) (built: Jul 5 2021 15:13:35) ( NTS )` \
`Copyright (c) The PHP Group` \
`Zend Engine v3.4.0, Copyright (c) Zend Technologies` \
&#x20;   `with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies`

Above we are using PHP version **7.4.3,** though this may be a later version for you depending on which package was in the repository.

Depending on what version of Nginx and PHP you install, you may need to manually configure the location of the PHP socket that Nginx will connect to.

List the contents for the directory `/var/run/php/`.

```
ls /var/run/php/
```

You should see one or a few entries here.

```
php-fpm.sock  php7.4-fpm.pid  php7.4-fpm.sock
```

{% hint style="success" %}
You've completed this section, now your website can load Unlike Apache, Nginx does not contain native PHP processing. For that we have to install PHP-FPM (FastCGI Process Manager). FPM is an alternative PHP FastCGI implementation with some additional features useful for heavy-loaded sites.

You should add Ubuntu’s universe repository before installing php-fpm to ensure you get the correct package the PHP file.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://haqem.gitbook.io/install-nginx-mariadb-php-and-phpmyadmin/install-php.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
