宝塔面板维护记录bt.cn
一次帮朋友维护宝塔面板的技术笔记
相关重要目录
- 网站程序目录:
/www/wwwroot
- 网站日志目录:
/www/wwwlogs
- 宝塔面板日志目录:
/www/server/total/logs
- 回收站目录:
/www/Recycle_bin
清理日志
- 普通网站日志
- 宝塔面板日志
# 网站日志
cd /www/wwwlogs && rm -rf *
# 宝塔面板日志<直接外面删除会出问题>
cd demo.com/ && rm -rf * && cd -
mini alias 基本的命令
# 编辑
vim ~/.bashrc
# reload载入
source ~/.bashrc
# customize by aric.zheng
# cd
alias ..='cd ..';
alias ...='cd ../..';
alias c-='cd -';
# list
alias l="ls -alh";
alias x="exit";
alias reload='source ~/.bashrc';
alias sz='du -hs *';
alias ym="yum";
alias lv="lnav";
alias reload="source ~/.bashrc";
常用基本工具安装
yum install -y vim autojump ncdu lnav htop
几个用于替代 du 命令的更好选择
为什么会有这个需求,因为朋友的站,有个统计跑了10多分钟还没有出结果 。
需求:快一点的统计工具
- ncdu
- dust<rust 开发的,未试用过>
# 安装
yum install -y ncdu
# 使用
ncdu ~/www/wwwroot
面板里的操作工具
- web 日志清理:侧边/安全 http://URL/firewall
- 回收站关闭: 侧边/文件/右上角
systemctl 使用<php: 替换成具体的 service>
- 启动
systemctl start php
- 重启
systemctl restart php
php-fpm-56.service loaded active running LSB: starts php-fpm
php-fpm-70.service loaded active running LSB: starts php-fpm
php-fpm-72.service loaded active running LSB: starts php-fpm
使用 /etc/init.d 来启动
/etc/init.d/php-fpm restart # typical
/etc/init.d/php5-fpm restart # debian-style
/etc/init.d/php7.0-fpm restart # debian-style PHP 7
mysql服务管理
systemctl start mysqld.service
systemctl stop mysqld.service
systemctl restart mysqld.service
mysql 配置文件
宝塔mysql数据库配置文件
my.ini
# 配置文件
/etc/my.cnf
# 慢查询
tail -f /www/server/data/mysql-slow.log
nginx配置相关
# nginx 配置
/www/server/nginx/conf/nginx.conf
# 网站nginx的log
/www/wwwlogs
相关优化
- 把没用的爬虫全都屏蔽掉
server {
# ....
# forbiden crwal & add by aric.zheng
if ($http_user_agent ~ "MegaIndex|MegaIndex.ru|BLEXBot|Qwantify|qwantify|semrush|Semrush|serpstatbot|hubspot|python|Go-http-client|Java|PhantomJS|SemrushBot|Scrapy|Webdup|AcoonBot|AhrefsBot|Ezooms|EdisterBot|EC2LinkFinder|jikespider|Purebot|MJ12bot|WangIDSpider|WBSearchBot|Wotbox|xbfMozilla|Yottaa|YandexBot|Jorgee|SWEBot|spbot|TurnitinBot-Agent|mail.RU|perl|Python|Wget|Xenu|ZmEu|SeznamBot|Curl|HttpClient|Crawler|crawler|Nimbostratus-Bot|MRA58N|LMY47V|^$" ) {
return 410;
}
}
mysql CPU消耗过高问题排查
- 找到 /etc/my.conf 里的慢查询
- 根据慢查询,找到对应的网站,哪个慢先找哪个的问题
- 清空nginx日志,nginx -s reload,重新建立日志
- 查看快速产生日志的文件
- 查出慢的原因,这次的原因是爬虫(直接禁止垃圾爬虫即可解决问题)
安装php
- 软件商店
- 运行环境
![](https://tva1.js.work/large/da432263ly1h0svv8u9vnj21ok0boab8.jpg)
参考
- https://www.ahaoyw.com/article/649.html
- https://www.bt.cn/bbs/thread-23665-1-1.html
- https://ostechnix.com/check-disk-space-usage-linux-using-ncdu/
- https://linux.cn/article-10239-1.html
- https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
- https://serverfault.com/questions/189940/how-do-you-restart-php-fpm
- https://www.cnblogs.com/itsharehome/p/11114588.html
- https://blog.csdn.net/shiyong1949/article/details/72637189