Files
Deployments/NginxAndLetsencrypt/经验汇集.md
2020-04-26 17:01:11 +08:00

93 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 经验汇集
## 常用指令
* Docker相关
```
docker network ls
docker network rm 【网络名称】
docker inspect 【容器id/名称】
docker logs -f -t --since="2017-05-31" --tail=10 【容器名称】 #动态查看容器日志
```
* Linux
```
history #查看历史执行命令
tail -n 20 【文件名】#查看文件的后20行
du -sh * #查看目录下的磁盘占用情况
```
* Vim
```
history #查看历史执行命令
tail -n 20 【文件名】#查看文件的后20行
```
## 坑记
### Nginx
#### 请求大小限制
在http 的 server 节点中添加`client_max_body_size`。参见https://blog.csdn.net/yedajiang44/article/details/99294216
#### Nginx开启gzip
参考:https://blog.csdn.net/bigtree_3721/article/details/79849503
### 未分类
#### 域名解析
域名解析做完整。如果要给ycmusic.cn配证书不要忘记相应添加域名解析。可以参考
如何解析设置域名添加www和不添加www都能够访问
*来自 <*[*https://jingyan.baidu.com/article/6d704a130c6d0d28db51ca3c.html*](https://jingyan.baidu.com/article/6d704a130c6d0d28db51ca3c.html)*>*
#### 文本格式导致的脚本执行错误问题
注意在windows下编辑的文本格式是dos格式需要改成unix格式才能作为sh脚本在linux下执行。否则会出现诸如
bin/bash^M: bad interpreter: No such file or directory
参考[*https://blog.csdn.net/helloxiaozhe/article/details/90347064解决*](https://blog.csdn.net/helloxiaozhe/article/details/90347064)
另外,可以采用vs的编码保存,其中指定行尾设置
#### Let's Encrypt可以添加--dry-run参数来验证运行
例如:
docker-compose run --rm --entrypoint "\
certbot certonly **--dry-run** --webroot -w /var/www/certbot \
$staging_arg \
$email_arg \
$domain_args \
--rsa-key-size $rsa_key_size \
--agree-tos \
--force-renewal" certbot
echo
#### docker-compose中的特殊字符
如有特殊字符,用""将包含特殊字符的字符串包裹起来。如果有$,哪怕在引号内,也需要输入两个$$以作转义。
例如:
db:
image: "mysql:5.7.27"
restart: always
environment:
- MYSQL_ROOT_PASSWORD="mima$$woshimima"
不过,上面的又有引号又有$的设置是否正确并不确定因为初次这么设置发现无法登录通过docker exec -it 进入执行mysql -uroot -p
#### docker-compose中mysql的密码设置
第一次运行后,只要/var/lib/mysql中的数据没有改变这通常是因为已经mount到主机的特定目录那么后续的密码更改是无效的哪怕把container删了再重建也一样。所以这个时候要不然用原来密码登录要不然就是清空data目录。data目录需要有不然docker-compose up会失败