06-08-20121

This commit is contained in:
2021-08-06 13:32:29 +02:00
parent 53aa196ac1
commit 7d89fb0224
14 changed files with 2297 additions and 46 deletions

225
docs/Divers/alfred.md Normal file
View File

@@ -0,0 +1,225 @@
# Alfred
### StackExchange Search for Alfred
https://github.com/deanishe/alfred-stackexchange
- `stack [<query>]` — Choose a StackExchange site to search.
- `↩` — Select site
- `⌘↩` — Set as default site
- `⌥↩` — Reveal site icon in Finder
- `⌘C` — Copy site ID to clipboard (for adding Script Filters)
- `.so <query>` — Search StackOverflow.com for `<query>`. See below for syntax.
- `↩` or `⌘+NUM` — Open result in default browser
- `⌘L` — Show full question title in Alfred's Large Text window
Prefix a word in your `<query>` with `.` (full stop) to indicate that it's a tag, e.g `requests .python` will search for answers tagged `python` with the query `requests`.
### GitHub Repos workflow for Alfred
http://www.packal.org/workflow/github-repos
- `gh <query>` — Recherche globale
- `repo <query>` — Recherche dans repos perso
### Google Suggest
- `g <query>`
### Amazon Suggest
- `amazon <query>`
### Search Notes.app with Alfred
https://github.com/sballin/alfred-search-notes-app
- `n <query>` — Recherche un titre ou crée une nouvelle note si non trouvée
- `nb <query>` — Recherche dans les titres et les corps
- `nf <query>` — Recherche nom de dossier
#### Result actions
- **enter** to open the note/folder or create a new note if none was found
- **shift+enter** to search for your Alfred query using the Notes in-app search
- **cmd+enter** to copy the note body to the clipboard
- **alt+enter** to copy a link to the note to the clipboard
#### Note linking
You can generate links to any of your notes and use them on macOS or iOS. Copy the note URL by pressing alt+enter on an Alfred result or paste it using the snippet. This will generate two links. The first one works on macOS Big Sur (11) and newer, and the second one works on iOS.
### Font Awesome workflow for Alfred
https://github.com/ruedap/alfred-font-awesome-workflow
### RemoveQuarantine
https://github.com/vitorgalvao/alfred-workflows/tree/master/RemoveQuarantine
- `rq`
### Intégration iTerm2 à Alfred
https://github.com/vitorgalvao/custom-alfred-iterm-scripts
### Alfred Keywords
https://github.com/pochemuto/alfred-help-workflow
- `?` — affiche tous les mots-clés de tous les workflows
### alfred-show-network-info
https://github.com/jeppestaerk/alfred-show-network-info
- `ip4`
### Alfred Password Generator
https://github.com/deanishe/alfred-pwgen
- `pwgen [<strength>]`
- `pwlen [<length>]`
- `pwconf [<query>]`
### Mac App Store Search
http://www.packal.org/workflow/mac-app-store-search
- `mas <query>`
## Cheatsheet
https://github.com/mutdmour/alfred-workflow-cheatsheet
# alfred-amphetamine
https://github.com/demartini/alfred-amphetamine
### Alfred Browser Tabs
https://github.com/epilande/alfred-browser-tabs
### Joplin Noteplan Actions
https://github.com/beet/joplin_alfred_actions
### Play Song
https://github.com/caleb531/play-song
- `playsong hey jude` — Playing a song
- `playsongin abbey road` — playsongin abbey road
- `playsongby beatles` — playsongby beatles
- `playalbum pet sounds` — Playing an album
- `playalbumby beach boys` — playalbumby beach boys
- `playartist killers` — Playing an artist
- `playgenre alternative` — Playing a genre
- `playplaylist favorites` — Playing a playlist
- `shuffleon` — Controlling the Music app's global shuffle setting
`shuffleoff`
`shuffletoggle`
### Search-Alfred-Workflows
https://github.com/Acidham/search-alfred-workflows
- alf <request>
- `ENTER` — Shows a list of keywords in the workflow and starts the workflow with a keyword
- `SHIFT` — Shows the workflow description , associated keywords and keyboard Shortcuts
- `CMD` — For addtional Actions:
- Copy path to Clipboard
- Open WF Folder in Terminal
- If you would like to use other terminal than macOS terminal.app change config in Alfred > Features > Terminal to custom
- Reveal in Finder
- Open in FileManager (if defined)
##
# alfred-markdown-search
https://github.com/leafney/alfred-markdown-search
- `mdd` — les 20 derniers fichiers
- `mdd -t php` — recherche par mot-clé dans le titre
- `mdd php` — recherche pleine par mot-clé
- `mdd -t golang python` — recherche 'golang' dans le titre et 'python' dans le contenu
- `mdd -t golang,python`— recherche 'golang' et 'python' dans le titre
- `mdd -t golang,python mysql` — recherche 'golang' et 'python' dans le titre , et 'mysql' dans le contenu
## alfred tldr
https://github.com/konoui/alfred-tldr
- `tldr` <query>
Options
`--version`/`-v` option shows the current version of the client.
`--update`/`-u` option updates local database (tldr repository).
`--platform`/`-p` option selects platform from `linux`,`osx`,`sunos`,`windows`.
`--language`/`-L` option selects preferred language for the page.
##
### Alfred Sonos Controller
https://github.com/karimkaylani/alfred-sonoscontroller
- `soco`
### alfred-wordpress-developer-workflow
https://github.com/keesiemeijer/alfred-wordpress-developer-workflow
### Sublime Text Projects Alfred Workflow
https://github.com/deanishe/alfred-sublime-text
### alfred_remote_IINA_Controller
https://github.com/qiujie8092916/alfred_remote_IINA_Controller
https://pacmax.org

39
docs/Divers/tmux.md Normal file
View File

@@ -0,0 +1,39 @@
# tmux
```bash
$ tmux
```
Ctrl + B -> mode Commande
Ctrl + B puis % : partage l'écran en 2
Ctrl + B puis -> / <- : passe d'un terminal à l'autre
#### Intégration iTerm2
```bash
$ tmux -CC
```
Ouvre une 2e fenêtre, un terminal tmux
Ctrl + clic sur la fenêtre, choisir *Split Pane Vertically*
On passe d'un panneau à l'autre par un simple clic.
On ferme la fenêtre -> choisir Detach tmux Session
Sur la 1e fenêtre
```bash
$ tmux -CC attach
```
On retrouve la 2e fenêtre dans le même état (la session précédente est restaurée).

565
docs/Divers/zsh/plugins.md Normal file
View File

