搭建了一个API服务,api.yii2-sns.com,配置nginx如下:
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
学习笔记
搭建了一个API服务,api.yii2-sns.com,配置nginx如下:
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
根据系统输出,根目录/所在的/dev/vda1分区已被占满,仅剩 13.80MB 空间。这会导致系统无法创建新文件、运行程序或更新,需要立即清理。以下是快速排查和清理的步骤:
1. 查找大文件和目录
使用以下命令找出占用空间最大的文件和目录:
TypeScript取消自动换行复制
# 查找根目录下占用空间最大的前10个文件和目录(深度为1)
sudo du -hxd 1 / | sort -hr | head -n 10
# 查找大于1GB的文件
sudo find / -type f -size +1G -exec du -sh {} \; 2>/dev/null
重点检查:
2. 清理日志文件
TypeScript取消自动换行复制
# 查看日志文件大小
sudo du -sh /var/log/*
# 安全清理(保留最新日志,清空历史内容)
sudo truncate -s 0 /var/log/syslog
sudo truncate -s 0 /var/log/nginx/access.log # 按需修改
# 或者直接删除(谨慎操作!)
sudo rm /var/log/old_log_file.log
3. 清理系统缓存
TypeScript取消自动换行复制
# 清理yum缓存(CentOS/RHEL)
sudo yum clean all
# 清理apt缓存(Ubuntu/Debian)
sudo apt-get clean
sudo apt-get autoclean
# 清理Docker缓存(如果安装了Docker)
sudo docker system prune -a –volumes
4. 清理临时文件
TypeScript取消自动换行复制
# 清理/tmp目录(确保无重要文件)
sudo rm -rf /tmp/*
# 清理系统临时文件(如30天未使用的文件)
sudo find /var/tmp -type f -atime +30 -delete
5. 卸载无用软件
TypeScript取消自动换行复制
# 查看已安装软件占用空间(CentOS/RHEL)
yum list installed | awk ‘{print $1}’ | xargs yum info | grep -E “Name|Size”
# 卸载无用软件(示例:卸载apache2)
sudo yum remove httpd # CentOS/RHEL
sudo apt-get purge apache2 # Ubuntu/Debian
6. 释放 inode 空间(如果 inode 使用率高)
TypeScript取消自动换行复制
# 检查inode使用率
df -i
# 查找包含大量小文件的目录
sudo find / -xdev -type d -print0 | xargs -0 du -s | sort -n | tail -n 10
如果 inode 已满,需删除大量小文件(如日志碎片、缓存文件)。
7. 临时扩容(如果无法立即清理)
如果清理后空间仍不足,可以考虑:
注意事项
如果问题持续存在,可能需要进一步分析磁盘使用模式或考虑扩容根分区。
Yii2 高级模板中自带 frontend 和 backend 应用程序,如果要添加其它应用程序,比如 api
步骤如下:
return [
'Development' => [
'path' => 'dev',
'setWritable' => [
'backend/runtime',
'backend/web/assets',
'frontend/runtime',
'frontend/web/assets',
'api/runtime',
'api/web/assets',
],
'setExecutable' => [
'yii',
'yii_test',
],
'setCookieValidationKey' => [
'backend/config/main-local.php',
'frontend/config/main-local.php',
'api/config/main-local.php',
],
],
'Production' => [
'path' => 'prod',
'setWritable' => [
'backend/runtime',
'backend/web/assets',
'frontend/runtime',
'frontend/web/assets',
'api/runtime',
'api/web/assets',
],
'setExecutable' => [
'yii',
],
'setCookieValidationKey' => [
'backend/config/main-local.php',
'frontend/config/main-local.php',
'api/config/main-local.php',
],
],];
Yii::setAlias('@api', dirname(dirname(__DIR__)) . '/api');
'controllerNamespace' => 'api\controllers',
$e^x=lnx+1$是一个方程
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>在指定div中浏览PDF</title>
<!--在此引入bootstrap只为初始化样式div样式-->
<link rel="stylesheet" href="css/bootstrap.min.css" />
<style>
/* 添加样式是为了实现全屏效果 */
html,body{
height: 100%;
overflow: hidden;
}
#example1{
height: 100%;
}
.pdfobject-container{
/* height: 500px; */
}
.pdfobject{
/* border: 1px solid #666; */
}
</style>
</head>
<body>
<div id="example1"></div>
<script type="text/javascript" src="js/pdfobject.min.js"></script>
<script>
// 我的pdf文件放在项目的pdf文件夹下,名字叫做Java.pdf,指定PDF从20页开始阅读
PDFObject.embed("pdf/Java.pdf", "#example1", {page: "20"});
</script>
</body>
</html>
How to embed a PDF without using JavaScript
方式一:
<embed src="/pdf/sample-3pp.pdf#page=2" type="application/pdf" width="100%" height="100%" />
方式二:
<iframe src="/pdf/sample-3pp.pdf#page=2" width="100%" height="100%">
</iframe>
方式三:
<object data="/pdf/sample-3pp.pdf#page=2" type="application/pdf" width="100%" height="100%">
<b>Example fallback content</b>: This browser does not support PDFs. Please download the PDF to view it:
<a href="/pdf/sample-3pp.pdf">Download PDF</a>.
</object>
方式四:
<object data="/pdf/sample-3pp.pdf#page=2" type="application/pdf" width="100%" height="100%">
<iframe src="/pdf/sample-3pp.pdf#page=2" width="100%" height="100%" style="border: none;">
This browser does not support PDFs. Please download the PDF to view it:
<a href="/pdf/sample-3pp.pdf">Download PDF</a>
</iframe>
</object>
层次看鞋子,卫生看指甲
人品看眼神,自律看身材
格局看买单,家教看坐姿
性格看笑声,脾气看语气
境界看表情,态度看嘴角
pycharm激活码最新提取方式:www.ajihuo.com
(如果不好用了可以到www.ajihuo.com中提取)
1、数据准备 建表
drop table if exists score; create table score( id int not null primary key auto_increment, score decimal(10,2) not null );
插入数据
insert into score (score) values (89.4); insert into score (score) values (82.5); insert into score (score) values (65); insert into score (score) values (98); insert into score (score) values (92); insert into score (score) values (34); insert into score (score) values (59); insert into score (score) values (83); insert into score (score) values (88); insert into score (score) values (63); insert into score (score) values (100); insert into score (score) values (96); insert into score (score) values (68); insert into score (score) values (56);
注意:计算标准差最少需要两个值
2、计算正态分布
计算方法是:平均分-标准差(四个值:μ-2σ,μ-σ,μ+σ,μ+2σ)
select round(score_avg - score_bzc * 2, 2) zt1, round(score_avg - score_bzc, 2) zt2, round(score_avg + score_bzc, 2) zt3, round(score_avg + score_bzc * 2, 2) zt4 from (select avg(score) score_avg, stddev_samp(score) score_bzc from score where id in (1, 2)) as a;
3、计算差异系数
计算方法是:标准差/平均分(σ/μ)
select round(score_bzc/score_avg,2) cyxs from (select avg(score) score_avg, stddev_samp(score) score_bzc from score where id in (1,2)) as a;
4、计算离均差
计算方法是:单个值-平均值(x-μ)
select round(score - (avg(score) over ()), 2) ljc from score where id in (1, 2);
5、计算离均差率
计算方法是:离均差/平均值((x-μ)/μ)
select round((score - (avg(score) over ())) / (avg(score) over ()), 2) ljcl from score where id in (1, 2);
如下题匹配选项:
(1) 设集合 $A=[-1,2], B=\left{y \mid y=x^{2}, x \in A\right}$, 则 $A\cap B=$
A. $[1,4]$
B. $[1,2]$
C. $[-1,0]$
D. $[0,2]$
直接上代码:
function getOption(str,from,to)
{
var r = 'var reg = /[\(]*'+from+'[:|:|、|.]{1}(.*?)[\s]?'+ to +'/';
// console.log(r);
eval(r);
var arr = str.match(reg);
console.log(arr);
return arr[1].replace('<br/>','').replace('</p><p style=\"white-space: normal;\">','');
//return str.match(reg)[1];
}
格式化数据:
function formatContent(content)
{
content = content.replace('\(A\)','A.').replace('\(B\)','B.').replace('\(C\)','C.').replace('\(D\)','D.').replace('\(E\)','E.').replace('\(F\)','F.');
content = content.replace('<br/>','');
content = content.replace('<br>','');
content = content.replace('</p><p>');
content = content.replace('<x','\\lt x');
return content;
}
设置选项:
function setChoiceItem()
{
var list =['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q'];
var ue = UE.geEditor('question-content');
var content = formatContent(ue.getContent());
console.log(content);
var str = content;
//console.log(getOption(str,'A','B'));
//console.log(getOption(str,'B','C'));
//console.log(getOption(str,'C','D'));
//console.log(getOption(str,'D','$'));
//$('p.optionContent:eq(0)').html(getOption(content,'A','B'));
//$('p.optionContent:eq(1)').html(getOption(content,'B','C'));
//$('p.optionContent:eq(2)').html(getOption(content,'C','D'));
//$('p.optionContent:eq(3)').html(getOption(content,'D','$'));
var len = $('p.optionContent').length;
$('p.optionContent').each(function(index,e){
console.log(list[index]);console.log(len);
var start = list[index];
var end = list[index+1];
if(index == len-1)
{
end='$';
}
$(this).html(getOption(content,start,end));
});
}