php:install-macos-mojave

Ceci est une ancienne révision du document !


Installer Apache et PHP7 sur macOS Mojave

Arrêter le Apache natif de macOS:

sudo apachectl stop

Installer Apache avec Homebrew:

brew install httpd

Lancer le service Apache:

brew services start https

En allant sur http://localhost:8080, il devrait s'afficher le classique It works !.

Modifier le fichier /usr/local/etc/httpd/httpd.conf:

  • remplacer le Listen 8080 par Listen 80
  • décommenter pour les charger les modules deflate_module et rewrite_module.
  • Remplacer le User par le login de l'utilisateur actuel
  • Remplacer le Group par staff
  • Changer DocumentRoot et le Directory juste en-dessous par un chemin qui convient

Redémarrer Apache:

sudo apachectl restart

Tout devrait fonctionner en allant sur http://localhost.

brew install php@7.2

Dans le fichier /usr/local/etc/httpd/httpd.conf, ajouter le module PHP7, à la fin de la liste des modules:

LoadModule php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so

Dans ce même fichier, remplacer

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

par

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

Démarrer le service PHP:

brew services start php@7.2

Redémarrer Apache:

sudo apachectl restart

Tout devrait fonctionner en allant sur une page PHP.

echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.zshrc
  • php/install-macos-mojave.1545580160.txt.gz
  • Dernière modification : 2021/04/04 17:01
  • (modification externe)