1er commit

De la docs au format Mkdocs
This commit is contained in:
2018-09-16 14:48:15 +02:00
commit e82296ba06
140 changed files with 17082 additions and 0 deletions

BIN
docs/macos/.DS_Store vendored Normal file

Binary file not shown.

72
docs/macos/Divers.md Normal file
View File

@@ -0,0 +1,72 @@
# Divers
#### Convertir une page man en fichier txt:
```bash
bruno@SilverBook:~$ man tmutil | col -b > tmutil.txt
```
( -bx)
#### Convertir une page man en fichier pdf:
(installer Ghostscript pour avoir ps2pdf)
```bash
bruno@SilverBook:~$ man -t tmutil | ps2pdf - tmutil.pdf
```
#### Installer LaTeX:
```bash
$ brew cask install basictex
```
ou
```bash
$ brew cask install mactex
```
#### rsync
`—delete` (efface de la destination ce qui nest plus dans la source)
#### Créer une image disque:
```bash
bruno@SilverBook:~$ hdiutil create -srcfolder /Users/bruno/Downloads/PC archive.dmg
.......................................................................................................................................................................................
created: /Users/bruno/archive.dmg
```
#### Rapport système:
```bash
bruno@SilverBook:~$ system_profiler -detailLevel basic > report.txt
```
#### Comparer fichiers et répertoires:
```bash
$ opendiff Contract1.rtf Contract2.rtf
```
#### Chercher les m-à-j sur l'App Store:
```bash
$ softwareupdate -l
Software Update Tool
Finding available software
No new software available.
```
#### Installer les m-à-j:
```bash
$ sudo softwareupdate -i -a
```

32
docs/macos/TouchID.md Normal file
View File

@@ -0,0 +1,32 @@
# Comment utiliser Touch ID dans le Terminal (commande sudo):
```bash
$ sudo cp /etc/pam.d/sudo /etc/pam.d/sudo.bak
$ sudo nano /etc/pam.d/sudo
```
Ajoutez la ligne suivante au début du fichier, et enregistrez :
`auth sufficient pam_tid.so`
```bash
# sudo: auth account password session
auth sufficient pam_tid.so
auth sufficient pam_smartcard.so
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
```
!!! attention
Les connections ssh sans mot-de-passe ne fonctionnent plus.

View File

@@ -0,0 +1,77 @@
# Bash (exemples)
Ajouter un préfixe à la ligne d'un fichier texte:
```bash
brew list | sed -e 's/^/brew install /' > brew-list.txt
```
Pour un suffixe:
```bash
sed -e 's/$/suffix/'
```
Cherche tous les .jpg d'un répertoire et les effacer:
```bash
find . -name '*jpg' -exec rm {} +
```
Concaténer tous les .csv:
```bash
find . -type f -iname "*.csv" -exec cat {} \; > toutes.txt
```
Couleurs dans le terminal:
```bash
export UNDERLINE=$(tput sgr 0 1)
export BOLD=$(tput bold)
export BLACK=$(tput setaf 0)
export RED=$(tput setaf 1)
export GREEN=$(tput setaf 2)
export YELLOW=$(tput setaf 3)
export BLUE=$(tput setaf 4)
export PURPLE=$(tput setaf 5)
export CYAN=$(tput setaf 6)
export WHITE=$(tput setaf 7)
export GRAY=$(tput setaf 8)
export LIGHTRED=$(tput setaf 9)
export LIGHTGREEN=$(tput setaf 10)
export LIGHTYELLOW=$(tput setaf 11)
export LIGHTBLUE=$(tput setaf 12)
export LIGHTPURPLE=$(tput setaf 11)
export LIGHTCYAN=$(tput setaf 11)
export RESET=$(tput sgr0)
```
```bash
echo "${BLUE}blue${RESET} ${RED}red${RESET}"
blue red
for i in {0..255}; do echo "$(tput setaf $i)test"; done
```
Supprimer récursivement tous les fichiers .DS_ST0RE:
```bash
sudo find / -name ".DS_Store" -depth -exec rm {} \;
```
```bash
find . -name '*.DS_Store' -type f -delete
```
```bash
find . -name '.DS_Store' -type f -print -exec rm -f {} +
```

View File

@@ -0,0 +1,30 @@
# Exécuter un shell script depuis le Finder
- Renommer le script avec l'extension .command:
```bash
$ cp mkdocs.sh mkdocs.command
```
- Le rendre exécutable
```bash
$ chmod +x mkdocs.command
```
- Le script doit commencer par `!/bin/bash`
Pour le lancer depuis LaunchBar: Info Fichier -> Ouvrir avec -> iTem
Connaître le répertoire courant:
```bash
DIRNAME=`dirname "$0"`
```

View File

