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/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