MacBook 开箱配置

安装 git 附带安装 Xcode

Mac 下使用 git 命令即可自动安装 Xcode 命令工具

git config --global user.name "Your Name"
git config --global user.email you@example.com

git config --global push.default matching
git config --global push.default simple

旧 Git 项目

将密钥放入 .ssh

git config pull.rebase true
git push

安装 On My Zsh

git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
#curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
#wget
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
#fetch
sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

vim .zshrc

alias la='ls -a'
alias py='python3'
alias workfold='cd ~/Documents/Dropbox/htdocs/project'
alias yiic='~/Documents/Dropbox/htdocs/project/datacenter/protected/yiic'
alias yii='~/Documents/Dropbox/htdocs/project/dacs/yii'
alias setproxy='export ALL_PROXY=socks5://127.0.0.1:7891'
alias unsetproxy='unset ALL_PROXY'
alias showip='curl https://ip.cn/'

alias -s php=vim
alias -s gz='tar -xzvf'
alias -s tgz='tar -xzvf'
alias -s zip='unzip'
alias -s bz2='tar -xjvf'

安装 HomeBrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

网络原因安装失败,重新安装报错: error: Not a valid ref: refs/remotes/origin/master

rm -rf /opt/homebrew

重新安装

- Run these two commands in your terminal to add Homebrew to your PATH:
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/freperl/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"

查看环境配置 brew doctor

Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

Software Update Tool

Finding available software
Downloading macOS Monterey 12.4
Password: 

#All are ok. brew doctor Your system is ready to brew.

安装软件包前使用更新命令

brew update && brew upgrade

安装 PHP-FPM

brew install php@7.3 Error: php@7.3 has been disabled because it is a versioned formula!

You can only install supported versions of PHP with brew. However, there is the tap shivammathur/php which can be used to install unsupported version of PHP.

brew install php@8.0

To enable PHP in Apache add the following to httpd.conf and restart Apache:

LoadModule php_module /opt/homebrew/opt/php@8.0/lib/httpd/modules/libphp.so
<FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch>

Finally, check DirectoryIndex includes index.php

DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:

/opt/homebrew/etc/php/8.0/

php@8.0 is keg-only, which means it was not symlinked into /opt/homebrew, because this is an alternate version of another formula.

If you need to have php@8.0 first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/php@8.0/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/opt/homebrew/opt/php@8.0/sbin:$PATH"' >> ~/.zshrc

For compilers to find php@8.0 you may need to set: export LDFLAGS="-L/opt/homebrew/opt/php@8.0/lib" export CPPFLAGS="-I/opt/homebrew/opt/php@8.0/include"

To restart php@8.0 after an upgrade: brew services restart php@8.0 Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/php@8.0/sbin/php-fpm --nodaemonize

brew tap shivammathur/php
brew install shivammathur/php/php@7.4
brew link php@7.4
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /opt/homebrew/etc/php/7.4/

php@7.4 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have php@7.4 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/opt/homebrew/opt/php@7.4/sbin:$PATH"' >> ~/.zshrc

For compilers to find php@7.4 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/php@7.4/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/php@7.4/include"


To restart shivammathur/php/php@7.4 after an upgrade:
  brew services restart shivammathur/php/php@7.4
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/php@7.4/sbin/php-fpm --nodaemonize

brew install nginx

Docroot is: /opt/homebrew/var/www

The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo.

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To restart nginx after an upgrade: brew services restart nginx Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/nginx/bin/nginx -g daemon off; ==> Summary 🍺 /opt/homebrew/Cellar/nginx/1.21.6_1: 26 files, 2.2MB ==> Running brew cleanup nginx... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see man brew).

brew services start nginx

brew install mysql

We've installed your MySQL database without a root password. To secure it run:

mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:

mysql -uroot

To restart mysql after an upgrade: brew services restart mysql Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/mysql/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql

迁移旧数据,整个mysql 文件夹

mysql_upgrade

The mysql_upgrade client is now deprecated. The actions executed by the upgrade client are now done by the server. To upgrade, please start the new MySQL binary with the older data directory. Repairing user tables is done automatically. Restart is not required after upgrade. The upgrade process automatically starts on running a new MySQL binary with an older data directory. To avoid accidental upgrades, please use the --upgrade=NONE option with the MySQL binary. The option --upgrade=FORCE is also provided to run the server upgrade sequence on demand. It may be possible that the server upgrade fails due to a number of reasons. In that case, the upgrade sequence will run again during the next MySQL server start. If the server upgrade fails repeatedly, the server can be started with the --upgrade=MINIMAL option to start the server without executing the upgrade sequence, thus allowing users to manually rectify the problem.

[InnoDB] Upgrade after a crash is not supported. This redo log was created with MySQL 5.7.34. Please follow the instructions at http://dev.mysql.com/doc/refman/8.0/en/upgrading.html

brew install mysql@5.7

迁移旧数据,整个mysql 文件夹

/opt/homebrew/etc/my.cnf

# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
#mysqlx-bind-address = 127.0.0.1

phpMyAdmin

brew install phpmyadmin

To enable phpMyAdmin in Apache, add the following to httpd.conf and restart Apache:

    Alias /phpmyadmin /opt/homebrew/share/phpmyadmin
    <Directory /opt/homebrew/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>

Then open http://localhost/phpmyadmin The configuration file is /opt/homebrew/etc/phpmyadmin.config.inc.php ==> Summary 🍺 /opt/homebrew/Cellar/phpmyadmin/5.2.0: 3,553 files, 44.7MB ==> Running brew cleanup phpmyadmin... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see man brew).