让命令行看起来更简单
vim ~/.zshrc
内容如下
export PS1="%1~ "
#export PATH="$HOME/.composer/vendor/bin:$PATH"
让配置生效
source ~/.zshrc
接着需要安装 macOS 系统的命令行工具,执行如下命令
sudo rm -rf $(xcode-select -print-path)
xcode-select --install
这样的安装命令会删除旧版本的命令行工具包,然后安装最新版本的命令行工具包。
一、配置 Homebrew 环境
1. 安装 Homebrew
git clone https://github.com/Homebrew/install.git
cd install
vim install.sh
然后修改代码如下
#BREW_REPO="https://github.com/Homebrew/brew"
BREW_REPO="https://mirrors.ustc.edu.cn/brew.git"
通过如下命令执行安装
./install.sh
当出现如下文字提示时
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
执行如下命令
git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
2. 配置中科大镜像
替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
替换Homebrew Bottles源
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
3. 安装常用的软件
brew update
brew install mpv atom mysql composer npm
4. 配置国内镜像
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
npm config set registry https://registry.npm.taobao.org
二、配置 MPV 播放器
vim ~/.config/mpv/mpv.conf
内容如下
no-border
ontop=yes
autofit-larger=49%x64%
save-position-on-quit=yes
三、安装 ATOM 插件
apm install platformio-ide-terminal atom-beautify atom-vue file-icons emmet linter-jshint
四、配置 Apache 环境
1. 设置 Apache 配置文件 httpd.conf
sudo vim /etc/apache2/httpd.conf
取消以下行的注释
#LoadModule php7_module libexec/apache2/libphp7.so
#LoadModule rewrite_module libexec/apache2/mod_rewrite.so
#LoadModule userdir_module libexec/apache2/mod_userdir.so
#Include /private/etc/apache2/extra/httpd-userdir.conf
#Include /private/etc/apache2/extra/httpd-vhosts.conf
修改如下代码
User _www
Group _www
如下
User jackie
Group staff
2. 开启个人的配置文件 httpd-userdir.conf
sudo vim /etc/apache2/extra/httpd-userdir.conf
注销如下代码
#Include /private/etc/apache2/users/*.conf
3. 创建个人的配置文件 jackie.conf
sudo vim /etc/apache2/users/jackie.conf
内容如下
<Directory "/Users/jackie/Sites">
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
4. 设置多站点配置文件 httpd-vhosts.conf
sudo vim /etc/apache2/extra/httpd-vhosts.conf
内容如下
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "/Library/WebServer/Documents"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@test.local
DocumentRoot "/Users/jackie/Sites/test"
ServerName test.local
ServerAlias *.test.local
ErrorLog "/private/var/log/apache2/test.local-error_log"
CustomLog "/private/var/log/apache2/test.local-access_log" common
</VirtualHost>
5. 部署网站代码
创建网站代码目录
mkdir -p ~/Sites/test
创建网站代码
cd ~/Sites/test
vim index.php
内容如下
<?php
echo 'It works now.'
6. 解析域名
sudo vim /etc/hosts
最后面加一行代码如下
127.0.0.1 test.local
这个时候就可以通过浏览器访问test.local了。
五、配置数据库
brew services start mysql
mysql -uroot
1. 创建 Mysql 用户
CREATE USER jackie@localhost IDENTIFIED WITH mysql_native_password BY '123456';
2. 创建 test 数据库
CREATE DATABASE test;
3. 授权 Mysql用户
GRANT all ON test.* TO jackie@localhost;
4. 撤销 Mysql 用户的授权
REVOKE all ON test.* FROM jackie@localhost;
5. 删除 Mysql 用户
DROP USER jackie@localhost;
6. 数据库导出
mysqldump -h 127.0.0.1 -uroot -p test > test.sql
7. 数据库导入
mysql -uroot test < test.sql
8. 拷贝本地文件到远程服务器
scp test.sql jackie@Server_IP:~
9. 拷贝远程服务器文件到本地
scp jackie@Server_IP:/home/jackie/test.sql ~
网友评论