问题:nginx日志中出现了大量其它网站的网址,请求都返回404
解决:nginx配置文件需要更改
方法:
在nginx的配置文件中加上
if ($host !~ '^it.xiaomantu.com$'){
return 444;
}
出现这种问题的原因是你的服务器被别人用来做代理了,只需要禁止除你的网址其它网址都直接返回错误码,就不会现在在日志中了
问题:nginx日志中出现了大量其它网站的网址,请求都返回404
解决:nginx配置文件需要更改
方法:
在nginx的配置文件中加上
if ($host !~ '^it.xiaomantu.com$'){
return 444;
}
出现这种问题的原因是你的服务器被别人用来做代理了,只需要禁止除你的网址其它网址都直接返回错误码,就不会现在在日志中了
问题:ubuntu终端输入异常,回退变空格
解决:缺少ncurses-base软件,因为安装mysql-workbench时安装了一堆的依赖,安装的依赖中有一个libncursesw5,安装这玩意儿会导致系统默认的ncurses-base被卸载…
方法:
sudo apt install ncurses-base
重启终端
问题:subprocess.popen进程卡死如何解决?
解决:原因是subprocess的PIPE是有大小的。在python2.6.11之前,PIPE的大小为文件页的大小(i386上是4096),2.6.11之后变为65536.因此当输出内容超过65536,会引起阻塞。因为PIPE已经被塞满了,无法再塞进更多的数据。
解决方法是不用subprocess提供的PIPE,或者不要实时输出执行命令后的输出内容。
方法:
obj = subprocess.Popen(cmd,stdout=fileno,stderr=fileno,shell=True)
obj.communicate()
关闭输出内容
from subprocess import DEVNULL, STDOUT, check_call
check_call([cmd, arg1, arg2], stdout=DEVNULL, stderr=STDOUT)
或
with open(os.devnull, 'w') as fp:
cmd = subprocess.Popen(("[command]",), stdout=fp)
问题:使用subprocess.Popen启动进程时,启动了两条进程,如何解决?
解决:添加executable='bash'
方法:
cmd_date = 'python test_01.py'
process = subprocess.Popen(cmd_date, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, executable='bash')
stdout, stderr = process.communicate()
print(stdout, stderr, process.pid)
问题:java提供的sm2公钥无法在python中使用
解决:因为java和python使用的加密方法有差
方法:
package com.bocsoft.security;
import com.bocsoft.decrypt.Util;
import org.bouncycastle.asn1.*;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import static com.bocsoft.decrypt.Util.getHexString;
public class translate {
public static void main(String[] args) throws Exception {
String private_key = "308193020100301306072a8648ce3d020106082a811ccf5501822d0479307702010104205931b7fa3a8ec4e974d48e84b8a64d931c9e7bad295dafe57940573d46481c44a00a06082a811ccf5501822da14403420004798718d3c2152a61ef18ff58adfb83e6694f84ea6c58ce4cfa83f79bb7ff4893d5e6050242cca375a6585f265bd862b448c90af4c61d67620900526f3ebffcaf";
String public_key = "04251ed256cf8ac425443cc444cda5aafbe8aa22a5c5af1f11b2eecff6217bb3299e554c202f5253eee538ff1576bdba729e9a4d338508ba421b6c6330dca2711c";
byte[] sm2_private = privateKey(Util.hexStringToBytes(private_key));
System.out.println("私钥为:"+ Util.encodeHexString(sm2_private));
byte[] publicKey = publicKey(Util.hexStringToBytes(public_key));
System.out.println("公钥为: " + Util.encodeHexString(publicKey));
}