MACOSX

De Marmits Wiki

Pour ZIP

brew install p7zip
7z x file.zip

Envoyer un email par php sous Mac OS X

usage: postfix start (or stop, reload, abort, flush, check, status, set-permissions, upgrade-configuration)
  • postfix
- 1 sudo nano /etc/postfix/main.cf

relayhost=smtp.gmail.com:587
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=noanonymous
smtp_sasl_mechanism_filter=plain
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom

- 2 sudo nano /etc/postfix/sasl_passwd 

smtp.gmail.com:587 user:password

- 3 Générer le fichier .db nécessaire au bon fonctionnement de postfix

postmap /etc/postfix/sasl_passwd

- 4 Autorun postfix on boot and restart postfix

Copy the postfix master plist out of System folder.

sudo cp /System/Library/LaunchDaemons/com.apple.postfix.master.plist /Library/LaunchDaemons/org.postfix.custom.plist
sudo vi /Library/LaunchDaemons/org.postfix.custom.plist

Change the label value from com.apple.postfix.master to org.postfix.custom

Remove these lines to prevent exiting after 60s
  <string>-e</string>
  <string>60</string>

Add these lines before </dict>
  <key>KeepAlive</key>
  <true/>
  <key>RunAtLoad</key>
  <true/>

Relaunch the daemon.
sudo launchctl unload /Library/LaunchDaemons/org.postfix.custom.plist
sudo launchctl load /Library/LaunchDaemons/org.postfix.custom.plist

''security System Integrity Protection (SIP)
démarrer le mac en recovery Pomme-R
Temporarily Turn Off Your Mac’s System Integrity Protection (Recommended For Advanced Users Only!)
Restart in Recovery Mode (press and hold Command + R at startup)
Open the Terminal Utility
Type the command csrutil disable
This gives you full, unrestricted access to your Mac’s entire operating system and every file–so again, advanced users only
For Terminal Users;
Restart your Mac and open Terminal again
Use Terminal with the commands that resulted in operation not permitted errors
When done, follow steps 1-2 and turn SIP back on using the command csrutil enable 
Restart your Mac and SIP should be back in business''


- 4 relancer postfix

sudo postfix stop
sudo postfix load

5 - Test
echo "Test sending email from Postfix" | mail -s "Test Postfix" youremail@domain.com
Change youremail@domain.com with valid email with mailbox access for easy checking.

Check mail queue and possible delivery errors with mailq.

Check mail log with tail -f /var/log/mail.log.

Les attributs étendus

ex:-rw-rwxr–@

  • dans le dossier avec terminal
xattr * (pour lister)
xattr -d -r com.apple.quarantine * (pour effacer)

apache

sudo apachectl restart
sudo apachectl -k restart
tail -f /usr/local/var/log/httpd/error_log

homebrew

 Setting up PHP & MySQL on OS X Yosemite | Rob Allen: http://akrabat.com/php/setting-up-php-mysql-on-os-x-yosemite/
 http://jeffbeeman.com/node/319
https://github.com/laurentlepee/webserver-macos
https://induste.com/threads/creer-son-environnement-de-developpement-web-local.575268/
  • GZIP
gzip grosfichier.dmd (remplace)
ou
gzip -c grosfichier.dmg > grosfichier.gz (cpoie)
  • APACHE
/usr/local/Cellar/httpd/2.4.41_1/homebrew.mxcl.httpd.plist

$ sudo cp -v /usr/local/Cellar/httpd/2.4.41_1/homebrew.mxcl.httpd.plist /Library/LaunchDaemons
$ sudo chown -v root:wheel /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
$ sudo chmod -v 644 /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
  • MySql
 brew services restart mariadb 
 si il y a de nombreuses bases et de tables il faut augmenter limit.maxfiles du mac
 verifier avec 
$ ulimit -n 
et 
$ ulimit -u

 - create /Library/LaunchDaemons/limit.maxfiles.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>limit.maxfiles</string>
    <key>ProgramArguments</key>
    <array>
      <string>launchctl</string>
      <string>limit</string>
      <string>maxfiles</string>
      <string>524288</string>
      <string>524288</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceIPC</key>
    <false/>
  </dict>
</plist>

 - create /Library/LaunchDaemons/limit.maxproc.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
      <string>limit.maxproc</string>
    <key>ProgramArguments</key>
      <array>
        <string>launchctl</string>
        <string>limit</string>
        <string>maxproc</string>
        <string>2048</string>
        <string>2048</string>
      </array>
    <key>RunAtLoad</key>
      <true />
    <key>ServiceIPC</key>
      <false />
  </dict>
</plist>
  • PHP
brew services restart php72
brew services restart php@5.6
  • avec PHP 5.6
 These steps worked on my Mac, Catalina version 10.15.3 (19D76).

 Step 1: Tap deprecated brew formula
 brew tap exolnet/homebrew-deprecated

 Step 2: Install PHP 5.6
 brew install php@5.6

 You can also have PHP 7.2 just run 
 brew install php@7.2

 Step 3: Install PHP switcher script to switch between 5.6 and 7.2

 $ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw > /usr/local/bin/sphp 
 $ chmod +x /usr/local/bin/sphp

 If you run sphp 7.2 it should work but running sphp 5.6 will not work and will show error like this from apache.
 Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylibn  Referenced from: /usr/local/opt/php@5.6/lib/httpd/modules/libphp5.son  Reason: image not found
 Unless we switch openssl version, it wont work. So we have to install old openssl

 Step 4: Install old openssl
 brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb

 Step 5: Switch to openssl 1.0
 brew switch openssl 1.0.2t

 Now you switch to PHP 5.6 by 
 sphp 5.6

 Everything works.

 ! attention appliquer le patch

 

