【写给自己的教程】合集

 前言

很多时候自己懒不想记这么多东西,所以专门写一篇文章来防止自己下次用到的时候又到处搜

Homebrew类教程(Apple Silicon & Intel)

相应软件包降级

到Homebrew的官方Github上找到更新记录

https://github.com/Homebrew/homebrew-core/commits/master/Formula

找到对应的软件包修改记录,点进去

然后来到本地文件夹

Apple Silicon
/opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula

找到相应要降级的软件包.rb文件,拖到代码编辑器中

替换掉相应的修改即可,然后重新在终端运行

brew reinstall xxxxx

这样就完成降级了

M1下的开发环境配置(均已支持M1芯片)

Git

brew search git
brew info git
brew install git

终端输入

echo $HOME

进入到这个文件夹 找到 command + shift + .

找到 .bash_profile

用代码编辑器打开该文件后,在最后加上brew安装好的git路径,例如我是Apple Silicon的Mac

终端输入代码

brew info git

这个

/opt/homebrew/Cellar/git

就是 GIT_HOME

在 .bash_profile 的最后面加上这两句

export GIT_HOME=/opt/homebrew/Cellar/git/
export PATH=$GIT_HOME/bin:$PATH

这样就可以使用brew下载的git了

Node & Npm

brew search node
brew search npm
brew info node
brew info npm
brew install node
brew install npm

一般装了node都会默认装npm

Postgresql

brew search postgresql
brew info postgresql
brew install postgresql
brew services start postgresql
brew services stop postgresql
brew services restart postgresql

MySQL

brew search mysql
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

上面brew给了一条restart命令,意思是重启的意思,从这我们可以衍生出两条命令,一条是停止,一条是启动,如下

brew services stop mysql
brew services start mysql

Tomcat

brew search tomcat
brew install tomcat

Maven

brew search maven
brew install maven

Maven Aliyun仓库

<mirror>
    <id>aliyunmaven</id>
    <mirrorOf>central</mirrorOf>
    <name>aliyun maven</name>
    <url>https://maven.aliyun.com/repository/public </url>
</mirror>

OpenJDK

brew search openjdk
brew install openjdk

把HomeBrew安装的openjdk链接到JVM

sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

这样JVM目录下就会有一个快捷目录,用IDEA的时候就可以快速识别到
什么?手贱删了JVM目录之后用命令提示没找到目录?手动创建一个不就完了,什么?还要我给命令?你疯了?

Httpd

首先先声明如果你是要用HomeBrew的httpd,那就先执行下面的命令,先把自带的httpd给取消开机启动

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
//当然想开机启动就是这样
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

关于自带的httpd命令如下

sudo apachectl stop
sudo apachectl start
sudo apachectl restart

其实macOS系统里面有自带的httpd的,这个装不装无所谓,但是你要是非要说你要用Homebrew来管理,装一个也不是不行,老规矩,上命令

brew search httpd
brew install httpd

安装完之后提示信息如下

DocumentRoot is /opt/homebrew/var/www.
The default ports have been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in
    /opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.
To restart httpd after an upgrade:
    brew services restart httpd
Or, if you don't want/need a background service you can just run:
    /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND

意思就是说,httpd的根目录是/opt/homebrew/var/www,默认的端口是8080
三条httpd的命令

brew services restart httpd    //重启
brew services start httpd    //启动
brew services stop httpd    //停止

PHP

brew search php
brew install php

安装完后提示如下信息

To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/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.1/

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

先不要着急,如果你没有安装httpd的话,建议你还是跳回上一步安装好httpd再来,安装了当我没说,以下教程适用于HomeBrew安装的httpd
前往文件夹/opt/homebrew/etc/httpd/ 里面有一个 httpd.conf 文件,打开这个文件
你会看到非常多的 LoadModule
在最后一个 LoadModule 下面加一行PHP安装完后的提示,也就是

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

添加完后,Command + F找到 DirectoryIndex ,找到后是这样显示的

DirectoryIndex index.html

将它改为

DirectoryIndex index.php index.html

保存即可,别忘了php的配置文件在 /opt/homebrew/etc/php/8.1/

brew services restart php
brew services stop php
brew services start php

如果你喜欢用macOS自带的httpd的话,那么httpd.conf文件就是在/private/etc/apache2 然后步骤都是一样的

brew常用命令

brew -v                              //查看brew版本
brew –help                        //查看帮助
brew install XXXXX          //安装XXXXX包
brew uninstall XXXXX      //卸载XXXXX包
brew search XXXXX         //搜索XXXXX包
brew list                             //显示已安装的包列表
brew update                      //更新Homebrew自己
brew upgrade                    //更新软件,可带指定包
//通常上面两个命令我是先update再upgrade
brew outdated                    //询可更新的包
brew cleanup XXXXX        //删除XXXXX包的旧版本
brew cleanup                      //删除所有包的旧版本
brew cleanup -n                 //查看可清理的旧版本包,不执行实际操作
brew info XXXXX                //查看包的信息

brew访问太慢

ClashX复制终端代理命令,例如

export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890

回车,终端就走代理了,但只对当前终端有效,挺不错的,毕竟节点有时候也会抽风

brew换源

//官方源 
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask
//清华源 
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git 
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git 
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
//中科大源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
//阿里源
git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-cask.git
//查看brew.git源
//查看homebrew-core.git源
//查看homebrew-cask.git源
git -C "$(brew --repo)" config --get remote.origin.url
git -C "$(brew --repo homebrew/core)" config --get remote.origin.url
git -C "$(brew --repo homebrew/cask)" config --get remote.origin.url

安装教程类

Mac上的Tomcat & IDEA配置

Android Studio的安装和配置

Mac上的PhpStorm环境配置

Node&NPM类

更换淘宝源或其他源

npm config set registry https://registry.npm.taobao.org

Jetbrains类

常用快捷键合集(Mac)

以下快捷键均在IntelliJ IDEA中测试可用,理论上Jetrains全家桶通用

control + return    //生成各种方法
control + shift + J    //将下一行移动到本行行尾部
control + O    //Override方法
control + I    //实现接口中的方法
control + option + O    //优化import
control + option + I    //缩进到缩进线
shift + return    //不影响本行的情况下切换到下一行
shift + F6    //批量重命名
shift + Tab    //反缩进代码
command + return    //在下方新增一行,并使光标处于当前行
command + J    //生成一些代码,例如if,for
command + B    //寻找目标变量的来源
command + G    //寻找变量且定位
command + shift + enter    //代码补全,补全指的是补全代码体部分
command + P    //方法参数提示
command + option + T    //把选中的代码放在 try{} if{} else{} 里 
command + option + /    //多行注释
command + option + 左右箭头    //返回上次编辑的位置
command + +    //展开代码块
command + -    //折叠代码块
command + shift + +     //展开所有代码块
command + shift + -    //折叠所有代码块
option + return    //导入未引入的类/包
option + Fn + delete    //删除到单词的末尾

未完待续

版权声明:
作者:X1a0He
链接:https://www.x1a0he.com/tutorialforme
来源:X1a0He's Blog
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>