# Configurer PHP (mod-php)(Apache 2.2-) #### php.ini Mac intel: ```bash $ nano /usr/local/etc/php/7.4/php.ini $ nano /usr/local/etc/php/8.0/php.ini ``` Mac M1: ```bash $ nano /opt/homebrew/etc/php/7.4/php.ini $ nano /opt/homebrew/etc/php/8.0/php.ini ``` ```ini [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = Europe/Paris ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Error handling and logging ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; error_log = php_errors.log ;;;;;;;;;;;;;;;;;;; ; Resource Limits ; ;;;;;;;;;;;;;;;;;;; memory_limit = 512M ``` #### Modifier le httpd.conf: Mac intel: ```bash $ nano /usr/local/etc/httpd/httpd.conf ``` Mac M1: ```bash $ nano /opt/homebrew/etc/httpd/httpd.conf ``` Dans *httpd.conf*, ajouter les lignes: Mac intel: ```http LoadModule php7_module /usr/localopt/php@7.4/lib/httpd/modules/libphp7.so #LoadModule php_module /usr/local/opt/php@8.0/lib/httpd/modules/libphp.so ``` Mac M1: ```http LoadModule php7_module /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so #LoadModule php_module /opt/homebrew/opt/php@8.0/lib/httpd/modules/libphp.so ``` intel / M1: Remplacer: ```http DirectoryIndex index.html ``` par ```http DirectoryIndex index.php index.html SetHandler application/x-httpd-php ``` ### Changer de version: #### Méthode 1: ```bash $ brew unlink php && brew link --overwrite --force php@7.4 ``` #### Méthode 2: *PHP switcher script* Installation Mac intel: ```bash $ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/0c36a5067fbd63e6a36700a6aaa119df0836bdfc/sphp.sh > /usr/local/bin/sphp $ chmod +x /usr/local/bin/sphp ``` Installation Mac M1: ```bash $ curl -L https://raw.githubusercontent.com/vadimbk/sphp/main/sphp > /opt/homebrew/bin/sphp $ chmod +x /opt/homebrew/bin/sphp ``` Utilisation: ```bash $ sphp 7.4 ``` #### Xdebug ##### Installation: ```bash $ sphp 8.2 $ pecl uninstall -r xdebug $ pecl install xdebug ``` ```bash $ sphp 8.3 $ pecl uninstall -r xdebug $ pecl install xdebug-3.3.0alpha3 ``` ##### Configuration: ```bash $ bbedit /opt/homebrew/etc/php/8.2/conf.d/ext-xdebug.ini $ bbedit /opt/homebrew/etc/php/8.3/conf.d/ext-xdebug.ini ``` ```http [xdebug] zend_extension="xdebug.so" xdebug.mode=debug ``` #### Xdebug Switcher: ##### Installation: ```bash $ curl -L https://gist.githubusercontent.com/rhukster/073a2c1270ccb2c6868e7aced92001cf/raw/c1629293bcf628cd6ded20c201c4ef0a2fa79144/xdebug > /opt/homebrew/bin/xdebug $ chmod +x /opt/homebrew/bin/xdebug ``` ```bash $ xdebug Usage: xdebug [--no-server-restart] You are running PHP v8.2 with Xdebug enabled PHP 8.2.14 (cli) (built: Dec 20 2023 06:28:06) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.14, Copyright (c) Zend Technologies with Zend OPcache v8.2.14, Copyright (c), by Zend Technologies with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans ``` #### APCu ##### Installation: ```bash $ pecl install apcu # fatal error: 'pcre2.h' file not found $ ln -s /opt/homebrew/Cellar/pcre2/10.42/include/pcre2.h /opt/homebrew/Cellar/php/ $ ln -s /opt/homebrew/opt/pcre2/include/pcre2.h /opt/homebrew/opt/php@8.4/include/php/ext/pcre/ ln -s /opt/homebrew/Cellar/pcre2/10.42/include/pcre2.h /opt/homebrew/Cellar/php/8.3.1/include/php/ext/pcre/pcre2.h ln -s /opt/homebrew/Cellar/pcre2/10.42/include/pcre2.h /opt/homebrew/Cellar/php@8.2/8.2.14/include/php/ext/pcre/pcre2.h ``` ```bash $ sphp 8.2 $ pecl install apcu ``` ```bash $ sphp 8.3 $ pecl uninstall -r apcu $ pecl install apcu ``` ##### Configuration: ```bash $ bbedit /opt/homebrew/etc/php/8.2/conf.d/ext-apcu.ini $ bbedit /opt/homebrew/etc/php/8.3/conf.d/ext-apcu.ini ``` ```http [apcu] extension="apcu.so" apc.enabled=1 apc.shm_size=64M apc.ttl=7200 apc.enable_cli=1 ``` #### YAML Installation: ```bash $ brew install libyaml ``` ```bash $ sphp 8.2 $ pecl install yaml # Au prompt "Please provide the prefix of libyaml installation [autodetect]", entrer: # /opt/homebrew/Cellar/libyaml/0.2.5 ``` ```bash $ sphp 8.3 $ pecl uninstall -r yaml $ pecl install yaml # Au prompt "Please provide the prefix of libyaml installation [autodetect]", entrer: # /opt/homebrew/Cellar/libyaml/0.2.5 ``` ##### Configuration: ```bash $ bbedit /opt/homebrew/etc/php/8.2/conf.d/ext-yaml.ini $ bbedit /opt/homebrew/etc/php/8.3/conf.d/ext-yaml.ini ``` ```http [yaml] extension="yaml.so" ```