分类:技术
-
在 macOS(Apple Silicon)根目录下创建目录的正确方式
在 macOS 上,我想在根目录(/)下创建一个目录,比如 /data1,用于放置项目数据。
mkdir /data1结果系统提示:
mkdir: /data1: Read-only file system一开始我以为是权限问题,于是又试了:
sudo mkdir /data1但依然报错,说明即使
sudo也不行。为什么会这样?
从 macOS Big Sur(11) 开始,苹果对系统盘启用了 Signed System Volume(SSV)签名保护机制。
这意味着:
系统卷
/是 只读的 APFS 快照;即使是 root 用户,也不能直接修改;
mount -uw /在 Apple Silicon(M1/M2/M3)上会报错:mount_apfs: volume could not be mounted: Permission denied mount: / failed with 66简单来说:根目录是锁死的。
-
通过 pyenv 配合 venv 来创建项目专属的虚拟环境
安装
pyenvcurl https://pyenv.run | bash这条命令会自动安装以下工具:
pyenvpyenv-doctor(检查pyenv安装的健康状况)pyenv-virtualenv(用于创建 Python 虚拟环境)
更新 Shell 配置
vim ~/.bashrcecho -e 'export PATH="$HOME/.pyenv/bin:$PATH"\n' \ 'eval "$(pyenv init --path)"\n' \ 'eval "$(pyenv init -)"\n' \ 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrcsource ~/.bashrc安装 Python 版本
pyenv install 3.11.9设置全局或本地 Python 版本
设置一个全局的 Python 版本(用于所有项目):
pyenv global 3.11.9你还可以为特定目录设置本地版本,例如在某个项目目录下:
pyenv local 3.8.12这会创建一个
.python-version文件,记录该项目使用的 Python 版本。创建虚拟环境(使用 venv)
python -m venv venv激活虚拟环境
对于 Bash/Zsh(Linux/macOS):
source venv/bin/activate对于 Windows(CMD):
.\venv\Scripts\activate -
解决 Python 3.8+ 遇到的 OpenSSL 版本不兼容的问题
在安装 Python3.8 时可能会遇到与系统自带 OpenSSL 版本不兼容的问题。Python3.8 需要的 OpenSSL 版本为
1.0.2或1.1.x。如果系统中默认的 OpenSSL 版本低于需求(通常是OpenSSL 1.0.1),会导致如下错误:Could not build the ssl module! Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host(). -
MySQL 容器异常 - mbind: Operation not permitted
2024-06-03 09:23:25+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started. 2024-06-03 09:23:25+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2024-06-03 09:23:25+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started. 2024-06-03T09:23:25.944402Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. 2024-06-03T09:23:25.944530Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead. 2024-06-03T09:23:25.944549Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27) starting as process 1 2024-06-03T09:23:25.970311Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2024-06-03T09:23:26.546899Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2024-06-03T09:23:26.881580Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main 2024-06-03T09:23:26.881612Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main 2024-06-03T09:23:26.899326Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2024-06-03T09:23:26.899366Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2024-06-03T09:23:26.989154Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. 2024-06-03T09:23:27.078117Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.27' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL. 2024-06-03T09:23:27.078165Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock mbind: Operation not permitted mbind: Operation not permitted mbind: Operation not permitted -
macOS 终端使用 Solarized Dark xterm-256color 主题
1. 下载主题文件
Solarized 是一款经典的终端配色方案,护眼又高对比度。可以在官方仓库下载 macOS 终端主题:
git clone https://github.com/altercation/solarized.git主题路径位于:
solarized/osx-terminal.app-colors-solarized/其中包括两个文件:
Solarized Dark xterm-256color.terminalSolarized Light xterm-256color.terminal
2. 导入主题
- 打开 Terminal.app
- 依次点击:
偏好设置 (Preferences)→Profiles - 点击左下角的 齿轮图标 →
导入... - 选择
Solarized Dark xterm-256color.terminal - 设置为默认主题:在主题上右键 → 选择「设为默认」
完成后重新打开终端,就能看到舒适的 Solarized Dark 效果。
3. 优化选中文本配色
- 打开 终端 → 设置 → 配置文件 → 文本 → 选中颜色
- 点击右侧的小色块(打开颜色选取器)
- 在弹出的窗口上方点 “滑块图标”(像三根小杠的那个),切换模式
- 在上方的下拉菜单中选择:RGB 滑块
- 在十六进制颜色编号框输入
284B5A
4. 设置字体
在 macOS 终端中,个人比较喜欢
SF Mono Terminal 11,苹果官方风格,简洁干净。 JetBrains Mono 字体也相当不错,专为开发设计,字符区分度高(比如 0/O, 1/l/I),自带连字(可以关闭),粗细分布合理,长时间看不累。 -
VS Code 设置编辑器及终端的字体和字号
作为一名开发者,我们都希望拥有一个舒适的编码环境。最近在配置 VS Code 的字体时遇到了一些问题,经过一番调试,终于找到了完美的解决方案。今天分享这个过程,希望能帮到有相似困扰的朋友。
第一次尝试:基础配置
{ "editor.fontFamily": "SF Mono, monospace", "editor.fontSize": 13, "terminal.integrated.fontFamily": "SF Mono, monospace" "terminal.integrated.fontSize": 13 }结果:字体和字号都不生效。
第二次尝试:带空格的字体加单引号
{ "editor.fontFamily": "'SF Mono', monospace", "editor.fontSize": 13, "terminal.integrated.fontFamily": "'SF Mono', monospace" "terminal.integrated.fontSize": 13 }结果:字号生效,字体不生效。
然而,在配置过程中还遇到了一个令人困扰的错误:
终端仅支持等宽字体。如果这是新安装的字体,请确保重新启动 VS Code。
最终打开目录
/System/Applications/Utilities/Terminal.app/Contents/Resources/Fonts/双击
SFMono-Regular.otf→ “安装字体”问题解决!
以下是完整的
~/Library/Application\ Support/Code/User/settings.json{ "workbench.colorTheme": "Solarized Dark", "roo-cline.allowedCommands": [ "git log", "git diff", "git show" ], "roo-cline.deniedCommands": [], "security.workspace.trust.untrustedFiles": "open", "editor.fontFamily": "'SF Mono', Menlo, monospace", "editor.fontSize": 13, "terminal.integrated.fontFamily": "'SF Mono Terminal', Menlo, monospace", "terminal.integrated.fontSize": 13 } -
Undefined index: constraint_name 报错解决方法
错误日志
[error][yii\base\ErrorException:8] yii\base\ErrorException: Undefined index: constraint_name in /path/to/vendor/yiisoft/yii2/db/mysql/Schema.php:394原因
MySQL 8.0.21 中返回的列名大小写不一致,导致 Yii2 在获取数据库模式时出错。
解决方法
编辑 common/config/main-local.php,设置 PDO 属性
PDO::ATTR_CASE => PDO::CASE_LOWER'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=db_name', 'username' => 'username', 'password' => '******', 'attributes' => [PDO::ATTR_CASE => PDO::CASE_LOWER], ],修改 /path/to/vendor/yiisoft/yii2/db/mysql/Schema.php:394
foreach ($rows as $row) { $row = array_change_key_case($row, CASE_LOWER);
推荐第一种方法,使列名明确指定为一致的大小写。
参考文章:https://github.com/yiisoft/yii2/issues/18171
-
入职满 7 周年纪念日

-
入职满 6 周年纪念日

-
Docker 清理无效容器镜像及日志的方法
清除无效容器、网络、镜像、缓存
docker system prune:删除停止的容器、未使用的网络、悬空的镜像和构建缓存。docker system prune -a:删除停止的容器、未使用的网络、所有未使用的镜像(不仅仅是悬空的镜像)和构建缓存。
清除日志
创建 clean_docker_log.sh,内容如下:
#!/bin/bash logs=$(find /var/lib/docker/containers/ -name *-json.log) for log in $logs do echo "clean logs : $log" cat /dev/null > $log done echo "Docker logs cleanup completed."给脚本增加可执行权限
# chmod +x clean_docker_log.sh执行脚本
# ./clean_docker_log.sh
文章归档
文章日历
| 2025 年 11 月 | ||||||
|---|---|---|---|---|---|---|
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
| 25 | 26 | 27 | 28 | 29 | 30 | 01 |
| 02 | 03 | 04 | 05 | 06 | 07 | 08 |
| 09 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 01 | 02 | 03 | 04 | 05 | 06 | 07 |
文章标签
- Linux
- Go
- Yii
- 新浪
- CentOS
- PHP
- Git
- WSL
- Composer
- Mac
- 入职
- Bootstrap
- macOS
- UCenter
- 厦门
- 出差
- 长沙
- 湖南卫视
- 微博
- Tengine
- YUI
- 泰国
- pecl
- 优化
- GitLab
- 迁移
- rootless
- 年会
- 生日
- Tengin
- RedHat
- Sphinx
- cygwin
- Windows
- Tmux
- Zsh
- 升级
- MySQL
- sql_mode
- Shadowsockets
- 面向对象
- HTTP
- 状态码
- grep
- unoconv
- PPT
- Nginx
- htpasswd
- golang
最新评论
-
Tengine 2.2.2 配置 http2 协议出现的坑 -
Yii China 是官方唯一认可的中文社区 -
Go 语言中 json 的操作以及常见问题 -
新浪赴泰国曼谷和芭提雅团建 -
CentOS 安装 PHP7 -
WordPress 如何控制每页显示的条数 -
关于 phpMyAdmin 免输入用户名和密码,直接进入管理界面 -
PHP 5.4 的新特性 -
PHP 5.4 的新特性 -
PHP 5.4 的新特性