15-09-2021
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
# Installer PHP (homebrew)
|
||||
# php
|
||||
|
||||
### Installation:
|
||||
|
||||
|
||||
### Installer PHP (homebrew)
|
||||
|
||||
#### Installation:
|
||||
|
||||
Ajouter le tap:
|
||||
|
||||
@@ -12,112 +16,36 @@ $ brew update
|
||||
Installer différentes versions de PHP:
|
||||
|
||||
```bash
|
||||
$ brew install shivammathur/php/php@7.4
|
||||
$ brew install shivammathur/php/php@7.4 # installe également la formule php@7.4
|
||||
$ brew link --overwrite --force php@7.4
|
||||
```
|
||||
|
||||
```bash
|
||||
$ brew install shivammathur/php/php@8.0
|
||||
$ brew link --overwrite --force php@8.0
|
||||
$ brew install shivammathur/php/php # installe également la formule php (8.0)
|
||||
$ brew link --overwrite --force php
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Configurer PHP:
|
||||
### Configurer php sous serveur Apache:
|
||||
|
||||
Mac intel:
|
||||
1. [mod-php](mod-php.md)
|
||||
|
||||
2. [php-fpm](php-fpm.md)
|
||||
|
||||
|
||||
|
||||
### Redémarrer PHP:
|
||||
|
||||
```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
|
||||
brew services restart shivammathur/php/php # php 8.0
|
||||
brew services restart shivammathur/php/php@7.4
|
||||
brew services restart shivammathur/php/php@8.1
|
||||
```
|
||||
|
||||
|
||||
|
||||
```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
|
||||
<IfModule dir_module>
|
||||
DirectoryIndex index.html
|
||||
</IfModule>
|
||||
```
|
||||
|
||||
par
|
||||
|
||||
```http
|
||||
<IfModule dir_module>
|
||||
DirectoryIndex index.php index.html
|
||||
</IfModule>
|
||||
|
||||
<FilesMatch \.php$>
|
||||
SetHandler application/x-httpd-php
|
||||
</FilesMatch>
|
||||
```
|
||||
|
||||
Redémarrer le serveur web:
|
||||
### Redémarrer le serveur web:
|
||||
|
||||
- pour Apache (httpd): `brew services restart httpd`
|
||||
- pour Nginx: `brew services restart nginx`
|
||||
@@ -130,45 +58,14 @@ echo "<?php phpinfo();" > ~/Sites/info.php
|
||||
|
||||
et aller sur http://localhost/info.php
|
||||
|
||||
- mod-php: `Server API: Apache 2.0 Handler`
|
||||
- php-fpm: `Server API: FPM/FastCGI`
|
||||
|
||||
Si PHP n'est pas interprété, redémarrer le mac.
|
||||
|
||||
|
||||
|
||||
### 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
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Version de PHP:
|
||||
### Version de PHP:
|
||||
|
||||
```bash
|
||||
$ php -v
|
||||
@@ -187,7 +84,7 @@ $ php -i
|
||||
|
||||
|
||||
|
||||
#### Logs:
|
||||
### Logs:
|
||||
|
||||
```bash
|
||||
/opt/homebrew/var/log/php-fpm.log
|
||||
@@ -232,7 +129,8 @@ xdebug.mode=debug
|
||||
$ brew install apcu@8.0
|
||||
|
||||
# Fichier config
|
||||
/opt/homebrew/etc/php/8.0/conf.d/apcu.ini
|
||||
/opt/homebrew/etc/php/8.0/conf.d/apcu.ini # M1
|
||||
/usr/local/etc/php/8.0/conf.d/apcu.ini # intel
|
||||
```
|
||||
|
||||
```bash
|
||||
@@ -254,7 +152,8 @@ apc.enable_cli=1
|
||||
$ brew install imagick@8.0
|
||||
|
||||
# Fichier config
|
||||
/opt/homebrew/etc/php/8.0/conf.d/imagick.ini
|
||||
/opt/homebrew/etc/php/8.0/conf.d/imagick.ini # M1
|
||||
/usr/local/etc/php/8.0/conf.d/imagick.ini # intel
|
||||
```
|
||||
|
||||
```bash
|
||||
@@ -272,7 +171,8 @@ extension="/opt/homebrew/opt/imagick@8.0/imagick.so"
|
||||
$ brew install memcached@8.0
|
||||
|
||||
# Fichier config
|
||||
/opt/homebrew/etc/php/7.4/conf.d/memcached.ini
|
||||
/opt/homebrew/etc/php/7.4/conf.d/memcached.ini # M1
|
||||
/usr/local/etc/php/8.0/conf.d/memcached.ini # intel
|
||||
```
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user