@@ -0,0 +1,191 @@
# Homebrew-Cask
**[:fa-link: Homebrew-Cask](https://github.com/caskroom/homebrew-cask)**
**[:fa-link: https://caskroom.github.io](https://caskroom.github.io)**
### Installer un plug-in QuickLook ([:fa-link: QLVideo](https://github.com/Marginal/QLVideo)):
```bash
$ brew cask install qlvideo
# --force réinstalle le Cask (si déjà présent)
```
### Desinstaller:
```bash
$ brew cask uninstall qlvideo
```
### Liste de tous les Casks disponibles:
```bash
$ brew cask search
```
### Liste de tous les Casks disponibles à propos de Chrome:
```bash
$ brew cask search chrome
==> Partial Matches
chrome-devtools dmm-player-for-chrome google-chrome
chrome-remote-desktop-host epichrome mkchromecast
==> Remote Matches
caskroom/versions/google-chrome-canary caskroom/versions/google-chrome-dev
caskroom/versions/google-chrome-beta
```
### Information au sujet d'un Cask:
```bash
$ brew cask info google-chrome
google-chrome: 63.0.3239.132
https://www.google.com/chrome/
Not installed
From: https://github.com/caskroom/homebrew-cask/blob/master/Casks/google-chrome.rb
==> Name
Google Chrome
==> Artifacts
Google Chrome.app (App)
```
### Liste des Casks installés:
```bash
$ brew cask list
basictex qlcolorcode suspicious-package
betterzipql qlstephen
# -1 sortie sur une seule colonne
# --versions montre toutes les versions installés
```
### Aller à la page du project Homebrew-Cask:
```bash
$ brew cask home
```
### Aller à la page du Cask:
```bash
$ brew cask home qlstephen
```
### Liste des Casks mis-à-jour disponibles:
```bash
$ brew cask outdated
# --greedy inclus les Casks avec auto_updates true et version :latest
# --verbose
```
### Installer les mises-à-jour:
```bash
$ brew cask reinstall `brew cask outdated`
```
```bash
$ brew cask outdated --greedy --verbose | grep -v '(latest)' | awk '{print $1}' | xargs brew cask reinstall
# mets à jour les auto_updates true mais pas les version :latest
```
### Mettre à jour tous les Casks:
```bash
$ brew cask upgrade
# --greedy met à jour les Casks avec auto_updates true et version :latest
```
### Script d'installation:
```bash
# !/bin/sh
# Brew packages that I use alot.
brew install wget
brew install ffmpeg
brew install node
brew install imagemagick
# Some cask packages that I like.
brew cask install google-chrome
brew cask install xquartz
brew cask install virtualbox
```
Sauver le script sous le fichier **installConfig.sh** et le rendre exécutable:
```bash
$ chmod +x installConfig.sh
```
### Cache:
```bash
$ cd ~/Library/Caches/Homebrew/Cask
total 480296
drwxr-xr-x 11 bruno staff 352 18 jan 18:54 .
drwxr-xr-x 92 bruno staff 2944 17 jan 17:19 ..
-rw-r--r--@ 1 bruno staff 19529710 14 déc 12:30 airy--3.3.179.dmg
-rw-r--r-- 1 bruno staff 135495923 10 jan 01:59 atom--1.23.3.zip
-rw-r--r-- 1 bruno staff 74574230 7 jui 2017 basictex--2017.0607.pkg
-rw-r--r--@ 1 bruno staff 2158705 22 oct 05:23 cakebrew--1.2.5.dmg
-rw-r--r-- 1 bruno staff 28404 26 oct 14:01 qlcolorcode--2.0.9.zip
-rw-r--r-- 1 bruno staff 55479 21 mai 2017 qlmarkdown--1.3.5.zip
-rw-r--r-- 1 bruno staff 30945 24 mai 2017 qlstephen--1.4.4.zip
-rw-r--r--@ 1 bruno staff 5078603 22 mai 2017 transmission--2.92.dmg
-rw-r--r--@ 1 bruno staff 2825054 13 nov 11:03 vnc-viewer--6.17.1113.dmg
```
### Vider le cache:
```bash
# Supprimer tous les téléchargements
$ brew cask cleanup
# Supprimer les téléchargements vieux de + de 10 jours.
$ brew cask cleanup --outdated
```
https://github.com/Homebrew/homebrew-cask/blob/master/doc/development/adding_a_cask.md

457
docs/macos/homebrew/brew.md Normal file
View File

@@ -0,0 +1,457 @@
# Homebrew
**[:fa-link: https://docs.brew.sh](https://docs.brew.sh)**
[:fa-link: formulae.brew.sh](http://braumeister.org)
### Update Homebrew et les formules:
```bash
$ brew update
```
### Chercher les M-à-J:
```bash
$ brew outdated
# --verbose
```
### Mettre tout à jour:
```bash
$ brew upgrade
# --cleanup Met à jour et supprime les anciennes versions installées.
```
### Formules:
#### Mettre à jour une formule:
```bash
$ brew upgrade <formula>
# --cleanup Met à jour et supprime les anciennes versions installées.
```
#### Installer une formule:
```bash
$ brew install <formula>
$ brew install --verbose --debug <formula>
# --build-from-source Compile la formule depuis la source même si une bottle est disponible. Les dépendances sont installées depuis les bottles.
```
#### Installer une formule dailleurs la branche:
```bash
$ brew install https://raw.github.com/user/repo/branch/formula.rb
```
#### Reinstaller une formule depuis les sources:
```bash
$ brew reinstall -s <formula>
```
#### Desinstaller une formule:
```bash
$ brew uninstall <formula>
# --force toutes les versions de la formule seront effacées
# --ignore-dependencies desinstallera même si des dépendances restent installées
```
#### Desinstaller les anciennes versions dune formule:
```bash
$ brew cleanup <formula>
# Supprime toutes les anciennes dans la Cellar et dans le Cache.
# --dry-run (ou -n) montre ce qui va être supprimer mais n'enlève rien.
# --prune=days supprime les fichiers du Cache plus vieux que <days> jours.
```
#### Desinstaller toutes les anciennes versions:
```bash
$ brew cleanup
# (-n ou --dry-run) voir tout ce qui sera désinstaller
```
#### Empecher la m-à-j dun package:
```bash
$ brew pin <formula>
```
```bash
bruno@SilverBook:/usr/local/Cellar/terminal-notifier/1.8.0$ brew pin terminal-notifier
```
#### Re-permettre la m-à-j:
```bash
$ brew unpin <formula>
```
#### Liste des formules installées:
```bash
$ brew list
# --versions affiche la verion en plus.
# --pinned affiche les formules pinned
```
#### Afficher des infos sur une formule installée:
```bash
$ brew info <formula>
```
```bash
$ brew info terminal-notifier
terminal-notifier: stable 1.8.0 (bottled), HEAD
Send macOS User Notifications from the command-line
https://github.com/julienXX/terminal-notifier
/usr/local/Cellar/terminal-notifier/1.7.1 (14 files, 2MB)
Poured from bottle on 2016-10-19 at 07:24:46
/usr/local/Cellar/terminal-notifier/1.8.0 (5 files, 99.8KB) *
Poured from bottle on 2017-08-12 at 20:20:48
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/terminal-notifier.rb
==> Requirements
Build: xcode ✔
Required: macOS >= 10.8 ✔
```
#### Description d'une formule:
```bash
$ brew desc <formula>
```
```bash
$ brew desc httpd
httpd: Apache HTTP server
```
#### Afficher les options d'une formule:
```bash
$ brew options <formula>
```
```bash
$ brew options php72
--with-argon2
Include libargon2 password hashing support
--with-cgi
Enable building of the CGI executable (implies --without-fpm)
--with-debug
Compile with debugging symbols
# --compact sur une seule ligne
```
#### Chercher une formule (avec description):
```bash
$ brew search --desc <formula>
```
```bash
$ brew search --desc pdf
briss: Crop PDF files
diff-pdf: Visually compare two PDF files
```
#### Activer une autre version:
```bash
$ brew switch <formula>
```
```bash
bruno@SilverBook:/usr/local/Cellar/terminal-notifier/1.8.0$ brew switch terminal-notifier 1.7.1
Cleaning /usr/local/Cellar/terminal-notifier/1.7.1
Cleaning /usr/local/Cellar/terminal-notifier/1.8.0
1 links created for /usr/local/Cellar/terminal-notifier/1.7.1
```
#### Configurer (arguments) une formule:
```bash
$ brew edit <formula>
```
#### Afficher la homepage de Homebrew:
```bash
$ brew home
```
#### Afficher la homepage de la formule:
```bash
$ brew home <formula>
```
#### Log:
```bash
$ brew log <formula>
```
#### « keg-only »
La formule est installée dans Cellar. Elle nest pas linkée dans /usr/local
<u>Pour la linker:</u>
```bash
$ brew link
```
#### Changer de version de PHP:
```bash
$ brew unlink php54 && brew link php53
```
####
### Dépendances:
#### Voir les dépendances:
```bash
$ brew deps <formula>
```
```bash
$ brew deps httpd
apr
apr-util
boost
c-ares
jansson
jemalloc
libev
libevent
nghttp2
openssl
pcre
# --tree Présentation comme arbre
```
#### Montrer les formules installées qui ne sont pas des dépendances d'autres formules installées:
```bash
$ brew leaves
```
#### Montrer les dépendances manquantes:
```bash
$ brew missing
$ brew missing <formula>
```
#### Dépendances inverses:
```bash
$ brew uses x264 --installed
ffmpeg
```
### Outils:
#### Vérifier le système:
```bash
$ brew doctor
```
#### Prune (supprimer les liens symboliques morts):
```bash
$ brew prune
# --dry-run
```
#### Où va tout ce que télécharge Homebrew (cache):
```bash
$ brew --cache
/Users/bruno/Library/Caches/Homebrew
```
```bash
$ cd /Users/bruno/Library/Caches/Homebrew
total 2616544
drwxr-xr-x 92 bruno staff 2944 17 jan 17:19 .
drwx------+ 194 bruno staff 6208 18 jan 18:57 ..
drwxr-xr-x 11 bruno staff 352 18 jan 18:54 Cask
-rw-r--r-- 1 bruno staff 400053 28 oct 08:20 apr-1.6.3.high_sierra.bottle.tar.gz
-rw-r--r-- 1 bruno staff 242481 3 nov 02:01 apr-util-1.6.1_1.high_sierra.bottle.tar.gz
-rw-r--r-- 1 bruno staff 88679443 19 déc 10:23 boost-1.66.0.high_sierra.bottle.tar.gz
-rw-r--r-- 1 bruno staff 3434 16 déc 20:15 brew-pip-0.4.1.tar.gz
-rw-r--r-- 1 bruno staff 12310915 21 nov 13:01 cmake-3.10.0.high_sierra.bottle.tar.gz
```
#### Affiche le chemin de Cellar:
```bash
$ brew --Cellar
/usr/local/Cellar
$ brew --Cellar httpd
/usr/local/Cellar/httpd
```
#### Sauvegarder sa configuration Homebrew:
Liste des packages, taps et casks installés:
```bash
$ brew tap Homebrew/bundle
$ brew bundle dump
```
Ceci crée un fichier <u>Brewfile</u> que l'on peut éditer.
```bash
tap 'homebrew/php'
brew 'homebrew/php/php71', args: ['with-imap']
brew 'shpotify'
cask 'spotify'
```
#### Restaurer sa configuration:
```bash
# Se positionner dans le répertoire contenant le fichier Brewfile
$ brew bundle
```
### Services:
#### Liste des services gérés par brew services:
```bash
bruno@SilverBook:~$ brew services list
Name Status User Plist
mariadb started bruno /Users/bruno/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
php71 started bruno /Users/bruno/Library/LaunchAgents/homebrew.mxcl.php71.plist
httpd started root /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
```
#### Lancer au démarrage:
```bash
$ brew services start mysql
```
#### Démarrer (pas au boot):
```bash
$ brew services run mysql
```
#### Arrêter le service:
```bash
$ brew services stop mysql
```
#### Redémarrer le service:
```bash
$ brew services restart mysql
```
### Taps (third-party repositories):
[:fa-link: brew tap](https://docs.brew.sh/Taps.html) rajoute des repositories à **brew**
#### Liste les repos tapped:
```bash
$ brew tap
caskroom/cask
homebrew/apache
homebrew/core
homebrew/dupes
homebrew/php
homebrew/services
homebrew/versions
tideways/profiler
vapor/tap
```
<u>Les tap sont situés là:</u>
```bash
bruno@silverbook:/usr/local/Homebrew/Library/Taps$ ls
caskroom homebrew tideways vapor
```
#### Ajouter un repo:
```bash
$ brew tap <tapname>
```
#### Supprimer un repo:
```bash
$ brew untap <tapname>
```
### Cask:
### [:fa-link: Homebrew-Cask](brew-cask.md)

36
docs/macos/index.md Normal file
View File

@@ -0,0 +1,36 @@
# macos
### Apache / PHP / MySQL
[Installer **Apache** (homebrew)](webserver/apache.md)
[Installer **PHP** (homebrew)](webserver/php.md)
[Installer **MySQL** (homebrew)](webserver/mysql.md)
[:fa-link: **PHP info** (Macbook)](http://silverbook.local/info.php)
### Gestionnaire de paquets
[**MacPorts**](https://clicclac.synology.me/dokuwiki/doku.php?id=osx:macports) est un système pour installer, compiler et gérer des programmes open-source.
[**homebrew**](homebrew/brew.md) est un système pour installer, compiler et gérer des programmes open-source.
[**pip**](python/pip.md) (Python install packages)
[node](node/node-js.md)
### Divers
[Se connecter au NAS en ssh et sans mot de passe](ssh/ssh-passwordless.md)
[Sécurité (Gatekeeper...)](securite.md)
[Calcul d'un checksum, md5, sha256…](md5.md)
[Touch ID](TouchID.md)

9
docs/macos/liens.md Normal file
View File

@@ -0,0 +1,9 @@
# Liens
[Launchd](http://www.launchd.info)
[How to Use launchd to Run Scripts on Schedule in macOS](https://www.maketecheasier.com/use-launchd-run-scripts-on-schedule-macos/)
[Schedule jobs with crontab on Mac OS X](https://ole.michelsen.dk/blog/schedule-jobs-with-crontab-on-mac-osx.html)

28
docs/macos/md5.md Normal file
View File

@@ -0,0 +1,28 @@
# Calculer le checksum d'un fichier ou d'un dossier
Il faut installer **md5deep** (Recursively compute digests on files/directories) avec [homebrew](homebrew/brew.md).
Le paquet contient hash deep, md5deep, sha1deep, sha256deep, tigerdeep, whirlpooldeep.
### Calcul du sha256 dun fichier
```bash
HackiMac:~ bruno$ sha256deep /Users/bruno/Library/ssdtPRGen/ACPI/APIC.aml
64e0949f7af61f2c23e74ecd6c9f59d25f4b9b904befd9252159f671f0ea2581 /Users/bruno/Library/ssdtPRGen/ACPI/APIC.aml
```
### Calcul du sha256 dun dossier
```bash
HackiMac:~ bruno$ sha256deep -r /Volumes/EFI/EFI/CLOVER/kexts/Other/realtekALC.kext
57b4630bf6365fd46d76e5d845b97cc8d1042e5fa48621086c3edcefb4d20517 /Volumes/EFI/EFI/CLOVER/kexts/Other/realtek
```

67
docs/macos/node/ghost.md Normal file
View File

@@ -0,0 +1,67 @@
# ghost
[Installer nvm](nvm.md).
Version LTS de Node:
```bash
$ nvm install --lts
$ nvm use --lts
```
Installer ghost-cli:
```bash
$ npm install -g ghost-cli
```
Créer un répertoire où installer Ghost:
```bash
$ mkdir myblog
$ cd myblog
$ ghost install local
```
Quand l'installation est terminée, on accède à Ghost à l'adresse http://localhost:2368/ et http://localhost:2368/ghost/ pour la page administration.
Paramétrage de Ghost (après l'installation)
```bash
$ ghost setup
? Enter your blog URL: http://localhost:2368
? Enter your MySQL hostname: localhost
? Enter your MySQL username: root
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost_prod
✔ Configuring Ghost
✔ Setting up instance
? Do you wish to set up "ghost" mysql user? Yes
✔ Setting up "ghost" mysql user
? Do you wish to set up Nginx? No
Setting up Nginx [skipped]
Task ssl depends on the 'nginx' stage, which was skipped.
Setting up SSL [skipped]
? Do you wish to set up Systemd? No
Setting up Systemd [skipped]
? Do you want to start Ghost? Yes
Ghost is already running! Run `ghost ls` for more information
```
View running ghost processes:
```bash
$ ghost ls
┌─────────────┬───────────────┬─────────┬───────────────────────┬────────────────────────┬──────┬─────────────────┐
│ Name │ Location │ Version │ Status │ URL │ Port │ Process Manager │
├─────────────┼───────────────┼─────────┼───────────────────────┼────────────────────────┼──────┼─────────────────┤
│ ghost-local │ ~/Sites/ghost │ 2.0.3 │ running (development) │ http://localhost:2368/ │ 2368local
└─────────────┴───────────────┴─────────┴───────────────────────┴────────────────────────┴──────┴─────────────────┘
```

10
docs/macos/node/index.md Normal file
View File

@@ -0,0 +1,10 @@
# WebServer
[Ghost](ghost.md)
[node-js](node-js.md)
[nvm](nvm.md)

163
docs/macos/node/node-js.md Normal file
View File

@@ -0,0 +1,163 @@
# node.js
[Node.js](https://nodejs.org/fr/)® est un environnement dexécution JavaScript construit sur le [moteur JavaScript V8 de Chrome](https://developers.google.com/v8/).
[npm](https://www.npmjs.com) est un gestionnaire de paquets pour JavaScript automatiquement installé avec Node.
[nvm](https://github.com/creationix/nvm) (Node Version Manager) est un gestionnaire de version de Node.
### Installation (Homebrew):
```bash
# installer node et npm
$ brew install node
```
### Installation (directe):
Installer [Node.js](https://nodejs.org/en/download/) (version LTS)
### Installation ([nvm](nvm.md)):
```bash
$ brew install nvm
# installer Node 8
$ nvm install 8
# installer Node 10
$ nvm install 10
```
### Version de npm:
```bash
# version:
$ node -v
v9.5.0
$ npm -v
5.6.0
```
### Update:
```bash
npm install npm@latest -g
$ brew install node
$ npm install npm --global
```
https://docs.npmjs.com/getting-started/fixing-npm-permissions#option-2-change-npms-default-directory-to-another-directory
### Local:
Installer npm packages localement => `/Users/bruno/Sites/node_modules`
- Installer: `npm install <package_name>`
- Mise-à-jour: `npm update` (depuis le répertoire du module)
- Desinstaller: `npm uninstall <package_name>`
<u>Mises à jour disponibles:</u>
```bash
bruno@silverbook:~/Sites/node_modules$ npm outdated
Package Current Wanted Latest Location
jquery MISSING 3.2.1 3.2.1
livephotoskit 1.4.11 1.5.2 1.5.2
```
<u>Mettre-à-jour:</u>
```bash
$ npm outdated | awk '{print $1}' | xargs npm update
```
### Global:
Installer npm packages globalement => `/usr/local/lib/node_modules/`
- Installer: `npm install -g <package_name>`
- Mise-à-jour: `npm update -g <package_name>`
- Désinstaller: `npm uninstall -g <package_name>`
### Aller dans node_modules:
```bash
bruno@SilverBook:~$ cd Sites/node_modules/
```
puis
- Liste package installé: `nom ls`
- Mises à jour disponibles: `nom outdated`
- Installer une m-à-j: `nom update`
- Installer un package: `nom install package`
- Désinstaller un package: `nom uninstall package`
### Supprimer tous les modules:
```bash
$ for package in `ls node_modules`; do npm uninstall $package; done;
```
### Maintenance:
```bash
$ npm doctor
npm WARN verifyCachedFiles Content garbage-collected: 46 (4358853 bytes)
npm WARN verifyCachedFiles Cache issues have been fixed
Check Value Recommendation
npm ping OK
npm -v v5.10.0 Use npm v6.4.1
node -v v8.11.4
npm config get registry https://registry.npmjs.org/
which git /usr/bin/git
Perms check on cached files ok
Perms check on global node_modules ok
Perms check on local node_modules ok
Verify cache contents verified 2159 tarballs
```
### Packages:
[Rechercher un package](https://npms.io)
##### uninstall-all-modules
Desinstaller tous les modules=
```bash
$ npm uninstall
```
##### livephotoskit, jquery, picturefill

109
docs/macos/node/nvm.md Normal file
View File

@@ -0,0 +1,109 @@
# nvm
Installer nvm:
```bash
$ brew install nvm
```
Créer un répertoire où sera installé les différentes versions de Node.
```bash
$ mkdir ~/.nvm
```
Editer .bash_profile pour régler le répertoire NVM_DIR
```bash
$ nano ~/.bash_profile
```
et ajouter les lignes suivantes.
```bash
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
```
Recharger le shell pour activer nvm.
```bash
$ source ~/.bash_profile
$ echo $NVM_DIR
$ nvm --version
```
Installer NodeJS.
```bash
# la dernière version 8
$ nvm install 8
# la version 8.9.4
$ nvm install 8.9.4
# la dernière version 6
$ nvm install 6
```
Liste des versions de Node installées:
```bash
$ nvm ls
# ou
$nvm list
-> v8.11.4
v10.9.0
default -> 8 (-> v8.11.4)
node -> stable (-> v10.9.0) (default)
stable -> 10.9 (-> v10.9.0) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.11.4)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.4 (-> N/A)
lts/carbon -> v8.11.4
```
Versions téléchargées:
```bash
$ cd $NVM_DIR
- OR -
$ cd ~/.nvm
$ ls versions/node
v10.9.0 v8.11.4
```
Version en usage:
```bash
$ node -v
v8.11.4
```
Changer de version:
```bash
$ nvm use 10.9.0
Now using node v10.9.0 (npm v6.2.0)
$ nvm use 10
Now using node v10.9.0 (npm v6.2.0)
$ node -v
v10.9.0
```
```bash
$ nvm use 8.11.4
Now using node v8.11.4 (npm v5.6.0)
$ node -v
v8.11.4
```
```bash
$ nvm use --lts
Now using node v8.11.4 (npm v5.6.0)
```

View File

@@ -0,0 +1,99 @@
# Installer Django
[Django](https://docs.djangoproject.com/en/2.0/topics/install/#installing-distribution-package) est un framework Web Python.
#### Installer [mysqlclient](https://pypi.python.org/pypi/mysqlclient)
```bash
$ pip3 install mysqlclient
```
#### Installer Django
```bash
$ pip3 install Django
$ python3 -m django --version
2.0.2
```
[Django avec Apache et mod_wsgi](https://docs.djangoproject.com/fr/2.0/howto/deployment/wsgi/modwsgi/)
Se positionner en dehors de <u>Document root</u> (/Users/bruno) pour <u>démarrer un projet Django</u>:
```bash
~$ django-admin startproject mydjango
```
Installer [mod_wsgi](https://pypi.python.org/pypi/mod_wsgi) depuis <u>pip</u>:
```bash
$ APXS=/usr/local/bin/apxs pip3 install mod_wsgi
```
ou depuis Homebrew:
```bash
$ brew uninstall -vd mod_wsgi
$ brew install -vd mod_wsgi --with-homebrew-python
```
Lancer la commande `mod_wsgi-express module-config` pour connaitre les directives à ajouter à la configuration d'Apache (httpd.conf):
```bash
$ mod_wsgi-express module-config
LoadModule wsgi_module "/usr/local/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-darwin.so"
WSGIPythonHome "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6"
```
Une fois <u>https.conf</u> modifié, relancer Apache:
```bash
$ sudo apachectl -k restart -e Debug -E /dev/stdout
```
Une autre option est de copier le module <u>mod_wsgi</u> dans l'installation d'Apache avec la commande `mod_wsgi-expressinstall-module`
Se positionner dans le dossier <u>mydjango</u> pour démarrer le serveur:
```bash
$ python3 manage.py runserver
```
Pour changer le port (8000 par défaut)
```bash
$ python3 manage.py runserver 8001
```
Créer les tables dans la BDD.
```bash
$ python3 manage.py migrate
```
Création d'un utilisateur administrateur.
```bash
$ python manage.py createsuperuser
```
https://docs.djangoproject.com/fr/2.0/intro/tutorial03/#write-views-that-actually-do-something

View File

@@ -0,0 +1,10 @@
# WebServer
[Django](Django.md)
[pip](pip.md)
[python3](python3.md)

301
docs/macos/python/pip.md Normal file
View File

@@ -0,0 +1,301 @@
# Installer pip (python 2):
[:fa-link: https://apple.stackexchange.com/questions/209572/how-to-use-pip-after-the-os-x-el-capitan-upgrade](https://apple.stackexchange.com/questions/209572/how-to-use-pip-after-the-os-x-el-capitan-upgrade)
### Documentation pip:
[:fa-link: https://pip.pypa.io/en/stable/](https://pip.pypa.io/en/stable/)
### Installer pip:
```bash
$ sudo easy_install pip
```
Pour [Python 3](python3.md), **pip** est installé d'origine.
### Version courrante de pip:
```bash
$ pip --version
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
```
### Mettre à jour pip:
```bash
$ sudo pip install --upgrade pip
```
```bash
$ pip install --user --upgrade pip
```
!!! attention
Sur macOS, à cause de SIP (System Integrity Protection), l'installation se fait avec le mot-clé —user
### Cache:
Linux and Unix
```bash
~/.cache/pip # and it respects the XDG_CACHE_HOME directory.
```
OS X
```bash
~/Library/Caches/pip
```
Windows
```bash
%LocalAppData%\pip\Cache
```
pip peut installer en ignorant le cache:
```bash
pip --no-cache-dir install mkdocs
```
### Installer un module (mkdocs):
```bash
$ pip install --user mkdocs
```
Les modules sont ici:
`/Users/bruno/Library/Python/2.7/bin`
### Désinstaller un module:
```bash
$ pip uninstall <module>
```
### Installer une ancienne version d'un module:
```bash
$ pip3 show tornado
Name: tornado
Version: 5.0
.../...
$ pip3 install tornado==4.5.3
Collecting tornado==4.5.3
Installing collected packages: tornado
Found existing installation: tornado 5.0
Uninstalling tornado-5.0:
Successfully uninstalled tornado-5.0
Successfully installed tornado-4.5.3
$ pip3 install 'tornado>=4.1.0,<4.5.3'
```
### Informations sur un module:
```bash
$ pip show <module>
$ pip show mkdocs
Name: mkdocs
Version: 0.17.2
Summary: Project documentation with Markdown.
Home-page: http://www.mkdocs.org
Author: Tom Christie
Author-email: tom@tomchristie.com
License: BSD
Location: /Users/bruno/Library/Python/2.7/lib/python/site-packages
Requires: tornado, PyYAML, click, Markdown, Jinja2, livereload
```
### Liste des modules installés:
```bash
$ pip list --format=columns
Package Version
-------------------------------------- ---------
altgraph 0.10.2
backports-abc 0.5
bdist-mpkg 0.5.0
```
### Liste des modules mis-à-jour:
```bash
$ pip list --outdated --format=columns
Package Version Latest Type
-------------------------------------- -------- ------ -----
altgraph 0.10.2 0.15 wheel
macholib 1.5.1 1.9 wheel
matplotlib 1.3.1 2.1.1 wheel
```
```bash
$ pip3 list --outdated --format=freeze
packaging==16.8
Sphinx==1.7.0
```
```bash
$ pip3 list --outdated --format=columns
Package Version Latest Type
------
packaging 16.8 17.1 wheel
Sphinx 1.7.0 1.7.1 wheel
```
```bash
$ pip3 list --outdated --format=legacy
packaging (16.8) - Latest: 17.1 [wheel]
Sphinx (1.7.0) - Latest: 1.7.1 [wheel]
```
```bash
$ pip3 list --outdated --format=json
[{"name": "packaging", "version": "16.8", "latest_version": "17.1", "latest_filetype": "wheel"}, {"name": "Sphinx", "version": "1.7.0", "latest_version": "1.7.1", "latest_filetype": "wheel"}]
```
### Mettre à jour un module:
```bash
$ pip install --user --upgrade <module>
$ pip install --user --upgrade mkdocs-material
```
### Chercher un module:
```bash
$ pip search <module>
$ pip search markdown
aberdeen (0.4.0) - Conversion from markdown files to database entries to use as the backend of a blog
python-academicmarkdown (0.9.0) - A markdown preparser for academic writing
odoo8-addon-web-widget-text-markdown (8.0.1.0.0.99.dev7) - web_widget_text_markdown
lektor-markdown-admonition (0.1) - Adds basic admonition tag support to Markdown.
```
### Montrer les dépendances d'un module:
```bash
$ pip3 show mkdocs | grep Requires
Requires: tornado, Markdown, click, PyYAML, Jinja2, livereload
```
### Modules:
#### Yolk:
```bash
$ pip3 install yolk3k
```
Montrer les dépendances:
```bash
$ yolk -d mkdocs
mkdocs 0.17.3
PyYAML>=3.10
tornado<5.0,>=4.1
Jinja2>=2.7.1
click>=3.3
Markdown>=2.3.1
livereload>=2.5.1
```
Montrer les M-à-J disponibles:
```bash
$ yolk -U
tornado 4.5.3 (5.0)
```
Listes des modules installés:
```bash
$ yolk -l
Babel - 2.5.3 - active development (/usr/local/lib/python3.6/site packages)
Django - 2.0.3 - active development (/usr/local/lib/python3.6/site-packages)
```
#### pipdeptree:
Savoir quel module requiert tel module:
```bash
$ pipdeptree -r -p mkdocs
mkdocs==0.17.3
- mkdocs-material==2.7.0 [requires: mkdocs>=0.17.1]
```
Montrer les dépendances:
```bash
$ pipdeptree -p mkdocs
mkdocs==0.17.3
- click [required: >=3.3, installed: 6.7]
- Jinja2 [required: >=2.7.1, installed: 2.10]
- MarkupSafe [required: >=0.23, installed: 1.0]
- livereload [required: >=2.5.1, installed: 2.5.1]
- six [required: Any, installed: 1.11.0]
- tornado [required: Any, installed: 4.5.3]
- Markdown [required: >=2.3.1, installed: 2.6.11]
- PyYAML [required: >=3.10, installed: 3.12]
- tornado [required: <5.0,>=4.1, installed: 4.5.3]
```

View File

@@ -0,0 +1,120 @@
# Python 3
Python 3 peut s'installer avec Homebrew:
```bash
$ brew install python3
```
Les extensions Python 3 s'installent dans `/usr/local/lib/python3.6/site-packages/`
Pour lancer un script Python 3:
```bash
$ python3 script.py
```
Pour que python pointe sur Python 3 (homebrew), rajouter ceci à .bash_profile:
```bash
export PATH=/usr/local/opt/python/libexec/bin:$PATH
```
Pip est installé d'origine avec Python 3. On le lance avec la commande **pip3**:
```bash
$ pip3 list --outdated --format=columns
$ pip3 install mkdocs
```
Installation utilisateur:
```bash
$ python3 -m site --user-base
/Users/bruno/Library/Python/3.6
```
[Pipenv](https://docs.pipenv.org)
### Modules:
#### Mkdocs
Mkdocs si'installe dans `/usr/local/bin` :
```bash
bruno@silverbook:/usr/local/bin$ ./mkdocs --version
mkdocs, version 0.17.2
```
Par défaut, c'est **mkdocs** installé avec Python 2 (macOS) qui se lance.
Pour utiliser **mkdocs** installé pour Python 3 (Homebrew):
```bash
bruno@silverbook:~/project$ /usr/local/bin/mkdocs serve
```
Par comparaison, les extensions Python 2 s'installent dans `/Library/Python/2.7/site-packages/`
**Mkdocs** si'installe dans `~/Library/Python/2.7/bin` :
```bash
bruno@silverbook:~/Library/Python/2.7/bin$ ./mkdocs --version
mkdocs, version 0.17.2
```
#### Django
[Installer Django](Django.md)
#### Rechercher un module
[PyPI - the Python Package Index](https://pypi.python.org/pypi)
#### Problème à l'installation
Erreur lors de linstall de python3 avec Homebrew:
```bash
bruno@HackiMac:/usr/local/bin$ brew install python3
==> Downloading https://homebrew.bintray.com/bottles/python-3.7.0.high_sierra.bottle.3.tar.gz
Already downloaded: /Users/bruno/Library/Caches/Homebrew/downloads/d76c2354ae237f190a868bb74f28d606b88cce724222bafa114e91cd8a1462d5--python-3.7.0.high_sierra.bottle.3.tar.gz
==> Pouring python-3.7.0.high_sierra.bottle.3.tar.gz
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
```
Solution:
```bash
sudo mkdir /usr/local/Frameworks
sudo chown $(whoami):admin /usr/local/Frameworks
```

32
docs/macos/securite.md Normal file
View File

@@ -0,0 +1,32 @@
# Sécurité (Gatekeeper...)
#### Pour ajouter une application aux exceptions Gatekeepers et à la liste de lancement des applications approuvées:
```bash
$ spctl --add /Path/To/Application.app
```
#### Suppression d'une demande de la liste d'approbation du Gatekeeper:
```bash
$ spctl --remove /Path/To/Application.app
```
#### Pour désactiver complètement Gatekeeper:
```bash
$ sudo spctl --master-disable
```
#### Pour désactiver Gatekeeper pour certaines applications:
```bash
$ sudo xattr -rd com.apple.quarantine /Applications/LockedApp.app
```

View File

@@ -0,0 +1,280 @@
# Se connecter au NAS en ssh et sans mot de passe
**Pré requis:**
Le serveur doit accepter la connexion par clé: la ligne `PubKeyAuthentication yes` doit être présente dans le fichier de configuration du serveur, généralement /etc/ssh/sshd_config.
Sur Mac, installer ssh-copy-id:
```bash
$ brew install ssh-copy-id
```
### Générer sur la machine locale (Mac)
Le jeu de clé/certficat (la clé est créée dans `~/.ssh/`):
```bash
$ ssh-keygen -t rsa -b 4096 -C "Commentaire: ma clé sur le macbook"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/bruno/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/bruno/.ssh/id_rsa.
Your public key has been saved in /Users/bruno/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:WFJNXaCoraMCYSiP0xqlOvdOsh74W86rC5OgHJppvuw Commentaire: ma clé sur le macbook
The key's randomart image is:
+---[RSA 4096]----+
| .o...o. |
| . .... |
|. . o . |
|+.. * |
|+O o S |
|@=+ . |
|@Bo o o |
|B+oO . . |
|.EOBB. |
+----[SHA256]-----+
```
Plusieurs types de clé possibles (rsa, ecdsa, ed25519):
```bash
$ ssh-keygen -t rsa -b 4096 -C "USEFUL-COMMENT"
$ ssh-keygen -t ecdsa -b 521
$ ssh-keygen -t ed25519
```
Sur ovh.com -> **rsa**
Sur vps 1and1 -> **ed25519**
Les clés DSA sont dépréciées dans OpenSSH 7.0
Autres options:
-o crée un clé privée au nouveau format OpenSSH (au lieu du format PEM plus compatible). Le nouveau format est plus résistant au brut-force mais n'est pas compatible avec OpenSSH pré 6.5. Les clés ed25519 sont toujours au nouveau format.
### Copier la clé publique sur le serveur:
Copiez la clé publique *(id_rsa.pub*) sur le serveur NAS dans le fichier “*authorized_keys*” dans le répertoire `$HOME/.ssh` de l'utilisateur.
```bash
$ cat ~/.ssh/id_rsa.pub | ssh admin@192.168.0.8 'cat>> ~/.ssh/authorized_keys'
# si ssh n'est pas sur le port 22
$ cat ~/.ssh/id_rsa.pub | ssh -p35148 admin@192.168.0.8 'cat>> ~/.ssh/authorized_keys'
```
ou
```bash
$ ssh-copy-id -i ~/.ssh/id_rsa.pub admin@192.168.0.8
# si ssh n'est pas sur le port 22
$ ssh-copy-id -i ~/.ssh/id_rsa.pub admin@192.168.0.8 -p35148
```
Pour les oneliners...
```bash
ssh matthieu@monserveur.local 'mkdir -p ~/.ssh; chmod 0700 ~/.ssh; echo ' $(< ~/.ssh/ma_cle_perso.pub) ' >> ~/.ssh/authorized_keys ; chmod 0600 ~/.ssh/authorized_keys'
```
Sur le serveur, vérifier les autorisations:
```bash
[server]$ chmod 700 ~/.ssh
[server]$ chmod 600 ~/.ssh/*
```
### Ajouter la passphrase à SSH-agent.
Démarrer ssh-agent en arrière-plan:
```bash
$ eval "$(ssh-agent -s)"
Agent pid 2876
```
Ajouter la clé à ssh-agent:
```bash
$ ssh-add -K ~/.ssh/id_rsa
Enter passphrase for /Users/bruno/.ssh/id_rsa:
Identity added: /Users/bruno/.ssh/id_rsa (/Users/bruno/.ssh/id_rsa)
```
Si on utilise une passphrase avec OSX 10.12.2+, il faut ajouter à `~/.ssh/config`
```bash
Host *
# la passphrase de la clé privée est stockée dans la keychain de macOS
AddKeysToAgent yes
# ssh-agent décrypte la clé privée en mémoire
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
```
La passphrase est stockée durablement dans la keychain, on na plus besoin de la rentrer à chaque session.
### SSH Config
Le fichier *config* se trouve dans `~/.ssh/`
Il permet de configurer et de faciliter les connections ssh pour chaque serveur.
```bash
Host *
AddKeysToAgent yes
UseKeychain yes
#SCE_ICON:linux
Host dsm414
User bruno
HostName 192.168.1.8
Port 42666
IdentityFile ~/.ssh/id_ed25519
```
On se connecte directement au serveur avec:
```bash
$ ssh dsm414
```
### Se connecter à la machine distante sans mot-de-passe:
```bash
$ ssh bruno@xxx.synology.me -p12345
bruno@DS916:~ $
```
Finalement, sur le serveur, on peut éditer le fichier `/etc/ssh/sshd_config` pour supprimer l'authentification par mot de passe (`PasswordAuthentication no`). A ne faire que si l'on a un accès physique au serveur.
### Plus:
#### En cas de compromission de la clé privée, que faut-il faire ?
- Regénérer une nouvelle paires de clés ;
- Redéployer la nouvelle clé publique sur tous les serveurs ;
- Révoquer la clé publique sur tous les serveurs où elle est présente, cest-à-dire supprimer la ligne correspondant à votre clé publique dans le fichier ~/.ssh/authorized_keys et en même temps vérifier que dautres clés publiques non légitimes nont pas été ajoutées ;
- Si la clé publique était présente sur un compte root, il va falloir faire un audit complet du serveur car il peut potentiellement avoir été compromis, bonne chance.
#### Info sur une clé:
```bash
$ ssh-keygen -l -f ~/.ssh/id_rsa.pub
2048 SHA256:a++yRIZiaqAx7hJkYdmgYBVeGJtbiFdNrFNrsr0Qi7k bruno@HackiMac.local (RSA)
```
#### Changer la passphrase:
```bash
$ ssh-keygen -f id_rsa -p
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.
```
Cela modifie la clé privée, la clé publique ne change pas.
#### Changer le format de clé:
##### Convertir au nouveau format OpenSSH:
```bash
$ ssh-keygen -f ~/.ssh/id_dsa -o -c -C "dsa@HackiMac.local"
Key now has no comment
The comment in your key file has been changed.
```
- -o: convertit la clé privée de PEM au nouveau format format OpenSSH.
- -c: changer le commentaire dans les clés privée et publique.
- -C: commentaire
##### Convertir une clé publique au format PEM:
```bash
$ ssh-keygen -f server.pub -e -m pem
```
#### Vérifier si ssh-agent est lancé (macOS):
```bash
$ launchctl list | grep ssh-agent
2251 0 com.openssh.ssh-agent
```
#### Pour retrouver la passphrase:
Trousseau daccès -> Présentation -> Afficher les éléments invisibles - > Chercher *id_rsa* ou *ssh*
Clic droit et copier le mot de passe dans le presse-papier (le mot de passe de session est demandé)
#### Supprimer une entrée SSH du fichier known_hosts:
En vous connectant en SSH à une machine que vous venez de réinstaller, vous risquez davoir le message suivant sur le poste client :
```bash
$ ssh-keygen -R NomDuServeur
$ ssh-keygen -f "/home/<USERNAME>/.ssh/known_hosts" -R <NOM_DU_DOMAINE_OU_ADRESSE_MACHINE>
```
#### Regénérer les clés:
Si on veut, pour une raison ou un autre, changer cette pair de clés, il faut :
1. **Côté serveur** : éditer le fichier `/etc/ssh/sshd_config` pour vérifier ou remettre l'authentification par mot de passe est à yes : `PasswordAuthentication yes`
2. recharger ssh : `service ssh start`
3. supprimer le fichier `~/.ssh/authorized_keys`
4. **Côté client** : supprimer les fichier `~/.ssh/id_rsa` et `~/.ssh/id_rsa.pub` puisqu'on va les régénérer en se créant une nouvelle paire de clés.
#### Les clés d'hôtes:
elles sont dans `/etc/sshd/ssh_host*`
#### Copier sa clé publique dans le presse-papier:
- ```bash
- Mac OS: pbcopy < ~/.ssh/id_rsa.pub
- Windows: clip < ~/.ssh/id_rsa.pub
- Linux: xclip -sel clip < ~/.ssh/id_rsa.pub
```
[:fa-link: How to Set Up a Password-less SSH Login](http://osxdaily.com/2012/05/25/how-to-set-up-a-password-less-ssh-login/)
[:fa-link: ssh-copy-id](http://www.qth.fr/tag/ssh-copy-id)
[https://www.ssh.com/ssh/keygen/](https://www.ssh.com/ssh/keygen/)
[https://apple.stackexchange.com/questions/48502/how-can-i-permanently-add-my-ssh-private-key-to-keychain-so-it-is-automatically](https://apple.stackexchange.com/questions/48502/how-can-i-permanently-add-my-ssh-private-key-to-keychain-so-it-is-automatically)
[http://happygitwithr.com/ssh-keys.html](http://happygitwithr.com/ssh-keys.html)
[https://help.github.com/articles/connecting-to-github-with-ssh/](https://help.github.com/articles/connecting-to-github-with-ssh/)

54
docs/macos/ssh/ssh.md Normal file
View File

@@ -0,0 +1,54 @@
# ssh
La configuration SSHD est stockée dans `/private/etc/ssh/sshd_config`
Pour démarrer ou arrêter SSHD:
```bash
sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd
```
[source](https://superuser.com/questions/364304/how-do-i-configure-ssh-on-os-x/364370#364370)
```bash
# On crée un alias bash pour redémarrer sshd:
alias restartsshd='sudo launchctl stop com.openssh.ssh-agent; sudo launchctl start com.openssh.ssh-agent;'
# Liste des services:
launchctl list | grep openssh
```
Changer le port ssh (22 par défaut) sur macOS:
[https://apple.stackexchange.com/questions/335324/cannot-change-ssh-port-on-high-sierra](https://apple.stackexchange.com/questions/335324/cannot-change-ssh-port-on-high-sierra)
**12.6.1 HTTPS vs SSH**
If you think you have SSH set up correctly and yet you are still challenged for credentials, consider this: for the repo in question, have you possibly set up GitHub, probably called origin, as an HTTPS remote, instead of SSH?
How to see the remote URL(s) associated with the current repo in the shell:
git remote -v
An SSH remote will look like this: git@github.com:USERNAME/REPOSITORY.git
whereas an HTTPS remote will look like this: https://github.com/USERNAME/REPOSITORY.git
You can toggle between these with git remote set-url:
- <https://help.github.com/articles/changing-a-remote-s-url/>
<https://apple.stackexchange.com/questions/225231/how-to-use-ssh-keys-and-disable-password-authentication>

BIN
docs/macos/webserver/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,36 @@
# Installer Xhprof pour PHP7
https://github.com/Yaoguais/phpng-xhprof (ne fonctionne pas)
```bash
git clone git@github.com:Yaoguais/phpng-xhprof.git ./xhprof
cd xhprof
/usr/local/opt/php71/bin/phpize
./configure --with-php-config=/usr/local/opt/php71/bin/php-config
make clean && make && make test && sudo make install
```
Installing shared extensions: /usr/local/Cellar/php71/7.1.1_12/lib/php/extensions/no-debug-non-zts-20160303/
http://danieldvork.in/xhprof-vs-xdebug-apache-osx/
https://blog.engineyard.com/2014/profiling-with-xhprof-xhgui-part-1
https://lamosty.com/2015/03/19/profiling-wordpress-with-xhprof-on-mac-os-x-10-10/
### Gui pour Xhpro*
https://github.com/Tuurlijk/xhprof
http://webadvent.org/2010/profiling-with-xhgui-by-paul-reinheimer.html

View File

@@ -0,0 +1,321 @@
# Installer Apache (homebrew)
### Installation:
```bash
$ sudo apachectl stop
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
$ brew install httpd
$ sudo brew services start httpd
```
### Arrêter / redémarrer Apache
```bash
$ sudo apachectl start
$ sudo apachectl stop
$ sudo apachectl -k restart
$ sudo apachectl -k restart -e Debug -E /dev/stdout
```
### Log:
```bash
$ tail -f /usr/local/var/log/httpd/error_log
```
```bash
$ multitail -s 2 /usr/local/var/log/httpd/error_log /usr/local/var/log/httpd/access_log
```
### Version:
```bash
$ httpd -v
```
### Configuration:
Ouvrir le fichier *httpd.conf*:
```bash
$ open -e /usr/local/etc/httpd/httpd.conf
$ bbedit /usr/local/etc/httpd/extra/httpd-vhosts.conf
```
### Virtual Hosts:
Editer le fichier *hosts*:
```bash
$ sudo nano /etc/hosts
127.0.0.1 silverbook.local
127.0.0.1 wordpress.silverbook.local
127.0.0.1 dev.silverbook.local
127.0.0.1 zenphoto.silverbook.local
127.0.0.1 phpmyadmin.silverbook.local
```
Editer le fichier *httpd-vhosts.conf*:
```http
<VirtualHost *:80>
DocumentRoot /Users/bruno/Sites/wordpress
ServerName wordpress.silverbook.local
CustomLog /usr/local/var/log/httpd/wordpress-access.log combined
ErrorLog /usr/local/var/log/httpd/wordpress-error.log
</VirtualHost>
```
### SSL:
<u>Ouvrir le fichier *httpd.conf* et dé-commenter les lignes suivantes:</u>
```http
LoadModule socache_shmcb_module lib/httpd/modules/mod_socache_shmcb.so
...
LoadModule ssl_module lib/httpd/modules/mod_ssl.so
...
Include /usr/local/etc/httpd/extra/httpd-ssl.conf
```
<u>Ouvrir le fichier *httpd-ssl.conf*:</u>
Remplacer le port 8443 par défaut par le port 443 et commenter 2 lignes.
```http
Listen 443
...
<VirtualHost _default_:443>
\# General setup for the virtual host
\# DocumentRoot "/usr/local/var/www"
\# ServerName www.example.com:443
\# ServerAdmin you@example.com
```
<u>Ouvrir le fichier *httpd-vhosts.conf*:</u>
Rajouter ce bloc pour chaque Virtual Host.
```http
<VirtualHost *:443>
DocumentRoot "/Users/bruno/Sites"
ServerName silverbook.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é:
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
```
### 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
```
### Voir si Apache tourne:
```bash
$ ps -aef | grep httpd
0 23417 1 0 2:48PM ?? 0:00.06 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
```
### M-à-J:
directement depuis Homebrew
### 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)
### \# macOS - homebrew:
***MacOS:***
```
/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:***
```
/usr/local/opt/httpd/bin/httpd
/Library/LaunchDaemons/homebrew.mxcl.httpd.plist
/usr/local/var/www/index.html -> /Users/bruno/Sites
/usr/local/etc/httpd/httpd.conf
/usr/local/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:
`Fatal Python error: Py_Initialize: unable to load the file system codec`
`ModuleNotFoundError: No module named 'encodings'`
Dans `https.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
```
### Liens:
[:fa-link: https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions](https://getgrav.org/blog/macos-sierra-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

@@ -0,0 +1,95 @@
# Composer:
### Composer s'installe avec Homebrew :
(nécessite php avec l'extension phar)
```bash
$ brew install composer
$ php composer --version
Composer version 1.6.3 2018-01-31 16:28:17
```
Fichier config:`~/.composer/config.json`
### Pour installer une application:
on se positionne dans son dossier où l'on trouve 2 fichiers:
- composer.json
- composer.lock
```bash
$ composer install
# Sur DSM 6
$ composer.phar install
```
Si erreur, mettre à jour:
```bash
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for friendsofphp/php-cs-fixer v2.2.6 -> satisfiable by friendsofphp/php-cs-fixer[v2.2.6].
- friendsofphp/php-cs-fixer v2.2.6 requires php ^5.3.6 || >=7.0 <7.2 -> your PHP version (7.2.3) does not satisfy that requirement.
```
### Pour mettre à jour:
```bash
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 62 installs, 0 updates, 0 removals
- Installing symfony/process (v4.0.6): Downloading (100%)
- Installing klaussilveira/gitter (0.2.0): Downloading (100%)
###
Writing lock file
Generating autoload files
```
Juste pour tester, aucune modification n'est faite:
```bash
$ composer update --dry-run --profile --verbose
```
### Liste des commandes
```bash
$ composer list
```
### Aide:
```bash
$ composer —help
```
### Affiche ce qui a été installé:
```bash
$ composer show
```
https://coderwall.com/p/ma_cuq/using-composer-to-manage-global-packages
https://akrabat.com/global-installation-of-php-tools-with-composer/

View File

@@ -0,0 +1,18 @@
# Erreurs Apache
```bash
[Thu Apr 26 07:59:22.057052 2018][wsgi:warn] [pid 10412] (2)No such file or directory: mod_wsgi (pid=10412): Unable to stat Python home /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fff98297380 (most recent call first):
[Thu Apr 26 07:59:23.055853 2018][core:notice] [pid 94] AH00052: child pid 10412 exit signal Abort trap (6)
[Thu Apr 26 07:59:23.059385 2018][wsgi:warn] [pid 10415] (2)No such file or directory: mod_wsgi (pid=10415): Unable to stat Python home /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
[Thu Apr 26 07:59:23.059259 2018][wsgi:warn] [pid 10414] (2)No such file or directory: mod_wsgi (pid=10414): Unable to stat Python home /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
Fatal Python error: Py_Initialize: unable to load the file system codec
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: ModuleNotFoundError: No module named 'encodings'No module named 'encodings'
```

View File

@@ -0,0 +1,18 @@
# WebServer
[Apache](apache.md)
[composer](composer.md)
[PHP](php.md)
[PHP 7.2](php72)
[MySQL](mysql)
[mongodb](mongodb)
[Xhprof](Xhprof.md)

View File

@@ -0,0 +1,55 @@
# Installer mongodb
http://pecl.php.net/package/mongodb (v1.2.5 le 04/03/2017)
mongo db nécessite openssl version > 1.0
How to build software outside Homebrew with Homebrew keg-only dependencies
http://docs.brew.sh/How-to-build-software-outside-Homebrew-with-Homebrew-keg-only-dependencies.html
```bash
export PKG_CONFIG_PATH=$(brew --prefix)/opt/openssl/lib/pkgconfig
/usr/local/opt/php71/bin/phpize
./configure --with-php-config=/usr/local/opt/php71/bin/php-config CFLAGS=-I$(brew --prefix)/opt/openssl/include LDFLAGS=-L$(brew --prefix)/opt/openssl/lib
make
sudo make install
```
Sinon avec Homebrew
```bash
$ brew tap homebrew/php
$ brew install phpxx-mongodb
```
Pour démarrer mongodb:
```bash
$ brew services start mongodb
```
Then access the shell by: `mongo`
Stopper la base:
```bash
$ brew services stop mongodb
```
Plus d'options:
```bash
$ brew info mongodb
```

View File

@@ -0,0 +1,79 @@
# Installer mysql
### Installation:
```bash
$ brew update
$ brew install mariadb
$ brew services start mariadb
```
`/usr/local/Cellar/mariadb/10.2.11`
### Arrêter MySQL:
```bash
$ brew services stop mariadb
```
### Démarrer MySQL:
```bash
$ brew services start mariadb
ou
$ mysql.server start
```
### Fix the 2002 MySQL Socket error:
```bash
$ sudo mkdir /var/mysql
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
```
### Version:
```bash
$ mysql -v -u root -p
```
### Après une m-à-j:
arrêter puis démarrer
### Erreurs:
```bash
$ mysql -v -u root -p
mysql: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
Fatal error in defaults handling. Program aborted
```
Le répertoire `/usr/local/etc/my.cnf.d` n'existe plus, il faut le recréer et y créer un fichier:
```bash
$ mkdir /usr/local/etc/my.cnf.d
$ touch wont_prune.txt
```
### Bases:
Les bases sont stockées ici: `/usr/local/var/mysql`
### Liens:
[:fa-link: https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/ ](https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/)
[:fa-link: https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/ ](https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/)
[:fa-link: http://apple.stackexchange.com/questions/255671/error-mysql-server-pid-file-could-not-be-found](http://apple.stackexchange.com/questions/255671/error-mysql-server-pid-file-could-not-be-found)
### Package MySQL
[:fa-link: Télécharger depuis mysql.com](http://dev.mysql.com/downloads/mysql/)
[:fa-link: Installation](https://dev.mysql.com/doc/refman/5.7/en/osx-installation.html)
###

View File

@@ -0,0 +1,93 @@
# ls -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

@@ -0,0 +1,25 @@
Installer PHP 7.2 (Homebrew)
Désintaller PHP
$ brew uninstall --force php72
Installer PHP 7.2
$ brew install php72 --with-httpd --with-webp
Infos sur PHP 7.2
$ brew info php72
homebrew/php/php72: stable 7.2.0 (bottled), HEAD
PHP Version 7.2
$ brew upgrade php72-xdebug

54
docs/macos/youhavemail.md Normal file
View File

@@ -0,0 +1,54 @@
# You have mail.
```
Last login: Thu Oct 26 06:25:34 on ttys000
You have mail.
bruno@SilverBook:~$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/mail/bruno": 1 message 1 new
\>N 1 MAILER-DAEMON@Silver Mon Oct 2 16:43 91/3372 "Undelivered Mail Returned to Sender"
? q
Held 1 message in /var/mail/bruno
You have mail in /var/mail/bruno
```
### Pour effacer les messages:
**Solution 1**
Taper d 1 (delete) pour supprimer le message
**Solution 2**
```bash
bruno@SilverBook:~$ cd /var/mail/
total 8
drwxrwxr-x 3 root mail 102 2 oct 16:43 .
drwxr-xr-x 26 root wheel 884 25 jul 15:54 ..
-rw------- 1 bruno mail 3382 27 oct 07:41 bruno
bruno@SilverBook:/var/mail$ cd bruno
-bash: cd: bruno: Not a directory
total 8
drwxrwxr-x 3 root mail 102 2 oct 16:43 .
drwxr-xr-x 26 root wheel 884 25 jul 15:54 ..
-rw------- 1 bruno mail 3382 27 oct 07:41 bruno
bruno@SilverBook:/var/mail$ > /var/mail/bruno
bruno@SilverBook:/var/mail$
```