@@ -0,0 +1,565 @@
# ZSH Plugins
### Plugins (installés)
#### You Should Use *
https://github.com/MichaelAquilina/zsh-you-should-use
```bash
antibody bundle MichaelAquilina/zsh-you-should-use
```
```bash
zinit light MichaelAquilina/zsh-you-should-use
```
```bash
# Config:
export YSU_MESSAGE_POSITION="after"
# %alias_type: alias, git alias, global alias
# %command: la commande entrée
# %alias: l'alias trouvé
export YSU_MESSAGE_FORMAT="$(tput setaf 1)Hey! I found this %alias_type for %command: %alias$(tput sgr0)"
# Fonctions
check_alias_usage
```
[alias-type](https://github.com/djui/alias-tips)
#### zsh-fast-alias-tips *
```bash
```
```bash
zinit ice from'gh-r' as'program'
zinit light sei40kr/fast-alias-tips-bin
zinit light sei40kr/zsh-fast-alias-tips
```
| Variable | Default value | Description |
| ------------------------ | ------------------ | ---------------------- |
| `FAST_ALIAS_TIPS_PREFIX` | `"💡 $(tput bold)"` | The prefix of the Tips |
| `FAST_ALIAS_TIPS_SUFFIX` | `"$(tput sgr0)"` | The suffix of the Tips |
#### diractions *
https://github.com/AdrieanKhisbe/diractions
```bash
antibody bundle "adrieankhisbe/diractions"
```
```bash
zinit light adrieankhisbe/diractions
```
```bash
# Editer fichier .diractions (folders)
nano ~/.diractions
# sauver répertoire courant avec le nom <mkdocs>
diraction save mkdocs
```
#### zsh colored man pages *
https://github.com/ael-code/zsh-colored-man-pages
```bash
antibody bundle ael-code/zsh-colored-man-pages
```
```bash
zinit light ael-code/zsh-colored-man-pages
```
#### shell-plugins (profile-secrets)*
https://github.com/gmatheu/shell-plugins
```bash
zinit snippet 'https://raw.githubusercontent.com/gmatheu/shell-plugins/master/profile-secrets/init.zsh'
```
```bash
# Fichier des secrets par défaut:
~/.profile-secrets/secrets.sh
```
Fonctions:
```bash
# décrypte le fichier des secrets
profile-secrets-decrypt: Decrypts secret file.
# encrypte le fichier des secrets (ou le crée lors du 1er lancement)
profile-secrets-encrypt: Encrypts secret file. First time it is called will create secrets file
# ajoute les variables secrets à la session courante
profile-secrets-source: Decrypts secrets file, source it and encrypts it back.
```
#### Bol *
https://github.com/ikhurramraza/bol
```bash
zinit light ikhurramraza/bol
```
```bash
$ bol print
Kuch bhi hojaye na, to kuch nahi hota
— Urwa Hocane
```
```bash
$ cd /Users/bruno/.zinit/plugins/ikhurramraza---bol/quotes/
drwxr-xr-x 3 bruno staff 96 jul 31 21:28 Bollywood
drwxr-xr-x 3 bruno staff 96 jul 31 21:28 Motivation
drwxr-xr-x 4 bruno staff 128 jul 31 21:28 Originals
drwxr-xr-x 4 bruno staff 128 jul 31 21:28 Seinfeld
drwxr-xr-x 3 bruno staff 96 jul 31 21:28 Supernatural
drwxr-xr-x 3 bruno staff 96 jul 31 21:28 TVD
-rw-r--r-- 1 bruno staff 109 aoû 1 22:10 jvc.txt
```
#### zsh-notify *
https://github.com/marzocchi/zsh-notify
```bash
antibody bundle marzocchi/zsh-notify
```
```bash
zinit light marzocchi/zsh-notify
```
```bash
zstyle ':notify:*' error-icon "https://media3.giphy.com/media/10ECejNtM1GyRy/200_s.gif"
zstyle ':notify:*' error-title "Command failed (in #{time_elapsed} seconds)"
zstyle ':notify:*' success-icon "https://s-media-cache-ak0.pinimg.com/564x/b5/5a/18/b55a1805f5650495a74202279036ecd2.jpg"
zstyle ':notify:*' success-title "Command finished (in #{time_elapsed} seconds)"
zstyle ':notify:*' error-sound "Glass"
zstyle ':notify:*' success-sound "default"
```
[auto-notify](https://github.com/MichaelAquilina/zsh-auto-notify)
#### forgit *
https://github.com/wfxr/forgit
```bash
antibody bundle wfxr/forgit
```
- **Interactive `git add` selector** (`ga`)
- **Interactive `git log` viewer** (`glo`)
- **Interactive `.gitignore` generator** (`gi`)
- **Interactive `git diff` viewer** (`gd`)
- **Interactive `git reset HEAD <file>` selector** (`grh`)
- **Interactive `git checkout <file>` selector** (`gcf`)
- **Interactive `git checkout <branch>` selector** (`gcb`)
- **Interactive `git checkout <commit>` selector** (`gco`)
- **Interactive `git stash` viewer** (`gss`)
- **Interactive `git clean` selector** (`gclean`)
- **Interactive `git cherry-pick` selector** (`gcp`)
- **Interactive `git rebase -i` selector** (`grb`)
- **Interactive `git commit --fixup && git rebase -i --autosquash` selector** (`gfu`)
####
#### Fast Syntax Highlighting *
https://github.com/zdharma/fast-syntax-highlighting
```bash
antibody bundle zdharma/fast-syntax-highlighting
```
```bash
zinit light zdharma/fast-syntax-highlighting
```
```bash
# liste des themes
fast-theme -l
Found existing alias for "fast-theme". You should use: "fsh-alias"
Available themes:
clean
default
forest
free
q-jmnemonic
safari
spa
sv-orple
sv-plant
zdharma
# changer de thème
fast-theme -t <theme-name>
```
#### history-search-multi-word *
https://github.com/zdharma/history-search-multi-word
```bash
zinit load zdharma/history-search-multi-word
```
```
Ctrl-R
```
```bash
hist
Ctrl-K context, Ctrl-J bump. Entry #1 of 50
> abspath .zsh_history
history | grep man
history | grep curl
history
history | tail
history -x
antibody purge jimeh/zsh-peco-history
cd zsh-history-enquirer
cd zsh-directory-history
which zsh-history-enquirer
npm i -g zsh-history-enquirer
antibody purge tymm/zsh-directory-history
```
#### zsh-autosuggestions *
https://github.com/zsh-users/zsh-autosuggestions
```bash
antibody bundle zsh-users/zsh-autosuggestions
```
```bash
zinit light zsh-users/zsh-autosuggestions
```
```bash
Touche ->
```
#### zsh-completions *
https://github.com/zsh-users/zsh-completions
```bash
antibody bundle zsh-users/zsh-completions
```
```bash
zinit light zsh-users/zsh-completions
```
#### venv-wrapper *
https://github.com/glostis/venv-wrapper
```
zinit light glostis/venv-wrapper
```
```bash
# Créer un venv
venv test2
Virtual environment `test2` does not exist.
Do you want to create it? [y/n]y
Created and activated venv test2
# Supprimer un venv
rmvenv test2
Removed venv test2
# Liste des venv
venv
Type `venv name_of_env` to activate a virtual environment.
Here is the list of existing virtual environments:
--------------------------------------------------
test
# Activer un venv
venv test
~/Documents/venv 06:59:57
test
# Variables
$VENV_WRAPPER_PYTHON
```
!!! info
export PATH="$HOME/Documents/venv/soco-cli/bin:$PATH"
#### web-search *
https://github.com/sineto/web-search
```bash
zinit snippet 'https://raw.githubusercontent.com/sineto/web-search/master/web_search.plugin.zsh'
```
```
google <search>
ddg <search>
github <search>
youtube <search>
```
#### z-a-man *(marche pas)
https://github.com/zinit-zsh/z-a-man
```bash
zinit light zinit-zsh/z-a-man
```
```bash
# View README.md manpage in the terminal
zman z-a-man
# View the code documentation (via the full plugin name, as demonstrated)
zman -c zinit-zsh/z-a-man
```
### Plugins (autres)
#### FM
https://github.com/ddnexus/fm
```bash
antibody bundle ddnexus/fm
```
#### zshmarks
https://github.com/jocelynmallon/zshmarks
```bash
antibody bundle jocelynmallon/zshmarks
```
#### zsh-history-substring-search
https://github.com/zsh-users/zsh-history-substring-search
```bash
antibody bundle zsh-users/zsh-history-substring-search
```
#### zsh-peco-history
https://github.com/jimeh/zsh-peco-history
```bash
antibody bundle jimeh/zsh-peco-history
```
#### zsh-history-enquirer
https://github.com/zthxxx/zsh-history-enquirer
```bash
npm i -g zsh-history-enquirer
echo 'source `npm root -g`/zsh-history-enquirer/scripts/zsh-history-enquirer.plugin.zsh' >> ~/.zshrc
```
```
Ctrl-R
```
#### antibody-completion
https://github.com/sinetoami/antibody-completion
```
antibody bundle sinetoami/antibody-completion
```
#### zsh-async
https://github.com/mafredri/zsh-async
```bash
antibody bundle mafredri/zsh-async
```
#### mysql.plugin.zsh
https://github.com/voronkovich/mysql.plugin.zsh
```bash
antibody bundle voronkovich/mysql.plugin.zsh
```
#### zsh-autocomplete
https://github.com/marlonrichert/zsh-autocomplete
```bash
antibody bundle marlonrichert/zsh-autocomplete
```
#### zsh-notes
https://github.com/aperezdc/zsh-notes
```
antibody bundle aperezdc/zsh-notes
```
#### Interactive-cd
https://github.com/changyuheng/zsh-interactive-cd
#### Link File Plugin
https://github.com/JaumeRF/linkfile-zsh
#### zsh-lux
https://github.com/pndurette/zsh-lux
```bash
antibody bundle pndurette/zsh-lux
```
#### Shelf
https://github.com/ecmma/shelf
```bash
antibody bundle ecmma/shelf
```
```bash
```
### Thèmes
#### Powerlevel10k
https://github.com/romkatv/powerlevel10k/#antibody
```bash
antibody bundle romkatv/powerlevel10k
```
```bash
zinit ice depth"1" # git clone depth
zinit light romkatv/powerlevel10k
```
#### Pure
https://github.com/sindresorhus/pure
```bash
antibody bundle sindresorhus/pure
```
### Plugins Managers
#### Zinit *
https://github.com/zdharma/zinit (2021) (zpluggin)*
#### zplug
https://github.com/zplug/zplug (R2017)(2020)*
https://github.com/zpm-zsh/zpm (2021)
https://github.com/tarjoilija/zgen (2018)
https://github.com/zsh-users/antigen (2018)
https://github.com/sorin-ionescu/prezto (2021)
https://github.com/getantibody/antibody (2020)
####
### Liens
https://github.com/unixorn/awesome-zsh-plugins
https://learnpracticeandshare.com/awesome-zsh-plugins-massive-collection-of-resources/#alf

129
docs/Divers/zsh/zinit.md Normal file
View File

@@ -0,0 +1,129 @@
# zinit
For more information see:
- README section on the ice-modifiers:
- https://github.com/zdharma/zinit#ice-modifiers,
- intro to Zinit at the Wiki:
- https://zdharma.org/zinit/wiki/INTRODUCTION/,
- zinit-zsh GitHub account, which holds all the available Zinit annexes:
- https://github.com/zinit-zsh/,
- For-Syntax article on the Wiki; it is less directly related to the ices, however, it explains how to use them conveniently:
- https://zdharma.org/zinit/wiki/For-Syntax/.
```bash
Downloading zinit-zsh/z-a-rust…
▹▸▹▹▹ ███████████ OBJ: 100, PACK: 0/153, COMPR: 100%
Note: Compiling: z-a-rust.plugin.zsh… OK.
Downloading zinit-zsh/z-a-as-monitor…
▝ ███████████ OBJ: 100, PACK: 0/333, COMPR: 100%
Note: Compiling: z-a-readurl.plugin.zsh… OK.
Downloading zinit-zsh/z-a-patch-dl…
▐ ███████████ OBJ: 100, PACK: 0/105, COMPR: 100%
Note: Compiling: z-a-patch-dl.plugin.zsh… OK.
Downloading zinit-zsh/z-a-bin-gem-node…
▍ ███████████ OBJ: 100, PACK: 0/530, COMPR: 100%
Note: Compiling: z-a-bin-gem-node.plugin.zsh… OK.
bruno@airbook ~ %
```
```bash
zinit zstatus
Found existing alias for "zinit". You should use: "zini"
Zinit's main directory: /Users/bruno/.zinit
Zinit's binary directory: /Users/bruno/.zinit/bin
Plugin directory: /Users/bruno/.zinit/plugins
Completions directory: /Users/bruno/.zinit/completions
Loaded plugins: 13
Light loaded: 4
Downloaded plugins: 14
Enabled completions: 148
Disabled completions: 0
Completions available overall: 152
Snippets loaded:
Compiled plugins: 13
```
```bash
zinit times
Found existing alias for "zinit". You should use: "zini"
Plugin loading times:
1 ms - zinit-zsh/z-a-rust
1 ms - zinit-zsh/z-a-as-monitor
1 ms - zinit-zsh/z-a-patch-dl
2 ms - zinit-zsh/z-a-bin-gem-node
12 ms - romkatv/powerlevel10k
5 ms - zdharma/history-search-multi-word
5 ms - zsh-users/zsh-autosuggestions
33 ms - zdharma/fast-syntax-highlighting
12 ms - MichaelAquilina/zsh-you-should-use
5 ms - ael-code/zsh-colored-man-pages
4 ms - zsh-users/zsh-completions
9 ms - marzocchi/zsh-notify
19 ms - wfxr/forgit
Total: 0.109 sec
```
```bash
zinit status
Found existing alias for "zinit". You should use: "zini"
Assuming --all is passed
Updating Zinit…
Note: status done also for unloaded plugins
Status for plugin MichaelAquilina/zsh-you-should-use
Sur la branche master
Votre branche est à jour avec 'origin/master'.
```
```bash
zinit ls
Found existing alias for "zinit". You should use: "zini"
No `tree' program, it is required by the subcommand `ls'
Download from: http://mama.indstate.edu/users/ice/tree/
It is also available probably in all distributions and Homebrew, as package `tree'
.
├── OMZ::plugins
└── plugins -> OMZ::plugins
2 directories, 0 files, located at ZINIT[SNIPPETS_DIR], i.e. /Users/bruno/.zinit/snippets
```
```bash
zinit delete chipsenkbeil/zsh-notes
Found existing alias for "zinit". You should use: "zini"
Delete /Users/bruno/.zinit/plugins/chipsenkbeil---zsh-notes? (it holds: zsh-notes.plugin.zsh, .gitignore, LICENSE, README.md, more…)
[yY/n…]
y
Done (action executed, exit code: 0)
```
#### Les plugins sont installés ici:
```bash
/Users/bruno/.zinit/plugins/
```

View File

@@ -98,6 +98,27 @@ $ ls archive.tar
Compresser avec zip: Compresser avec zip:
```
zip <archive.zip> <file1> <file2>
zip <archive.zip> <file*>
```
```bash
$ zip p10k.zip p1Ok.zsh
adding: p1Ok.zsh (deflated 63%)
```
Options:
- -q : pas des sortie écran
- -Z bzip2 : méthode de compression bzip2 (deflate par défaut)
- -9 ... -0 : niveau de compression (maxi -> mini)
- -e : avec mot-de-passe
Compresser un dossier avec zip:
```bash ```bash
$ zip -r scripts.zip scripts/ $ zip -r scripts.zip scripts/
adding: scripts/ (stored 0%) adding: scripts/ (stored 0%)

View File

@@ -119,7 +119,7 @@ $ usermod -G "" <username>
### Code de sortie: ### Code de sortie (code de retour):
Chaque commande renvoie un *code de sortie* (quelque fois nommé *état de retour* ). Chaque commande renvoie un *code de sortie* (quelque fois nommé *état de retour* ).
@@ -136,6 +136,7 @@ $ hostname
silverbook.home silverbook.home
$ echo $? $ echo $?
0 0
$ hostnam $ hostnam
-bash: hostnam: command not found -bash: hostnam: command not found
$ echo $? $ echo $?
@@ -149,3 +150,18 @@ bruno@SilverBook:~/.kymsu/plugins.d$ if [ $? -eq 0 ]; then echo "ok"; else echo
ok ok
``` ```
```bash
$ pip3 install -U "pip"
ret=$?
# pas d'update: ret=0
[ $ret -eq 0 ] && echo -e "No update available !"
if [ $ret -eq 0 ]; then
echo -e "No update available !"
fi
```

View File

@@ -100,6 +100,16 @@ if [ -d directory ]; then
if [ -d ~/.kde ]; then if [ -d ~/.kde ]; then
``` ```
Si le répertoire *<u>directory</u>* existe ET n'est <u>pas vide</u>
```bash
local_path=$HOME/Sites/
if find "$local_path/node_modules" -mindepth 1 -maxdepth 1 | read; then echo "dir not empty"; else echo "dir empty"; fi
if [ -d "$local_path/node_modules" ] && [ -n "$(ls -A "$local_path/node_modules")" ]; then echo "dir not empty"; else echo "dir empty"; fi
```
Si le fichier *<u>regularfile</u> (ni un blockspecialfile, ni un characterspecialfile, ni un directory)* existe Si le fichier *<u>regularfile</u> (ni un blockspecialfile, ni un characterspecialfile, ni un directory)* existe
```bash ```bash

17
docs/Linux/exa.md Normal file
View File

@@ -0,0 +1,17 @@
**exa -lbhHigUmuSa@ --time-style=long-iso --git --color-scale**
```bash
exa -lbhHigUmuSa@ --time-style=long-iso --git --color-scale
inode Permissions Links Size Blocks User Group Date Modified Date Created Date Accessed Git Name
3426575 drwxr-xr-x 12 - - bruno staff 2021-08-05 17:33 2021-08-05 09:35 2021-08-05 17:33 -- .git
3426645 drwxr-xr-x 3 - - bruno staff 2021-08-05 09:35 2021-08-05 09:35 2021-08-05 17:32 -- img
3426641 .rw-r--r-- 1 1,1Ki 8 bruno staff 2021-08-05 09:35 2021-08-05 09:35 2021-08-05 09:35 -- LICENSE
3426642 .rw-r--r-- 1 1,4Ki 8 bruno staff 2021-08-05 09:35 2021-08-05 09:35 2021-08-05 09:35 -- Pure Dark.alfredappearance
3426643 .rw-r--r--@ 1 1,4Ki 8 bruno staff 2021-08-05 09:35 2021-08-05 09:35 2021-08-05 09:36 -- Pure Light.alfredappearance
└── com.apple.lastuseddate#PS (len 16)
3426644 .rw-r--r-- 1 316 8 bruno staff 2021-08-05 09:35 2021-08-05 09:35 2021-08-05 09:36 -- README.md
```

View File

@@ -1,4 +1,4 @@
# nvm # nvm

View File

@@ -113,10 +113,10 @@ lrwxr-xr-x 1 bruno staff 6 15 mar 07:29 python3 -> python
Mettre-à-jour `pip` et `setuptools`: Mettre-à-jour `pip`, `setuptools` et installer `wheel`:
```bash ```bash
(tuto-virtuel-env) bruno@SilverBook:~/venv/tuto-virtuel-env/bin$ pip3 install -U pip setuptools (tuto-virtuel-env) bruno@SilverBook:~/venv/tuto-virtuel-env/bin$ pip3 install -U pip setuptools wheel
``` ```
@@ -150,6 +150,27 @@ Le module installé dans l'environnement virtuel est disponible UNIQUEMENT dans
#### Virtual environnment courant:
```python
python
Python 3.9.6 (default, Jun 28 2021, 19:24:41)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.prefix)
/Users/bruno/Documents/venv/soco-cli
>>> print(sys.executable)
/Users/bruno/Documents/venv/soco-cli/bin/python
>>>
```
```bash
which -a python
/Users/bruno/Documents/venv/soco-cli/bin/python
/usr/bin/python
```
### pyvenv ### pyvenv

View File

@@ -0,0 +1,691 @@
# Apache
### Installer Apache (homebrew)
#### Désactiver le serveur Apache d'origine:
```bash
$ sudo apachectl stop
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
```
#### Installation:
```bash
$ brew install httpd
$ sudo brew services start httpd
```
Voir si Apache tourne:
```bash
$ ps -aef | grep httpd
501 28356 1 0 10:56 ?? 0:00.29 /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND
501 12984 781 0 9:09 ttys001 0:00.01 tail -f /opt/homebrew/var/log/httpd/error_log
501 29101 786 0 1:19 ttys002 0:00.00 grep httpd
```
Faire les m-à-j directement depuis Homebrew.
### Arrêter / redémarrer Apache
Apache est controllé par les *services brew*:
```bash
$ brew services stop httpd
$ brew services start httpd
$ brew services restart httpd
```
ou par *apachectl*:
```bash
$ sudo apachectl start
$ sudo apachectl stop
$ sudo apachectl -k restart
$ sudo apachectl -k restart -e Debug -E /dev/stdout
```
### Log:
```bash
# Mac intel
$ tail -f /usr/local/var/log/httpd/error_log
$ tail -f /usr/local/var/log/httpd/access_log
# Mac M1
$ tail -f /opt/homebrew/var/log/httpd/error_log
$ tail -f /opt/homebrew/var/log/httpd/access_log
```
```bash
$ multitail -s 2 /usr/local/var/log/httpd/error_log /usr/local/var/log/httpd/access_log
```
```bash
$ tail -f /opt/homebrew/var/log/httpd/error_log -f /opt/homebrew/var/log/httpd/access_log
==> /opt/homebrew/var/log/httpd/error_log <==
[Fri Jul 30 06:58:08.250315 2021] [mpm_prefork:notice] [pid 59484] AH00169: caught SIGTERM, shutting down
PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so' (tried: /opt/homebrew/lib/php/pecl/20200930/mcrypt.so (dlopen(/opt/homebrew/lib/php/pecl/20200930/mcrypt.so, 9): image not found), /opt/homebrew/lib/php/pecl/20200930/mcrypt.so.so (dlopen(/opt/homebrew/lib/php/pecl/20200930/mcrypt.so.so, 9): image not found)) in Unknown on line 0
==> /opt/homebrew/var/log/httpd/access_log <==
::1 - - [29/Jul/2021:17:39:55 +0200] "GET /info.php HTTP/1.1" 200 120227
::1 - - [29/Jul/2021:18:04:09 +0200] "GET /info.php HTTP/1.1" 200 120660
```
### Version:
```bash
$ httpd -v
Server version: Apache/2.4.48 (Unix)
Server built: Jul 6 2021 20:11:03
```
### Modules activés:
```bash
$ httpd -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_prefork_module (shared)
authn_file_module (shared)
$ apachectl -M
```
### Configuration:
Ouvrir le fichier *httpd.conf*:
```bash
# Mac intel
$ nano /usr/local/etc/httpd/httpd.conf
# Mac M1
$ nano /opt/homebrew/etc/httpd/httpd.conf
```
Remplacer les lignes et blocs:
| Original | Modifié |
| ----------------------------------------------- | ------------------------------------------------------------ |
| `Listen 8080` | `Listen 80` |
| `DocumentRoot "/usr/local/var/www"` | `DocumentRoot "/Users/bruno/Sites"` |
| `<Directory "/usr/local/var/www">` | `<Directory "/Users/bruno/Sites">`<br /><br />*Dans le même bloc Directory:*<br/>`AllowOverride All` |
| #User & Group:<br/>`User http`<br/>`Group http` | #User & Group:<br/>`User bruno`<br/>`Group staff` |
| `#ServerName www.example.com:8080`<br/> | `ServerName airbook.local`<br />#ServerName localhost |
Activer certains modules:
```http
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
```
Créer une page d'accueil:
```bash
echo "<h1>My User Web Root</h1>" > ~/Sites/index.html
```
#### Tester la configuration:
```bash
$ httpd -t
Syntax OK
$ apachectl configtest
```
#### Redémarrer Apache:
```bash
$ brew services restart httpd
```
Créer un alias dans .zshrc
```bash
alias bra='brew services restart httpd'
```
### [=> Installer PHP](php_M1.md)
### Virtual Hosts:
Les activer dans *httpd.conf* (décocher les lignes):
```http
LoadModule vhost_alias_module lib/httpd/modules/mod_vhost_alias.so
```
Mac M1
```http
# Virtual hosts
Include /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf
```
Mac intel
```http
# Virtual hosts
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
```
#### Redirection:
Editer le fichier *hosts*:
```bash
$ sudo nano /etc/hosts
127.0.0.1 airbook.local
127.0.0.1 wordpress.airbook.local
127.0.0.1 dev.airbook.local
127.0.0.1 zenphoto.airbook.local
127.0.0.1 phpmyadmin.airbook.local
```
Editer le fichier *httpd-vhosts.conf*:
```bash
# Mac intel
$ nano /usr/local/etc/httpd/extra/httpd-vhosts.conf
# Mac M1
$ nano /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf
```
```http
<VirtualHost *:80>
DocumentRoot /Users/bruno/Sites/wordpress
ServerName wordpress.air.local
CustomLog /usr/local/var/log/httpd/wordpress-access.log combined
ErrorLog /usr/local/var/log/httpd/wordpress-error.log
</VirtualHost>
```
#### Redirection de port:
wiki.js tourne sur localhost:3000
Pour le rendre disponible sur wiki.silverbook.local:
Editer le fichier *httpd.conf* et activer les modules `mod_proxy` et `mod_proxy_http`:
```http
LoadModule proxy_module lib/httpd/modules/mod_proxy.so
LoadModule proxy_http_module lib/httpd/modules/mod_proxy_http.so
```
Editer le fichier *hosts*:
```bash
$ sudo nano /etc/hosts
127.0.0.1 airbook.local
127.0.0.1 wiki.airbook.local
```
Editer le fichier *httpd-vhosts.conf*:
```http
<VirtualHost *:80>
ServerName wiki.airbook.local
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
ProxyPreserveHost On
</VirtualHost>
```
### SSL:
Activer SSL dans *httpd.conf* (décocher les lignes):
```http
LoadModule socache_shmcb_module lib/httpd/modules/mod_socache_shmcb.so
...
LoadModule ssl_module lib/httpd/modules/mod_ssl.so
```
Mac M1
```http
# Secure (SSL/TLS) connections
Include /opt/homebrew/etc/httpd/extra/httpd-ssl.conf
```
Mac intel
```http
# Secure (SSL/TLS) connections
Include /usr/local/etc/httpd/extra/httpd-ssl.conf
```
Ouvrir le fichier *httpd-ssl.conf*:
```bash
# Mac intel
$ nano /usr/local/etc/httpd/extra/httpd-ssl.conf
# Mac M1
$ nano /opt/homebrew/etc/httpd/extra/httpd-ssl.conf
```
Remplacer les lignes:
| Original | Modifié |
| -------------------------------------- | ----------------------------------- |
| `Listen 8443` | `Listen 443` |
et le bloc:
```http
<VirtualHost _default_:8443>
# General setup for the virtual host
DocumentRoot "/opt/homebrew/var/www"
ServerName www.example.com:8443
ServerAdmin you@example.com
ErrorLog "/opt/homebrew/var/log/httpd/error_log"
TransferLog "/opt/homebrew/var/log/httpd/access_log"
```
par
```http
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "/Users/bruno/Sites"
ServerName airbook.local:443
ServerAdmin bruno@clicclac.info
ErrorLog "/opt/homebrew/var/log/httpd/error_log"
TransferLog "/opt/homebrew/var/log/httpd/access_log"
```
Ouvrir le fichier *httpd-vhosts.conf*:
Rajouter ce bloc pour chaque Virtual Host.
```http
<VirtualHost *:443>
DocumentRoot "/Users/bruno/Sites"
ServerName airbook.local
SSLEngine on
SSLCertificateFile "/usr/local/etc/httpd/server.crt"
SSLCertificateKeyFile "/usr/local/etc/httpd/server.key"
</VirtualHost>
```
### Générer un certificat auto-signé:
#### Méthode 1:
Générer la <u>clé</u> et le <u>certificat</u> (*Common Name* doit correspondre à *ServerName* du *https-vhosts.conf*)
```bash
$ cd /usr/local/etc/httpd
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
```
Vérifier la configuration Apache et relancer le serveur:
```bash
$ sudo apachectl configtest
$ sudo apachectl -k restart
```
#### Méthode 2:
Installer 2 programmes:
- mkcert: Simple tool to make locally trusted development certificates
- nss: Libraries for security-enabled client and server applications (for Firefox)
```bash
$ brew install mkcert nss
```
Installer le serveur de certificat:
```bash
$ mkcert -install
Created a new local CA 💥
Sudo password:
The local CA is now installed in the system trust store! ⚡️
The local CA is now installed in the Firefox trust store (requires browser restart)! 🦊
```
Créer les dossiers pour les certificats:
```bash
$ cd /opt/homebrew/etc/httpd
$ mkdir certs && cd certs
```
Générer les certificats:
```bash
$ mkcert airbook.local
Created a new certificate valid for the following names 📜
- "airbook.local"
The certificate is at "./airbook.local.pem" and the key at "./airbook.local-key.pem"
It will expire on 29 October 2023 🗓
```
Un certificat et une clé sont créer pour chaque domaine:
```http
/opt/homebrew/etc/httpd/certs/airbook.local.pem
/opt/homebrew/etc/httpd/certs/airbook.local-key.pem
```
Editer le fichier *httpd-ssl.conf* et remplacer les 2 lignes:
```http
SSLCertificateFile "/opt/homebrew/etc/httpd/certs/airbook.local.pem"
SSLCertificateKeyFile "/opt/homebrew/etc/httpd/certs/airbook.local-key.pem"
```
Tester la configuration:
```bash
$ httpd -t
Syntax OK
$ apachectl configtest
```
Redémarrer Apache:
```bash
$ brew services restart httpd
```
#### SSL dans Virtual Host
Editer le fichier *httpd-vhosts.conf*:
Rajouter le bloc suivant
```http
<VirtualHost *:443>
DocumentRoot "/Users/bruno/Sites"
ServerName airbook.local
SSLEngine on
SSLCertificateFile "/opt/homebrew/etc/httpd/certs/airbook.local.pem"
SSLCertificateKeyFile "/opt/homebrew/etc/httpd/certs/airbook.local-key.pem"
</VirtualHost>
```
après le bloc
```http
<VirtualHost *:80>
ServerAdmin bruno@clicclac.info
DocumentRoot "/Users/bruno/Sites"
ServerName airbook.local
#ServerAlias www.dummy-host.example.com
#ErrorLog "/opt/homebrew/var/log/httpd/dummy-host.example.com-error_log"
#CustomLog "/opt/homebrew/var/log/httpd/dummy-host.example.com-access_log" common
</VirtualHost>
```
### Warning: getimagesize(): SSL operation failed with code 1.
Erreur dans Worpdress:
```
Warning: getimagesize(): SSL operation failed with code 1.
OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in
/Users/bruno/Sites/wordpress/wp-content/themes/CreatorThemeRes-child/functions.php on line 1611
```
Il faut rajouter les lignes suivantes au PHP.ini
```ini
[openssl]
openssl.cafile="/usr/local/etc/httpd/server.crt"
# D'après SSLCertificateFile "/usr/local/etc/httpd/server.crt" du httpd-ssl.conf
```
https://stackoverflow.com/questions/51532963/tcpdf-getimagesize-ssl-operation-failed-with-code-1-error1416f086ssl-routi
Mais ça donne une erreur pour les MàJ PECL: `Connection to ssl://pecl.php.net:443' failed: `
### Messages d'erreur personnalisés:
Dans un fichier .htaccess, ajouter:
```html
ErrorDocument 404 /custom_404.html
ErrorDocument 500 /custom_50x.html
```
### Messages d'erreur personnalisés multilingues:
Ouvrir le fichier *httpd-ssl.conf* et dé-commenter les lignes suivantes:
```http
LoadModule include_module lib/httpd/modules/mod_include.so
LoadModule negotiation_module lib/httpd/modules/mod_negotiation.so
Include /usr/local/etc/httpd/extra/httpd-multilang-errordoc.conf
```
### Installer phpmyadmin (Homebrew):
```bash
$ brew install homebrew/php/phpmyadmin
```
Le fichier de configuration se trouve là:`/usr/local/etc/phpmyadmin.config.inc.php`
Ajouter le bloc qui suit dans le **httpd.conf**
```http
Alias /phpmyadmin /usr/local/share/phpmyadmin
<Directory /usr/local/share/phpmyadmin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
```
### Message derreur personnalisé:
[:fa-link: https://httpd.apache.org/docs/2.4/fr/custom-error.html](https://httpd.apache.org/docs/2.4/fr/custom-error.html)
### Différence installation macOS - homebrew:
***MacOS:***
```bash
/usr/sbin/httpd-wrapper
/System/Library/LaunchDaemons/org.apache.httpd.plist
/Library/WebServer/Documents/index.html
/private/etc/apache2/httpd.conf
/private/etc/apache2/extra/httpd-vhosts.conf
```
***Homebrew:***
Mac intel:
```bash
/usr/local/opt/httpd/bin/httpd
/Users/bruno/Library/LaunchAgents/homebrew.mxcl.httpd.plist
/Users/bruno/Library/LaunchAgents/homebrew.mxcl.php.plist
/Users/bruno/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
/usr/local/var/www/index.html -> /Users/bruno/Sites
/usr/local/etc/httpd/httpd.conf
/usr/local/etc/httpd/extra/httpd-vhosts.conf
```
Mac M1:
```bash
/opt/homebrew/opt/httpd/bin/httpd
/Users/bruno/Library/LaunchAgents/homebrew.mxcl.httpd.plist
/Users/bruno/Library/LaunchAgents/homebrew.mxcl.php.plist
/Users/bruno/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
/opt/homebrew/var/www/index.html -> /Users/bruno/Sites
/opt/homebrew/etc/httpd/httpd.conf
/opt/homebrew/etc/httpd/extra/httpd-vhosts.conf
```
### Arrêt brutal de macOS:
Il se peut qu'au redémarrage, Apache ne fonctionne plus.
Regarder *error_log*:
<!--Tue Jan 30 13:24:14.790214 2018] [core:warn][pid 2103] AH00098: pid file /usr/lo 218-->
<!--cal/var/run/httpd/httpd.pid overwritten -- Unclean shutdown of previous Apache run 127.0.0.1 - - [30/Jan/2018:09:57:30 +0100] "GET /favicon.ico HTTP/1.1" 404 209-->
<!--?-->
Puis arrêter et redémarrer Apache:
```bash
$ sudo apachectl stop
$ sudo apachectl start
```
### Nouvelle version de Python:
<u>Apache ne fonctionne plus</u>. Regarder *error_log*:
```http
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
```
Dans *httpd.conf* commencer par vérifier la version de Python dans la ligne suivante. Si elle est correcte, commenter la ligne:
`WSGIPythonHome "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6"`
Arrêter et redémarrer Apache.
Si cela refonctionne, désinstaller et réinstaller <u>mod_wsgi</u> avec <u>pip</u>.
```bash
$ pip3 list --format=columns
Package Version
------
...
mod-wsgi 4.6.4
...
$ pip uninstall mod-wsgi
Uninstalling mod-wsgi-4.6.4:
Would remove:
/usr/local/bin/mod_wsgi-express
/usr/local/lib/python3.6/site-packages/mod_wsgi-4.6.4.dist-info/*
/usr/local/lib/python3.6/site-packages/mod_wsgi/*
Proceed (y/n)? y
Successfully uninstalled mod-wsgi-4.6.4
$ pip install mod-wsgi
Collecting mod-wsgi
Downloading https://files.pythonhosted.org/packages/9e/37/dd336068ece37c43957aa337f25c59a9a6afa98086e5507908a2d21ab807/mod_wsgi-4.6.4.tar.gz (2.6MB)
100% |████████████████████████████████| 2.6MB 1.6MB/s
Building wheels for collected packages: mod-wsgi
Running setup.py bdist_wheel for mod-wsgi ... done
Stored in directory: /Users/bruno/Library/Caches/pip/wheels/2d/73/68/9dcbbd0147b3fde4686263a31324ea2372e42f7cefa2f7d181
Successfully built mod-wsgi
Installing collected packages: mod-wsgi
Successfully installed mod-wsgi-4.6.4
$ sudo apachectl stop
$ sudo apachectl start
```
Pour connaître la configuration dans *httpd.conf*, lancez `mod_wsgi-express module-config`
```bash
$ mod_wsgi-express module-config
LoadModule wsgi_module "/usr/local/lib/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-darwin.so"
WSGIPythonHome "/usr/local/Cellar/python@3.8/3.8.3_2/Frameworks/Python.framework/Versions/3.8"
```
### Liens:
[:fa-link: https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions](https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions)
[:fa-link: https://lukearmstrong.github.io/2016/12/setup-apache-mysql-php-homebrew-macos-sierra/](https://lukearmstrong.github.io/2016/12/setup-apache-mysql-php-homebrew-macos-sierra/)

View File

@@ -1,93 +1,513 @@
# ls -Installer PHP (homebrew) # Installer PHP (homebrew)
### Installation: ### Installation:
Ajouter le tap:
```bash ```bash
$ brew tap homebrew/php $ brew tap shivammathur/php
$ brew update $ brew update
$ brew install php71 --with-httpd ```
Installer différentes versions de PHP:
```bash
$ brew install shivammathur/php/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
``` ```
### Configurer PHP: ### Configurer PHP:
Mac intel:
```bash ```bash
$ bbedit /usr/local/etc/php/7.1/php.ini $ 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: ### Modifier le httpd.conf:
```http Mac intel:
httpd.conf:
#LoadModule php7_module /usr/local/Cellar/php71/7.1.11_22/libexec/apache2/libphp7.so
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
```
### Version de PHP:
```bash ```bash
$ php -v $ 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:
- pour Apache (httpd): `brew services restart httpd`
- pour Nginx: `brew services restart nginx`
Valider PHP:
```bash
echo "<?php phpinfo();" > ~/Sites/info.php
```
et aller sur http://localhost/info.php
Si PHP n'est pas interprété, redémarrer le mac.
### Changer de version: ### Changer de version:
#### Méthode 1:
```bash ```bash
$ brew unlink php54 && brew link php53 $ brew unlink php && brew link --overwrite --force php@7.4
``` ```
Erreur: Failed loading /usr/local/opt/php71-opcache/opcache.so: dlopen(/usr/local/opt/php71-opcache/opcache.so, 9): Symbol not found: *compiler*globals ⇒ #### Méthode 2:
*PHP switcher script*
Installation Mac intel:
```bash ```bash
$ brew reinstall php71-opcache --build-from-source $ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/0c36a5067fbd63e6a36700a6aaa119df0836bdfc/sphp.sh > /usr/local/bin/sphp
$ brew reinstall php71-apcu --build-from-source $ chmod +x /usr/local/bin/sphp
$ brew reinstall php71-xdebug --build-from-source ```
$ brew reinstall php71-yaml --build-from-source
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
``` ```
## Extensions: #### Version de PHP:
### Liste des extensions (Homebrew):
```bash ```bash
$ brew search php71 $ php -v
PHP 7.4.22 (cli) (built: Jul 27 2021 15:38:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.22, Copyright (c), by Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
```
#### PHP Info:
```bash
$ php -i
``` ```
### Installer l'extension Tideways: #### Logs:
[:fa-link: https://tideways.io/profiler/docs/setup/installation#macos-homebrew](https://tideways.io/profiler/docs/setup/installation#macos-homebrew)
```bash ```bash
$ brew tap tideways/homebrew-profiler /opt/homebrew/var/log/php-fpm.log
$ brew install tideways-daemon-tideways
``` ```
Puis ajouter dans le php.ini ### Extensions:
`extension=/usr/local/opt/php71/lib/php/extensions/no-debug-non-zts-20160303/tideways.so` #### Installer une extension (depuis Homebrew):
Idem pour mongodb Ajouter le tap:
`extension=/usr/local/opt/php71/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so` ```bash
$ brew tap shivammathur/php
$ brew update
```
Installer les [différentes extensions](https://github.com/shivammathur/homebrew-extensions):
```bash
$ brew install xdebug@8.0
# Fichier config
/opt/homebrew/etc/php/8.0/conf.d/xdebug.ini # M1
/usr/local/etc/php/8.0/conf.d/xdebug.ini # intel
```
```bash
$ nano /opt/homebrew/etc/php/8.0/conf.d/xdebug.ini
```
```php
[xdebug]
zend_extension="/opt/homebrew/opt/xdebug@8.0/xdebug.so"
xdebug.mode=debug
```
### Liens: ```bash
$ brew install apcu@8.0
[:fa-link: PHP (osx)](https://php-osx.liip.ch/) (package PHP) # Fichier config
/opt/homebrew/etc/php/8.0/conf.d/apcu.ini
```
[Installer Xhprof pour PHP7](Xhprof.md) ```bash
$ nano /opt/homebrew/etc/php/8.0/conf.d/apcu.ini
```
```php
[apcu]
extension="/opt/homebrew/opt/apcu@8.0/apcu.so"
apc.enabled=1
apc.shm_size=64M
apc.ttl=7200
apc.enable_cli=1
```
```bash
$ brew install imagick@8.0
# Fichier config
/opt/homebrew/etc/php/8.0/conf.d/imagick.ini
```
```bash
$ nano /opt/homebrew/etc/php/8.0/conf.d/imagick.ini
```
```php
[imagick]
extension="/opt/homebrew/opt/imagick@8.0/imagick.so"
```
```bash
$ brew install memcached@8.0
# Fichier config
/opt/homebrew/etc/php/7.4/conf.d/memcached.ini
```
```bash
$ nano /opt/homebrew/etc/php/7.4/conf.d/memcached.ini
```
```php
[memcached]
extension="/opt/homebrew/opt/memcached@7.4/memcached.so"
```
#### Installer une extension (PECL)
On peut également installer des extensions avec [PECL](https://pecl.php.net):
```bash
$ pecl channel-update pecl.php.net
```
<u>mcrypt:</u>
```bash
$ brew install mcrypt
$ pecl install mcrypt
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
```
```bash
$ pecl install mcrypt
libmcrypt prefix? [autodetect] : /opt/homebrew
Build process completed successfully
Installing '/opt/homebrew/Cellar/php/8.0.8_2/pecl/20200930/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.4
Extension mcrypt enabled in php.ini
```
<u>Yaml:</u>
```bash
$ brew install libyaml
$ pecl install yaml
configure: error: Please install libyaml
```
```bash
$ pecl install yaml
Please provide the prefix of libyaml installation [autodetect] : /opt/homebrew
Build process completed successfully
Installing '/opt/homebrew/Cellar/php/8.0.8_2/pecl/20200930/yaml.so'
install ok: channel://pecl.php.net/yaml-2.2.1
Extension yaml enabled in php.ini
```
PECL a un souci avec l'installation homebrew des macs M1:
https://stackoverflow.com/a/68138560/12431632
Chaque version de PHP a son propre répertoire d'extensions:
Mac intel:
```bash
/usr/local/lib/php/pecl/20160303 ← 7.1
/usr/local/lib/php/pecl/20170718 ← 7.2
/usr/local/lib/php/pecl/20180731 ← 7.3
/usr/local/lib/php/pecl/20190902 ← 7.4
/usr/local/lib/php/pecl/20200930 ← 8.0
```
Mac M1:
```bash
/opt/homebrew/lib/php/pecl/20160303 ← 7.1
/opt/homebrew/lib/php/pecl/20170718 ← 7.2
/opt/homebrew/lib/php/pecl/20180731 ← 7.3
/opt/homebrew/lib/php/pecl/20190902 ← 7.4
/opt/homebrew/lib/php/pecl/20200930 ← 8.0
```
Désinstaller une extension:
```bash
$ pecl uninstall mcrypt
Extension mcrypt disabled in php.ini
uninstall ok: channel://pecl.php.net/mcrypt-1.0.4
```
#### Installer une extension (depuis les sources):
<u>ssh2:</u>
```bash
# Installation de ssh2:
# https://pecl.php.net/package/ssh2
$ brew install libssh2
$ cd ~/Downloads
$ wget https://pecl.php.net/get/ssh2-1.3.1.tgz
$ tar zxvf ssh2-1.3.1.tgz
$ cd ssh2-1.3.1
$ phpize
$ ./configure
checking for ssh2 files in default path... not found
configure: error: The required libssh2 library was not found. You can obtain that package from http://sourceforge.net/projects/libssh2/
# libssh2 est dans /opt/homebrew mais attendue dans /usr/local
$ ./configure --with-ssh2=$(brew --prefix libssh2)
$ make
...
Libraries have been installed in:
/Users/bruno/Downloads/ssh2-1.3.1/modules
$ make install
Installing shared extensions: /opt/homebrew/Cellar/php@7.4/7.4.22/pecl/20190902/
```
```bash
$ nano /opt/homebrew/etc/php/7.4/conf.d/ssh2.ini
```
```php
[ssh2]
extension="/opt/homebrew/Cellar/php@7.4/7.4.22/pecl/20190902/ssh2.so"
```
<u>Yaml:</u>
```bash
# Installation de yaml:
# https://pecl.php.net/package/yaml
$ brew install libyaml
$ cd ~/Downloads
$ wget https://pecl.php.net/get/yaml-2.2.1.tgz
$ tar zxvf yaml-2.2.1.tgz
$ cd yaml-2.2.1/
$ phpize
$ ./configure
checking for yaml headers... not found
configure: error: Please install libyaml
# libyaml est dans /opt/homebrew mais attendue dans /usr/local
$ ./configure --with-yaml=$(brew --prefix libyaml)
$ make
...
Libraries have been installed in:
/Users/bruno/Downloads/yaml-2.2.1/modules
$ make install
Installing shared extensions: /opt/homebrew/Cellar/php@7.4/7.4.22/pecl/20190902/
```
```bash
$ nano /opt/homebrew/etc/php/7.4/conf.d/yaml.ini
```
```php
[yaml]
extension="/opt/homebrew/Cellar/php@7.4/7.4.22/pecl/20190902/yaml.so"
```
<u>mcrypt</u>:
```bash
# Installation de mcrypt:
# https://pecl.php.net/package/mcrypt
$ brew install libmcrypt
$ cd ~/Downloads
$ wget https://pecl.php.net/get/mcrypt-1.0.4.tgz
$ tar zxvf mcrypt-1.0.4.tgz
$ cd mcrypt-1.0.4/
$ phpize
$ ./configure
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
# libmcrypt est dans /opt/homebrew mais attendue dans /usr/local
./configure --with-mcrypt=$(brew --prefix libmcrypt)
$ make
...
Libraries have been installed in:
/Users/bruno/Downloads/mcrypt-1.0.4/modules
$ make install
Installing shared extensions: /opt/homebrew/Cellar/php@7.4/7.4.22/pecl/20190902/
```
```bash
$ nano /opt/homebrew/etc/php/7.4/conf.d/mcrypt.ini
```
```php
[mcrypt]
extension="/opt/homebrew/Cellar/php@7.4/7.4.22/pecl/20190902/mcrypt.so"
```
Chaque version de PHP a son propre répertoire d'extensions:
Mac intel:
```bash
/usr/local/Cellar/php@7.4/7.4.22/pecl/20190902/
```
Mac M1:
```bash
/opt/homebrew/Cellar/php@7.4/7.4.22/pecl/20190902/
```
[Installer mongodb](mongodb.md)

View File

@@ -0,0 +1,93 @@
# Installer PHP (homebrew)
### Installation:
```bash
$ brew tap homebrew/php
$ brew update
$ brew install php71 --with-httpd
```
### Configurer PHP:
```bash
$ bbedit /usr/local/etc/php/7.1/php.ini
```
### Modifier le httpd.conf:
```http
httpd.conf:
#LoadModule php7_module /usr/local/Cellar/php71/7.1.11_22/libexec/apache2/libphp7.so
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
```
### Version de PHP:
```bash
$ php -v
```
### Changer de version:
```bash
$ brew unlink php54 && brew link php53
```
Erreur: Failed loading /usr/local/opt/php71-opcache/opcache.so: dlopen(/usr/local/opt/php71-opcache/opcache.so, 9): Symbol not found: *compiler*globals ⇒
```bash
$ brew reinstall php71-opcache --build-from-source
$ brew reinstall php71-apcu --build-from-source
$ brew reinstall php71-xdebug --build-from-source
$ brew reinstall php71-yaml --build-from-source
```
## Extensions:
### Liste des extensions (Homebrew):
```bash
$ brew search php71
```
### Installer l'extension Tideways:
[:fa-link: https://tideways.io/profiler/docs/setup/installation#macos-homebrew](https://tideways.io/profiler/docs/setup/installation#macos-homebrew)
```bash
$ brew tap tideways/homebrew-profiler
$ brew install tideways-daemon-tideways
```
Puis ajouter dans le php.ini
`extension=/usr/local/opt/php71/lib/php/extensions/no-debug-non-zts-20160303/tideways.so`
Idem pour mongodb
`extension=/usr/local/opt/php71/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so`
### Liens:
[:fa-link: PHP (osx)](https://php-osx.liip.ch/) (package PHP)
[Installer Xhprof pour PHP7](Xhprof.md)
[Installer mongodb](mongodb.md)

View File

@@ -352,11 +352,15 @@ https://github.com/otsuarez/mkdocs_auth
/Users/bruno/Documents/venv/mkdocs/bin/pip3 install ## Plugins:
- mkdocs-material-extensions
- mkdocs-git-revision-date-localized-plugin
- mkdocs-minify-plugin
- fontawesome_markdown
- mkdocs-pdf-export-plugin
```bash
$ pip install --upgrade mkdocs-material-extensions mkdocs-git-revision-date-localized-plugin mkdocs-minify-plugin fontawesome_markdown mkdocs-pdf-export-plugin
```
### Some heading