07 - PHP
PHP komplett deinstallieren
Schauen was ist installiert: brew list | grep php. Uralte php Versionen entfernen / altes Homebrew Schema:
brew untap exolnet/deprecated
brew uninstall --force php56 php56-apcu php56-opcache php56-xdebug php56-yaml
brew uninstall --force php70 php70-apcu php70-opcache php70-xdebug php70-yaml
brew uninstall --force php71 php71-apcu php71-opcache php71-xdebug php71-yaml
brew uninstall --force php72 php72-apcu php72-opcache php72-xdebug php72-yaml
brew uninstall --force php73 php73-apcu php73-opcache php73-xdebug php73-yaml
brew uninstall --force php74 php74-apcu php74-opcache php74-xdebug php74-yamlWeitere zu entfernende Versionen waren bei mir:
brew uninstall --force php@7.3
uninstall --force phpmyadmin
rm -Rf /usr/local/etc/php/\*Jetzt ist das System wieder sauber, und alles kann neu installiert werden:
PHP Versionen installieren
welche php Versionen sind installiert?
brew search phpIm Terminal
brew tap shivammathur/php
brew install shivammathur/php/php@7.4
brew install shivammathur/php/php@8.0Ich habe 7.4 und 8.0 installiert. Auch wenn mehrere Versionen installiert sind, ist immer nur eine PHP Version aktiv.
wenn PHP zuerst im PATH sein soll:
echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.zshrcAusserdem:
pecl install memcachedphp.ini bearbeiten
codium /usr/local/etc/php/7.4/php.ini
codium /usr/local/etc/php/8.0/php.ini
date.timezone = Europe/BerlinDas Terminal schließen, und ein neues Terminal öffnen.
Prüfe die Version
php -v
which phpwhich php Liefert den Pfad zum executable: /usr/local/bin/php
Apache Module
codium /usr/local/etc/httpd/httpd.confINFO: Das bleibt neuerdings alles auskommentiert. Keine Ahnung wieso.
#LoadModule php5_module /usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so
#LoadModule php7_module /usr/local/opt/php@7.0/lib/httpd/modules/libphp7.so
#LoadModule php7_module /usr/local/opt/php@7.1/lib/httpd/modules/libphp7.so
#LoadModule php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so
LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.sound
DirectoryIndex index.php index.html
SetHandler application/x-httpd-phpDann den Server neu starten.
sudo apachectl -k stop
sudo apachectl startPHP Versionen umschalten
Dazu gibt es das kompfortables Skript sphp das du zunächst installieren musst:
curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw > /usr/local/bin/sphp
chmod +x /usr/local/bin/sphpPfad prüfen
echo $PATHDer sollte so aussehen: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Umschalten von einer der aktiven PHP Version zB. auf 7.4 oder auf 8.0 - falls die installiert sind:
sphp 7.4
php -v
sphp 8.0
php -vEine etwas “komplizierte Art” der Umschaltung ohne sphp Skript, im Terminal:
brew unlink php && brew link --overwrite --force php@7.4
brew unlink php && brew link --overwrite --force php@8.0PHP Version aktualisieren
Es ist immer nur eine PHP Version aktiv. Um alle installierten PHP Version zu aktuallisieren muss du jeweils zur Version wechseln und dann das Update dafür ausführen.
php als Dienst starten
brew services start phpoder php-fpm wenn du keinen Dienst benötigst.