分类 cmd 下的文章

  • 回退一个版本, 会删除本地最后一个版本(危险操作, 慎用)
git reset HEAD~1 && git reset --hard
  • 如果此刻再次执行git pull后, 会重新下载到最新的状态
  • 查看第N个提交的hash值, 当前值为1
vv=1;
git_hashcode=`git log -n $vv --pretty=format:"%H"`
v2=0;
for line in $git_hashcode
do
    declare -i v2=$v2+1;
    if [ "$v2" -eq "$vv" ]
    then
        echo $line;
    fi
done
  • 代理执行命令
git clone --config http.proxy="http://user:password@agent.com:1234"  https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh

  • 创建ssh公钥和私钥 (最好保存到默认位置, 不然一会儿使用私钥的时候还是从默认位置读取的)
ssh-keygen -m PEM -t rsa -b 4096 -C "website@admin.com"
一路回车就好了
  • 默认公钥和私钥存储于用户家目录 .ssh目录下
[root@localhost .ssh]# pwd
/root/.ssh
[root@localhost .ssh]# ls -la
总用量 28
drwx------. 2 root root    81 7月   7 06:29 .
dr-xr-x---. 7 root root  4096 7月   7 06:20 ..
-rw-------. 1 root root  3243 7月   7 06:29 id_rsa
-rw-r--r--. 1 root root   742 7月   7 06:29 id_rsa.pub
  • 配置代码仓库设置
一般在代码仓库, 设置, 部署公钥 下面

然后就可以愉快的克隆啦


如果是服务端测服正服需要使用一样的发布

拷贝正服的 ~/.ssh/id_rsa,id_rsa.pub 到测服该目录
执行
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
git config --global user.email fabu@qq.com
git config --global user.name fabu
同样的git配置完成

nginx转发请求时出现错误: 6009#0: *1 connect() to 127.0.0.1:9501 failed (13: Permission denied) while connecting to upstream

  • 错误日志
[root@localhost code]# vim + /var/log/nginx/error.log
2020/07/06 21:52:21 [error] 6009#0: *6 no live upstreams while connecting to upstream, client: 192.168.2.80, server: _, request: "GET /https/ HTTP/1.1", upstream: "https://www.baidu.com/", host: "192.168.2.140"
2020/07/06 21:52:29 [crit] 6009#0: *1 connect() to 127.0.0.1:9501 failed (13: Permission denied) while connecting to upstream, client: 192.168.2.80, server: _, request: "GET /report/ HTTP/1.1", upstream: "http://127.0.0.1:9501/report/", host: "192.168.2.140"
  • nginx转发环境
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;

        location /https/ {
            proxy_pass https://www.baidu.com/;
        }

        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location /report/ {
            proxy_pass http://127.0.0.1:9501/;
        }

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }
  • 过的第一个坑
查了很多资料说是权限问题, 于是
vim /etc/nginx/nginx.conf
把其中的 user nginx;  改为 user root; 重启nginx不管用, 然后又改回去了
  • 执行了下面一条命令, nginx都不需要重启, 就正常了, 可以正常访问 /https/ 的转发, 但是 /report/ 转发还是报错了
setsebool -P httpd_can_network_connect 1
  • /report/ 报错内容
2020/07/06 21:54:02 [error] 6009#0: *10 open() "/usr/share/nginx/html/home/msg/data/personalcontent" failed (2: No such file or directory), client: 192.168.2.80, server: _, request: "GET /home/msg/data/personalcontent?num=8&indextype=manht&_req_seqid=3114502296&asyn=1&t=1594086842083&sid=31906_1445_31325_32139_31254_32046_32230_31709_32258_26350 HTTP/1.1", host: "192.168.2.140", referrer: "http://192.168.2.140/https/"
  • 解决过程
把report的配置移动到https的转发配置后面重启nginx就好了

  • 查询端口占用情况
[root@localhost ~]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      894/sshd            
tcp6       0      0 :::80                   :::*                    LISTEN      2105/docker-proxy   
tcp6       0      0 :::22                   :::*                    LISTEN      894/sshd

  • 先执行 (需要执行很久很久)
apt-get update
  • 再执行
apt-get install vim

上面的失败了, 下面的一种方法继续尝试

在Linux里面依次输入下面的命令:1,下载最新的yum-3.2.28.tar.gz并解压

wget http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz
tar xvf yum-3.2.28.tar.gz  
  • 进入目录,运行安装
cd yum-3.2.28 
yummain.py install yum
  • 最后更新系统。
yum check-update
yum update
yum clean all