PATCH PHP 5.6 Catalina (JParkinson1991 commented)

These open issues may also help:
php@5.6 Library not loaded libicui18n.64.dylib
MacOs,  brew install exolnet/deprecated/php@5.6 errors
PHP 5.6 and 7.0 doesn't run on Catalina - openssl 1.0.0 needed
Adds optional openssl@1.1 compatability patch for php@5.6.
 
source:
* https://www.sminrana.com/php/install-php-5-6-on-macos-catalina/
  • avec PHP-FPM
* https://www.aritsltd.com/blog/server/configuring-apache-with-php7-fpm-on-macos-mojave-using-homebrew/
* https://medium.com/@fahimhossain_16989/configuring-apache-with-php7-fpm-for-mac-os-x-using-homebrew-54a26bbdac7c
  • Redemarrer php
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php@7.2.plist
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.php@7.2.plist

Setup PHP

sudo mkdir -p /var/log/php
sudo chmod -R ugo+rw /var/log/php

Update /usr/local/etc/php/5.3/php.ini with some defaults.

error_log = /var/log/php/php.log
date.timezone = "Europe/Paris"

Fix sendmail

sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start

pour mettre en pause par exemple Firefox :

killall -STOP firefox
killall -CONT firefox (relancer)

ou id du processus:

kill -STOP 3221
kill -CONT 3221

supprimer .DS_Store

find . -name '*.DS_Store' -type f -delete

afficher les fichiers cachés et relancer le finder:

defaults write com.apple.finder AppleShowAllFiles 1
osascript -e 'tell app "Finder" to quit' -e 'delay 1' 'tell app "Finder" to activate'

samba3 smbup

sudo nano /opt/local/etc/samba3/smb.conf

repertoire avec caracteres spéciaux

cd "/volumes/quetchose/rep/dossier avec espace"
rsync --delete -avz /Users/compte/rep/ "/volumes/quetchose/rep/dossier avec espace"/

SQL

  • export
/usr/local/mysql-5.6.10-osx10.7-x86_64/bin/mysqldump --default-character-set=latin1 --host=localhost --user=compte --password=pass base  > "/volumes/quetchose/rep/dossier avec espace/fichier.sql"
  • import
/usr/local/mysql-5.6.10-osx10.7-x86_64/bin/mysqldump --default-character-set=latin1 --host=localhost --user=compte --password=pass base  < "/volumes/quetchose/rep/dossier avec espace/fichier.sql"
  • autres
find /usr -type d -name "mysql"
tar -zcvf "/volumes/quetchose/rep/dossier avec espace"/fichier.tar.gz "/volumes/quetchose/rep2/dossier avec espace"/

INSTALLER mavericks

sur clé USB
http://www.metronews.fr/high-tech/apple-comment-installer-la-mise-a-jour-os-x-mavericks-en-7-etapes/mmjx!jeSZ3JAcdgg/
avec DiskMaker
http://liondiskmaker.com

clear DNS cache

sudo killall -HUP mDNSResponder; sleep 2;

changer hostname

sudo scutil --set HostName "nouveaunom"
sudo scutil --set ComputerName "nouveaunom"
sudo scutil --set LocalHostName "nouveaunom"


Volumes

autofs automounter

créer un répertoire de montage

/Users/Shared/mnt/NasUser1 ou /System/Volumes/Data/Users/Shared/mnt/NasUser1
/Users/Shared/mnt/NasUser2 ou /System/Volumes/Data/Users/Shared/mnt/NasUser2
ls -la
dr-xr-xr-x root wheel mnt

créer un fichier de ressources pour automount

/etc/auto_ressources
exemples de partages:
Data   -fstype=smbfs ://user:password@nas._smb._tcp.local/Data
photo   -fstype=smbfs ://user:password@nas._smb._tcp.local/photo
video   -fstype=smbfs ://user:password@nas._smb._tcp.local/video
music   -fstype=smbfs ://user:password@nas._smb._tcp.local/music
download   -fstype=smbfs ://user:password@nas._smb._tcp.local/download

modifier le fichier master pour automount

/etc/auto_master
on retrouve NasUser1 et NasUser2 pour session utilisateur User1 et User2
si un seul partage pour tous les utilisateurs bug quand qu'on bascule de session, le partage n'est plus disponible.
#
# Automounter master map
#
/System/Volumes/Data/Users/Shared/mnt/NasUser1 auto_resources
/System/Volumes/Data/Users/Shared/mnt/NasUser2 auto_resources


+auto_master		# Use directory service
#/net			-hosts		-nobrowse,hidefromfinder,nosuid
/home			auto_home	-nobrowse,hidefromfinder
/Network/Servers	-fstab
/-			-static

exécuter les changements

sudo automount -vc

démonter les volumes

sudo umount /System/Volumes/Data/Users/Shared/mnt/NasUser1

découvrir les options du point de montage

mount | grep NasUser1

qu'est ce qui fonctionne ?

ps -ef | grep automount | grep -v grep
ps -ef | grep autof | grep -v grep

cd dans le repertoire = montage automatique

cd /System/Volumes/Data/Users/Shared/mnt/NasUser1/Repertoire
df -Ph .