# Stretch 9.6 apache2 2.4 ne reconnait pas le php

**URL:** <https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998>\
**Category:** Support Debian\
**Created:** [Novembre 15, 2018, 2:47 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998 "2018-11-15T14:47:32Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![nimant](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/n/e19adc/32.png) [@nimant](https://www.debian-fr.org/u/nimant)\
**Post date:** [Novembre 15, 2018, 2:47 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/1 "2018-11-15T14:47:33Z")

</div>

Bonjour  
après un

```nohighlight
apt-get remove --purge apache2

```

puis un

```nohighlight
apt-get install apache2

```

`/var/www/html/index.html` s’affiche normalement  
par contre, le fichier `hello_world.php` :

```php
<?php
  print "Hello World<br>";
?>

```

affiche

```nohighlight
"; ?>

```

le `php` est `7.2`

Qu’est-ce qui manque ?

---

<div class="post-metadata">

**Author:** ![PengouinPdt](https://www.debian-fr.org/user_avatar/www.debian-fr.org/pengouinpdt/32/3978_2.png) [@PengouinPdt](https://www.debian-fr.org/u/PengouinPdt)\
**Post date:** [Novembre 15, 2018, 5:21 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/2 "2018-11-15T17:21:50Z")

</div>

De dire à apache de prendre en compte php, non ?!

---

<div class="post-metadata">

**Author:** ![mattotop](https://www.debian-fr.org/user_avatar/www.debian-fr.org/mattotop/32/3942_2.png) [@mattotop](https://www.debian-fr.org/u/mattotop)\
**Post date:** [Novembre 15, 2018, 5:31 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/3 "2018-11-15T17:31:34Z")

</div>

Ca peut être plein de choses.

- Ton php est installé mais as tu aussi installé la version de libapache2-mod-php7.2 ?

- le module est activé dans apache (ls /etc/apache2/mods-enabled/ | grep php) ?

- avec je ne sais pas ou la déclaration de handler qui va bien (qui a du se faire toute seule normalement):

---

<div class="post-metadata">

**Author:** ![anon97446390](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/a/b4bc9f/32.png) [@anon97446390](https://www.debian-fr.org/u/anon97446390)\
**Post date:** [Novembre 16, 2018, 7:37 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/4 "2018-11-16T07:37:23Z")

</div>

Bonjour,

@nimant, j’essaierai sans la balise HTML

`<br>`

C’est juste une idée comme ça.  
[http://php.net/manual/fr/function.print.php](http://php.net/manual/fr/function.print.php)

---

<div class="post-metadata">

**Author:** ![Parco](https://www.debian-fr.org/user_avatar/www.debian-fr.org/parco/32/7493_2.png) [@Parco](https://www.debian-fr.org/u/Parco)\
**Post date:** [Novembre 16, 2018, 8:06 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/5 "2018-11-16T08:06:44Z")

</div>

Bonjour,

Essaie de créer un fichier index.php et d’y ajouter

> \<?php phpinfo(); ?\>

Tu verras si ton php est fonctionel ou non.  
ps : n’oublie pas de lui donner les bons droits 🙂

---

<div class="post-metadata">

**Author:** ![nimant](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/n/e19adc/32.png) [@nimant](https://www.debian-fr.org/u/nimant)\
**Post date:** [Novembre 16, 2018, 10:46 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/6 "2018-11-16T10:46:23Z")

</div>

Effectivement, il me manque le fichier /etc/apache2/mods-enabled/php7.2.conf  
dans /etc/apache2/mods-enabled/ j’ai ajouté  
php7.2.conf -\> …/mods-available/php7.2.conf

j’ai relancé apache2  
rien ne se passe apache2 ne “parse” pas le php.

---

<div class="post-metadata">

**Author:** ![Parco](https://www.debian-fr.org/user_avatar/www.debian-fr.org/parco/32/7493_2.png) [@Parco](https://www.debian-fr.org/u/Parco)\
**Post date:** [Novembre 16, 2018, 11:01 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/7 "2018-11-16T11:01:34Z")

</div>

Tu as installé «&nbsp;libapache2-mod-php7.2&nbsp;» que @mattotop t’a demandé ?

> sudo apt-get install -y libapache2-mod-php7.2  
> sudo a2enmod php7.2  
> sudo systemctl restart apache2

Normalement tu n’as pas besoin d’autre manipulation

---

<div class="post-metadata">

**Author:** ![nimant](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/n/e19adc/32.png) [@nimant](https://www.debian-fr.org/u/nimant)\
**Post date:** [Novembre 16, 2018, 11:12 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/8 "2018-11-16T11:12:48Z")

</div>

> [@Parco](#):
>
> a2enmod php7.2

a2enmod php7.2  
Considering dependency mpm\_prefork for php7.2:  
Considering conflict mpm\_event for mpm\_prefork:  
ERROR: Module mpm\_event is enabled - cannot proceed due to conflicts. It needs to be disabled first!  
Considering conflict mpm\_worker for mpm\_prefork:  
ERROR: Could not enable dependency mpm\_prefork for php7.2, aborting

je ne comprends pas cette erreur.

---

<div class="post-metadata">

**Author:** ![Parco](https://www.debian-fr.org/user_avatar/www.debian-fr.org/parco/32/7493_2.png) [@Parco](https://www.debian-fr.org/u/Parco)\
**Post date:** [Novembre 16, 2018, 11:19 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/9 "2018-11-16T11:19:31Z")

</div>

Il me semble que tu ne peux pas avoir les modules mpm\_event & mpm\_prefork en même temps  
Pour cela :

> sudo a2dismod mpm\_prefork  
> sudo systemctl restart apache2  
> sudo a2enmod php7.2  
> sudo systemctl restart apache2

N’hésite pas à (re)mettre les erreurs s’il y en a

---

<div class="post-metadata">

**Author:** ![nimant](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/n/e19adc/32.png) [@nimant](https://www.debian-fr.org/u/nimant)\
**Post date:** [Novembre 16, 2018, 11:21 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/10 "2018-11-16T11:21:45Z")

</div>

roo@iab\>apachectl -V | grep -i mpm  
Server MPM: event  
roo@iab\>a2dismod mpm\_prefork  
Module mpm\_prefork already disabled  
roo@iab\> systemctl restart apache2  
roo@iab\>a2enmod php7.2  
Considering dependency mpm\_prefork for php7.2:  
Considering conflict mpm\_event for mpm\_prefork:  
ERROR: Module mpm\_event is enabled - cannot proceed due to conflicts. It needs to be disabled first!  
Considering conflict mpm\_worker for mpm\_prefork:  
ERROR: Could not enable dependency mpm\_prefork for php7.2, aborting

toujours la même chose.  
Comment reinstaller apache2 ?

---

<div class="post-metadata">

**Author:** ![Parco](https://www.debian-fr.org/user_avatar/www.debian-fr.org/parco/32/7493_2.png) [@Parco](https://www.debian-fr.org/u/Parco)\
**Post date:** [Novembre 16, 2018, 11:26 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/11 "2018-11-16T11:26:15Z")

</div>

Du coup exécute les même commandes mais avec mpm\_event

---

<div class="post-metadata">

**Author:** ![nimant](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/n/e19adc/32.png) [@nimant](https://www.debian-fr.org/u/nimant)\
**Post date:** [Novembre 16, 2018, 11:27 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/12 "2018-11-16T11:27:08Z")

</div>

roo@iab\>a2dismod mpm\_event  
Module mpm\_event disabled.  
To activate the new configuration, you need to run:  
systemctl restart apache2  
roo@iab\>systemctl restart apache2  
Job for apache2.service failed because the control process exited with error code.  
See “systemctl status apache2.service” and “journalctl -xe” for details.

---

<div class="post-metadata">

**Author:** ![mattotop](https://www.debian-fr.org/user_avatar/www.debian-fr.org/mattotop/32/3942_2.png) [@mattotop](https://www.debian-fr.org/u/mattotop)\
**Post date:** [Novembre 16, 2018, 11:33 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/13 "2018-11-16T11:33:11Z")

</div>

> [@nimant](#):
>
> Comment reinstaller apache2

Mais non, attends, c’est juste une question de réglages.

> [@nimant](#):
>
> Module mpm\_event is enabled

C’est donc ce modèle là qui pose problème: **a2dismod mpm\_event**

> [@nimant](#):
>
> Considering dependency mpm\_prefork for php7.2

Il veut du prefork ? Donnons lui du prefork: **a2enmod mpm\_prefork**

Et aprés: **a2enmod php7.2** devrait passer mieux.  
Un petit **systemctl restart apache2** à la fin, pour voir si l’apache repart bien.

Et sinon, le mpm\_worker à tester.

---

<div class="post-metadata">

**Author:** ![nimant](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/n/e19adc/32.png) [@nimant](https://www.debian-fr.org/u/nimant)\
**Post date:** [Novembre 16, 2018, 11:38 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/14 "2018-11-16T11:38:02Z")

</div>

a2dismod mpm\_event  
a2enmod mpm\_prefork  
a2enmod php7.2  
systemctl restart apache2

tout se passe bien, sauf que php n’est toujours pas reconnu !

---

<div class="post-metadata">

**Author:** ![Parco](https://www.debian-fr.org/user_avatar/www.debian-fr.org/parco/32/7493_2.png) [@Parco](https://www.debian-fr.org/u/Parco)\
**Post date:** [Novembre 16, 2018, 12:18 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/15 "2018-11-16T12:18:38Z")

</div>

> ls -l /var/www/html/«&nbsp;ton\_fichier.php&nbsp;»

Il doit posséder les droits suivants :

> -rwxr-xr-x 1 www-data www-data

Commandes basiques linux pour faire cela :

> sudo chmod 755 /var/www/html/«&nbsp;ton\_fichier.php&nbsp;»  
> sudo chown www-data: /var/www/html/"ton\_fichier.php

Si cela ne fonctionne toujours pas, deux options :

- Regarder les logs dans /var/log/apache2/
- Afficher les erreurs dans php.ini

Les logs sont généralement **access.log** et **error.log**

Si cela ne donne rien, modifie le fichier php.ini

> sudo nano/vim/emacs /etc/php/7.2/apache2/php.ini

Cherche la ligne **display\_errors** ( ligne 477 sur mon PC ) et modifie la en lui mettant On  
Comme ceci :

> display\_errors = On

Puis restart apache2

> sudo systemctl restart apache2

---

<div class="post-metadata">

**Author:** ![nimant](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/n/e19adc/32.png) [@nimant](https://www.debian-fr.org/u/nimant)\
**Post date:** [Novembre 16, 2018, 1:24 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/16 "2018-11-16T13:24:17Z")

</div>

Je viens de reinstaller la 9.6 : même problème mais seulement avant d’installer php …  
apt-get install phpmyadmin installe php7.0 (et pas php7.2)  
Hello World fonctionne !  
J’avais donc un mélange de php7.0 et php7.2 dans la précédente version de Stretch.

---

<div class="post-metadata">

**Author:** ![Ksynet](https://www.debian-fr.org/user_avatar/www.debian-fr.org/ksynet/32/12919_2.png) [@Ksynet](https://www.debian-fr.org/u/Ksynet)\
**Post date:** [Novembre 17, 2018, 1:27 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/18 "2018-11-17T13:27:13Z")

</div>

faudra déjà m’expliquer pour quoi print au lieu de echo …  
Et il faut penser aux modules activés pour apache… moi je zappe régulièrement entre 7.1 et 7.2.  
Une petite ligne commande et hop.

---

<div class="post-metadata">

**Author:** ![Valbou](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/v/4bbf92/32.png) [@Valbou](https://www.debian-fr.org/u/Valbou)\
**Post date:** [Novembre 20, 2018, 8:03 UTC](https://www.debian-fr.org/t/stretch-9-6-apache2-2-4-ne-reconnait-pas-le-php/77998/19 "2018-11-20T08:03:08Z")

</div>

Bonjour,  
print() ou echo effectivement.  
print sous cette forme ça ressemble plus à du Python 2 😉
