systemd 清理不必要的service

执行systemctl status时,发现如下输出:

➔ systemctl status
● hostname
    State: degraded
     Jobs: 0 queued
   Failed: 1 units
    Since: Tue 2018-10-30 06:51:31 CST; 1 years 9 months ago
   CGroup: /
           ├─1 /usr/lib/systemd/systemd --system --deserialize 21

state的状态是degraded,查了一下发现是由于我的nginx service未启动,因为前几天手动编译安装了nginx,并且新建了一个nginx@1.18.service,所以这个service其实没用到了,把它清理掉吧:

systemctl stop [servicename]
systemctl disable [servicename]
rm /etc/systemd/system/[servicename]
rm /etc/systemd/system/[servicename] # and symlinks that might be related
rm /usr/lib/systemd/system/[servicename] 
rm /usr/lib/systemd/system/[servicename] # and symlinks that might be related
systemctl daemon-reload
systemctl reset-failed

记几次面试他人的经历

最近这段时间由于领导没空,让我临时当面试官👀,虽然我也不是什么大牛,但是还算读得起我这4、5年的工作经验吧,记录一下我当面试官的一些经历,可能由于我出的面试题是真正我自己出的,而不是网上copy的那些,导致很多面试者表现不是特别好。出于某些原因,所有人名字均用字母表示。

Continue reading "记几次面试他人的经历"

brew update灾难来了!

我以前用brew 安装了多个php的版本,早上执行了brew update后php就用不了了

# openssl版本不对了
➔ /usr/local/opt/php@5.6/bin/php -v
dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
  Referenced from: /usr/local/opt/php@5.6/bin/php
  Reason: image not found
[1]    16051 abort      /usr/local/opt/php@5.6/bin/php -v
# 把我的xdebug.so删掉了
➔ /usr/local/opt/php@7.2/bin/php -v
Failed loading /usr/local/opt/php@7.2/lib/php/20170718/xdebug.so:  dlopen(/usr/local/opt/php@7.2/lib/php/20170718/xdebug.so, 9): image not found
PHP 7.2.32 (cli) (built: Jul 10 2020 00:06:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.32, Copyright (c) 1999-2018, by Zend Technologies
# 又不知道缺了啥
➔ /usr/local/opt/php@7.4/bin/php -v
dyld: Library not loaded: /usr/local/opt/libffi/lib/libffi.6.dylib
  Referenced from: /usr/local/opt/php@7.4/bin/php
  Reason: image not found
[1]    16126 abort      /usr/local/opt/php@7.4/bin/php -v

我真的是太难了!!!

php5.6解决办法

其实可能我的电脑里已经有openssl@1.0,只是软链接指向变了,你也可以先直接修改软链接试试。

# 安装openssl@1.0
brew install rbenv/tap/openssl@1.0

# 修改symlink
ln -sf /usr/local/opt/openssl@1.0 /usr/local/opt/openssl

继续尝试:

➔ /usr/local/opt/php@5.6/bin/php -v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /usr/local/opt/php@5.6/bin/php
  Reason: image not found
[1]    52151 abort      /usr/local/opt/php@5.6/bin/php -v

看看是否icu4c的老版本在不在吧:

➔ ll /usr/local/opt/icu4c
lrwxr-xr-x  1 jake  admin    20B Jul 22 11:36 /usr/local/opt/icu4c -> ../Cellar/icu4c/67.1

ll /usr/local/Cellar/icu4c/
total 0
drwxr-xr-x  12 jake  staff   384B Jun 28  2019 64.2
drwxr-xr-x  12 jake  staff   384B Jul 22 11:36 67.1

可能是64.2,试试:

ln -sf /usr/local/Cellar/icu4c/64.2 /usr/local/opt/icu4c

这一次php5.6就复活了!

➔ /usr/local/opt/php@5.6/bin/php -v                                                     
PHP 5.6.40 (cli) (built: Apr 23 2019 11:14:34) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans

php7.2那还能怎么办,选择原谅她啦

去这里:https://xdebug.org/wizard 把phpinfo的信息粘进去,重新build一个吧。

但是其实更严重的问题来了,php7.2依赖/usr/local/Cellar/icu4c/67.1,而php5.6依赖/usr/local/Cellar/icu4c/64.2,(php7.4却可以正常,神奇!)那只好把/usr/local/Cellar/icu4c/67.1的内容复制到/usr/local/Cellar/icu4c/64.2去吧:

# 复制以下两种文件似乎就可以了
➔ cp /usr/local/Cellar/icu4c/67.1/lib/*.67.1.dylib /usr/local/Cellar/icu4c/64.2/lib/
➔ cp /usr/local/Cellar/icu4c/67.1/lib/*.67.dylib /usr/local/Cellar/icu4c/64.2/lib/

➔ /usr/local/opt/php@7.2/bin/php -v
Failed loading /usr/local/opt/php@7.2/lib/php/20170718/xdebug.so:  dlopen(/usr/local/opt/php@7.2/lib/php/20170718/xdebug.so, 9): image not found
PHP 7.2.32 (cli) (built: Jul 10 2020 00:06:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.32, Copyright (c) 1999-2018, by Zend Technologies

可以了,稍后去把xdebug.so build出来。

php7.4如法炮制

➔ rm /usr/local/opt/libffi
➔ ln -s /usr/local/Cellar/libffi/3.2.1 /usr/local/opt/libffi

➔ /usr/local/opt/php@7.4/bin/php -v
PHP 7.4.4 (cli) (built: Mar 19 2020 20:12:27) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.4, Copyright (c), by Zend Technologies
    with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans

git只add修改的和删除的文件

有时候我本地会写些tests测试用例文件,但是这些文件并不需要被提交,但是它们却有混杂在其他被修改的文件中,那该怎么办呢?

  1. 好的做法是修改.gitignore把这些文件排除开来
  2. 也可以通过git add -u app/ 这样,app目录下除了新增的文件没有被add,其他修改的和删除的都add进去了

另外如果你把一个不想提交的文件add了,可以使用git reset HEAD filename取消add。