====== Installer Apache et PHP7 sur macOS Mojave ====== * [[https://medium.com/@crmcmullen/how-to-install-php-on-macos-10-13-high-sierra-and-10-14-mojave-using-homebrew-and-pecl-ef2276db3d62]] * ([[https://www.dyclassroom.com/howto-mac/how-to-install-apache-mysql-php-on-macos-mojave-10-14]]) Installation avec Brew. ==== Installer Apache ==== 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 !//. ==== Configurer Apache ==== 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. ==== Installer PHP ==== 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 DirectoryIndex index.html par DirectoryIndex index.php index.html SetHandler application/x-httpd-php 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. ==== Avoir la bonne version de PHP en ligne de commande ==== echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.zshrc