df -l
fdisk -l
命令历史dmesg
history
cat /var/log/xxx.log
修改su密码sudo passwd
设置su可以ssh登录vi /etc/ssh/sshd_config
将PermitRootLogin
改为yes
安装xfce4
apt install xfce4 xfce4-goodies
apt install xfce-theme-manager
su命令和su -命令最大的本质区别就是:前者只是切换了root身份,但Shell环境仍然是普通用户的Shell,环境变量没有变;而后者连用户和Shell环境一起切换成root身份了,且环境变量也变成了root用户下的环境变量。su切换成root用户以后,pwd一下,发现工作目录仍然是普通用户的工作目录;而用su -命令切换以后,工作目录变成root的工作目录了。
]]>所以别相信什么路由器鬼东西,还是用热点比较靠谱,问题是……你得有两台手机,嘿嘿
]]>菱形背景
,会员背景图片
,背景图像
等,能找到很酷炫的
]]>Atom Beautify
需要一个php-cs-fixer的插件,brew install php-cs-fixer
的方式安装。但是安装完毕使用的时候也许会有个错误?
比如,我安装完成后对代码进行ctrl+alt+b
就发现代码并没有格式化……
为什么啊?原来是我的PHP代码出现了问题,所以在安装php-cs-fixer之前,还是先安装个linter-php吧,
在Atom
的Install
搜索php
就可以找到该选项了,安装就可以发现自己带代码有没有错误了。
npm install pm2 -g
pm2 --help
pm2 examples
pm2 start bin/www --name name --watch
--watch
是监视文件变化自动reload
重点说说反向代理和跳转HTTPS
UBUNTU系统,所以首先apt install nginx
,然后
进入/etc/nginx/sites-available
里面新建一个网站配置,例如www.xxx.com
,
当然了你也可以复制现有default复制一份出来例如cp default www.xxx.com
然后写入并以下信息
# 服务器的HTTP部分
server {
listen 80;
# 这里我直接做的反向代理,所以不用写根路径在哪
#root /var/www/html;
# 强制从HTTP跳转到HTTPS
rewrite ^(.*)$ https://$host$1 permanent;
# 默认的网页名称
index index.html index.htm index.nginx-debian.html;
# 网址名称
server_name xxx.net www.xxx.net;
location / {
# 这里就是反向代理的实现了,将访问的网址代理到本地NodeJS中
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# 服务器的HTTPS本分
server {
listen 443;
# 默认首页没啥好说的
index index.html index.htm index.nginx-debian.html;
# 你的SSL信息,百度一下全是了
ssl on;
ssl_certificate /etc/nginx/cert/215077960110430.pem;
ssl_certificate_key /etc/nginx/cert/215077960110430.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
# HTTPS也要反向代理哦!
location / {
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
哦了,代码就是这么简单,nginx -t
检查一下配置有没有错,service nginx reload
加载一下,刷新网页查看结果吧!
app.use(function (req, res, next) {
if(req.protocol !== 'https'){
return res.redirect('https://' + req.hostname + req.originalUrl);
}
next();
});
注意上面有个return
可别忘写了,不然报错!
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:470:11)
at ServerResponse.header (/root/taobao/node_modules/express/lib/response.js:767:10)
at ServerResponse.send (/root/taobao/node_modules/express/lib/response.js:170:12)
at done (/root/taobao/node_modules/express/lib/response.js:1004:10)
at tryHandleCache (/root/taobao/node_modules/ejs/lib/ejs.js:257:5)
at View.exports.renderFile [as engine] (/root/taobao/node_modules/ejs/lib/ejs.js:480:10)
at View.render (/root/taobao/node_modules/express/lib/view.js:135:8)
at tryRender (/root/taobao/node_modules/express/lib/application.js:640:10)
at Function.render (/root/taobao/node_modules/express/lib/application.js:592:3)
at ServerResponse.render (/root/taobao/node_modules/express/lib/response.js:1008:7)
加上return
就OK了
复制的方式是Copy->CURL,就可以导入到PostMan里面了,
但是PostMan可能复制出来的代码有问题,
因为我使用的是NodeJS环境,所以我就遇到了乱码这个问题:
var request = require("request");
var options = { method: 'GET',
url: '',
qs: { q: 'ios', code: 'utf-8', area: 'c2c', nick: '', sid: 'null' },
headers:
{ 'cache-control': 'no-cache',
authority: '',
accept: '*/*',
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7,zh-TW;q=0.6',
'accept-encoding': 'gzip, deflate, br'
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
乱码!
怎么办呢?
看似好像没什么问题,但是实际上是乱码的,God fuck my shit……
最后我经历了很久的折磨之后,我其实以为是代码出了问题,其实不是,只是Chrome复制出来的东西,里面含有这个:
'accept-encoding': 'gzip, deflate, br'
哈哈!是不是明白了,GZIP流压缩啊,当然会乱码,后来就明白了。
真正的解决方法是:去掉这行就可以了
'accept-encoding': 'gzip, deflate, br'
OK!
]]>background-image: radial-gradient(circle farthest-side at right,#71c5ff,#ec92fd);
background-image: radial-gradient(circle farthest-side at right,#ffc0c0,#ec92fd);
background-image: radial-gradient(circle farthest-side at right,#cfc,#39c);
background-image: radial-gradient(circle farthest-side at right,#9cc, #69c);
background-image: radial-gradient(circle farthest-side at right,#ccf, #69c);
background-image: radial-gradient(circle farthest-side at right,#ccf, #ccc);
]]><IfModule mod_rewrite.c>
RewriteEngine On
#如果开启了HTTPS服务,使用以下两行内容
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R=301]
#开启伪静态
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
]]><?php $this->content('- 阅读剩余部分 -'); ?>
替换成:
<?php $this->excerpt(300,'- 阅读剩余部分 -'); ?>
300这个数字,你怎么开心,怎么设置。
还有个好方法:
编辑文件
/var/Widget/Abstract/Contents.php
改成这样:
/**
* 输出文章摘要
*
* @access public
* @param integer $length 摘要截取长度
* @param string $trim 摘要后缀
*/
public function excerpt($length = 100, $trim = '...')
{
// Typecho_Common::subStr(strip_tags($this->excerpt), 0, $length, $trim)
echo Typecho_Common::subStr(strip_tags($this->excerpt), 0, $length, $trim) . "<p class=\"more\"><a href=\"{$this->permalink}\" title=\"{$this->title}\">- 阅读剩余部分 -</a></p>";
}
]]>