# MacOS 初始安裝 ## 套件管理 ### Homebrew https://brew.sh/index_zh-tw ``` 安裝 Homebrew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 更新 Homebrew brew update 檢查 Homebrew brew doctor ``` ``` 查詢套件 brew search <package> 安裝套件 brew install <package> 查看已安裝套件的資訊 brew info <package> 更新套件 brew upgrade <package> 移除套件 brew uninstall <package> 列出已安裝的套件 brew list 查詢有哪些套件的版本已經過期 brew outdated 刪除舊的套件版本 預設的情況下,Homebrew不會移除舊的套件,一段時間後,系統上會累積很多舊的套件 % brew cleanup -n #-n 是顯示刪除的過程,可以了解有哪些套件被刪除了 ``` * [教學] Homebrew使用教學 https://www.ptt.cc/bbs/MAC/M.1451965224.A.4C4.html > Note: 關於cask ### 建議安裝 **瀏覽器** Chrome ``` brew cask install google-chrome ``` **文字編輯器** 1. Sublime Text 3 https://www.sublimetext.com/ ``` brew cask install sublime-text ``` 2. Visual Studio Code https://code.visualstudio.com/ ``` brew cask install visual-studio-code ``` **通訊** Mattermost https://mattermost.com/ ``` brew cask install mattermost ``` **終端機** iTerm2 + zsh https://www.iterm2.com/ https://ohmyz.sh/ ``` brew cask install iterm2 ``` * 超簡單!十分鐘打造漂亮又好用的 zsh command line 環境 https://medium.com/statementdog-engineering/prettify-your-zsh-command-line-prompt-3ca2acc967f **其他** 1. Fliqlo https://fliqlo.com/ 翻頁時鐘螢幕保護程式 ``` brew cask install fliqlo ``` > Note: 設定>桌面與螢幕保護程式 Fliqlo ## Webserver ### PHP macOS 內建PHP ``` 檢查PHP版本 php -v ``` * install ext-zip for Mac https://stackoverflow.com/questions/58290566/install-ext-zip-for-mac * macOS High Sierra with built-in PHP https://medium.com/@romaninsh/macos-high-sierra-with-built-in-php-52bcb5c2398c ### Apache 1. 建立網頁檔案資料夾 `/Users/jouan/Sites` 2. 編輯 `httpd.conf` ``` sudo vim /etc/apache2/httpd.conf ``` > 取消註解 > `#LoadModule php7_module libexec/apache2/libphp7.so` > `#LoadModule socache_shmcb_module lib/httpd/modules/mod_socache_shmcb.so` > `#LoadModule ssl_module lib/httpd/modules/mod_ssl.so` > `#Include /private/etc/apache2/extra/httpd-ssl.conf` > 將 `/Library/WebServer/Documents` 取代為 `/Users/jouan/Sites` 3. 編輯 `httpd-ssl.conf` ``` sudo vim /private/etc/apache2/extra/httpd-ssl.conf ``` > 將 `/Library/WebServer/Documents` 取代為 `/Users/jouan/Sites` 4. 編輯 `httpd-vhosts.conf` ``` sudo vim /private/etc/apache2/extra/httpd-vhosts.conf ``` > <VirtualHost *:443> > DocumentRoot "/Users/jouan/Sites" > ServerName localhost > SSLEngine on > SSLCertificateFile "/private/etc/apache2/server.crt" > SSLCertificateKeyFile "/private/etc/apache2/server.key" > </VirtualHost> 5. 啟用Apache ``` sudo apachectl start ``` * Set up localhost on macOS High Sierra (Apache, MySQL, and PHP 7) with SSL/HTTPS https://websitebeaver.com/set-up-localhost-on-macos-high-sierra-apache-mysql-and-php-7-with-sslhttps * Install PHP 7.2 + xdebug on MacOS High Sierra (with homebrew July 2018) https://medium.com/@romaninsh/install-php-7-2-xdebug-on-macos-high-sierra-with-homebrew-july-2018-d7968fe7e8b8 * macOS 10.14 Mojave Apache Setup: SSL https://getgrav.org/blog/macos-mojave-apache-ssl * mac下Apache服务配置Https https://blog.csdn.net/shimazhuge/article/details/53174203 ### MariaDB ``` brew install mariadb brew services start mariadb ``` 更改root密碼 ```SQL mysql -uroot use mysql; UPDATE user SET password=PASSWORD("new-password") WHERE User='root'; flush privileges; exit mysql.server restart ``` * Installing MariaDB Server on macOS Using Homebrew https://mariadb.com/kb/en/library/installing-mariadb-on-macos-using-homebrew/ * [折騰筆記] MariaDB 重設密碼 https://medium.com/@jiajunxu/折騰筆記-mariadb-重設密碼-22761a6ad8f9 ### Adminer https://www.adminer.org 下載檔案`adminer-4.x.x.php` > 複製到 `/Users/jouan/Sites` 開啟以下頁面登入即可使用 http://localhost/adminer-4.7.1.php?server=127.0.0.1 ## Git git config --global user.name "Jouan Chen" git config --global user.email joannecja@gmail.com git config --global alias.co checkout git config --global alias.br branch git config --global alias.ci commit git config --global alias.st status