About

☑阅读控 ☑80后 ☑看电影 ☑打篮球
#java #jquery #ubuntu #wordpress #php #mysql
我就是希望她能回到我小时候那样子——上下学自己去,走几条马路就到学校,遇见陌生人也不害怕,不用家长去接,路上没那么多汽车,汽车知道避让行人,不用给老师送礼拍马屁,就这么简单。

蜘蛛网间

蜘蛛网与您分享网络间的爬行轨迹

Ubuntu 下安装配置 rsync

07/31/2020
  • 启用rsync
royakon@localhost~: sudo vim /etc/default/rsync
...
RSYNC_ENABLE=true # fals改为true
  • Server 端配置
# | - /etc/rsyncd.conf
# | - /etc/rsyncd
#            | - rsyncd.secrets
#            | - rsyncd.motd

royakon@localhost~: mkdir /etc/rsyncd
royakon@localhost~: touch /etc/rsyncd/rsyncd.secrets
royakon@localhost~: touch /etc/rsyncd/rsyncd.motd
royakon@localhost~: sudo chmod 600 /etc/rsyncd/rsyncd.secrets

royakon@localhost~: sudo vim /etc/rsyncd.conf

...
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
port=873
syslog facility = local3
...
[site-backup]
    comment                =    www.magth.cn site backup
    path                =    /home/magth/backup
    userchroot            =    yes
    max Connections        =    10
    motd file            =    /etc/rsyncd/rsyncd.motd

    lock file            =    /var/lock/rsyncd    
    #centos /var/run/rsync.lock

    read only            =    yes
    list                 =    yes
    uid                    =    root
    gid                    =    root
    exclude                =    error_log    httpd.pid
    auth users            =    magth
    secrets file        =    /etc/rsyncd/rsyncd.secrets
    strict modes        =    yes
    ignore errors        =    yes
    ignore nonreadable    =    yes
    transfer logging    =    yes
    log format            =    %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
    timeout                =    600
    refuse options        =    checksum dry-run
    dont compress        =    *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz
...


royakon@localhost~: sudo vim /etc/rsyncd/rsyncd.secrets

magth:Admin@20o20


royakon@localhost~: sudo vim /etc/rsyncd/rsyncd.motd

++++++++++++++++++++++++++++++++
+ www.magth.cn rsync 2020-2030 +
++++++++++++++++++++++++++++++++



royakon@localhost~: sudo vim /etc/services

...
rsync    873/tcp    #rsync
rsync 873/udp    #rsync
...


royakon@localhost~: sudo vim /etc/xinetd.d/rsync

service rsync
{
    disable         = no
    socket_type     = stream
    wait            = no
    user            = root
    server          = /usr/bin/rsync
    server_args     = --daemon --config=/etc/rsyncd.conf
    log_on_failure  += USERID
}



royakon@localhost~: sudo service xinetd restart
royakon@localhost~: sudo /etc/init.d/rsync start
  • Client 配置
royakon@localhost~: mkdir /etc/rsyncd
royakon@localhost~: touch /etc/rsyncd/rsyncd.secrets

Admin@20o20


# Test 
royakon@localhost~: sudo rsync -vzrtopg --delete --progress  --password-file=/etc/rsyncd/rsyncd.secrets --port=873 magth@www.magth.cn::site-backup /home/magth/backup/site
  • 同步脚本
royakon@localhost~: vim /home/magth/backup/script/site-rsync.sh

#!/bin/sh
sudo rsync -vzrtopg --delete  --password-file=/etc/rsyncd/rsyncd.secrets --port=873 magth@www.magth.cn::site-backup /home/magth/backup/site

royakon@localhost~: chmod +x site-rsync.sh
  • 定时任务
royakon@localhost~: crontab -e

25        21        *        *        *        /home/magth/backup/script/site-rsync.sh  

Ubuntu Server 命令行配置 Shadowsocks 全局代理

07/30/2020

由于Ubuntu Server是不带用户界面的,所以要为Server配置Shadowsocks还是稍显麻烦。本文就是我配置Shadowsocks的一些经验,以待参考。

安装 Shadowsocks

由于shadowsocks是基于python开发的,所以必须安装python:

royakon@royakon-storage:~$ apt-get install python

接着安装python的包管理器pip:(由于Ubuntu Server 20.04 lts 默认为python3)

royakon@royakon-storage:~$ sudo apt-get install python3-pip

通过pip3直接安装 Shadowsocks

royakon@royakon-storage:~$ sudo pip3 install shadowsocks

配置 Shadowsocks

新建配置文件

royakon@royakon-storage:~$ mkdir shadowsocks
royakon@royakon-storage:~$ touch ./shadowsocks/ss.json
royakon@royakon-storage:~$ vim ./shadowscoks/ss.json
{
  "server": "{your-server}",
  "server_port": 40002,
  "local_port": 1080,
  "password": "{your-password}",
  "timeout": 600,
  "method": "aes-256-cfb"
}

启动Shadowsocks

royakon@royakon-storage:~$ sudo sslcoal -c ./shadowsocks/ss.json -d start

Shadowsocks启动报错undefined symbol: EVP_CIPHER_CTX_cleanup

royakon@royakon-storage:~$ sudo sslcoal -c ./shadowsocks/ss.json -d start
AttributeError: /usr/local/ssl/lib/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup
shadowsocks start failed

修改Shadowsocks内的openssl.py文件

royakon@royakon-storage:~$ sudo vim /usr/local/lib/python3.8/dist-packages/shadowscoks/crypto/openssl.py
# 修改libcrypto.EVP_CIPHER_CTX_cleanup.argtypes,注意以下为 VIM命令
:%s/cleanup/reset/
:x

由于 Shadowsocks 为 Sock5 代理,并不能直接用于系统全局及命令行,配合Privoxy将sock5代理映射为http代理

安装Privoxy

安装

royakon@royakon-storage:~$ sudo apt-get install privoxy

配置

royakon@royakon-storage:~$ sudo vim /etc/privoxy/config
listen-address 127.0.0.1:8118
forward-socks5 / 127.0.0.1:1080  .   #此处端口号与Shadowsocks配置文件内local_port一致

重启服务

royakon@royakon-storage:~$ sudo service privoxy restart

配置全局代理

配置命令行全局代理及测试

royakon@royakon-storage:~$ export http_proxy='http://127.0.0.1:8118'
royakon@royakon-storage:~$ export https_proxy='http://127.0.0.1:8118'
royakon@royakon-storage:~$ curl -v https://www.google.com

Centos系统调整LVM卷/home分区到/分区

07/29/2020

目标:将VolGroup-lv_home缩小到20G,并将剩余的空间添加给VolGroup-lv_root

  • 首先查看磁盘使用情况
[root@localhost ~]# df -h
文件系统 容量  已用 可用  已用% 挂载点
Filesystem              Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 154G  7.9G  139G   6% /
tmpfs                  1.9G  100K  1.9G   1% /dev/shm
/dev/sda1              485M   69M  391M  15% /boot
/dev/mapper/VolGroup-lv_home 299G  984M  283G   1% /home
  • 卸载 /home
[root@localhost ~]# umount /home
umount /home 如果提示无法卸载,则是有进程占用/home,使用如下命令来终止占用进程:
[root@localhost ~]# fuser -m /home
  • 调整分区大小
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 20G
如果提示运行“e2fsck -f /dev/mapper/VolGroup-lv_home”,则执行相关命令:
[root@localhost ~]# e2fsck -f /dev/mapper/VolGroup-lv_home 然后重新执行命令:
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 20G
注:resize2fs 为重新设定磁盘大小,只是重新指定一下大小,并不对结果有影响,需要下面lvreduce的配合
  • 挂载 /home ,查看磁盘使用情况
[root@localhost ~]# mount /home
[root@localhost ~]# df -h
  • 设置空闲空间

使用lvreduce指令用于减少LVM逻辑卷占用的空间大小。可能会删除逻辑卷上已有的数据,所以在操作前必须进行确认。记得输入 “y”

[root@localhost ~]# lvreduce -L 20G /dev/mapper/VolGroup-lv_home
注:lvreduce -L 20G的意思为设置当前文件系统为20G,如果lvreduce -l 20G是指从当前文件系统上减少20G
使用lvreduce减小逻辑卷的大小。注意:减小后的大小不能小于文件的大小,否则会丢失数据。
可以使用vgdisplay命令等查看一下可以操作的大小。也可以是用fdisk -l命令查看详细信息。
[root@localhost ~]# vgdisplay
注:vgdisplay为显示LVM卷组的元数据信息
  • 把闲置空间挂在到根目录下
[root@localhost ~]# lvextend -L +283G /dev/mapper/VolGroup-lv_root
注:lvextend -L +283G为在文件系统上增加283G
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_root
  • 检查调整结果
[root@localhost ~]# df -h

Outlook2013 迁移OST存储位置

07/28/2020

在Outlook2013 IMAP账户中,假设你目前的demo.pst文件在路径C:\Users\%username%\AppData\Local\Microsoft\Outlook下(已创建)

  • 关闭Outlook,移动此文件到D:\Outlook Files下。
  • 打开CMD,键入
mklink "C:\Users\%username%\AppData\Local\Microsoft\Outlook\XXXX.com.ost" "E:\Profile\Outlook\XXXX.com.ost"
  • 此时C:\Users\%username%\AppData\Local\Microsoft\Outlook下会有一个类似于快捷方式的同步文件demo.ost存在(0KB)。
  • 打开Outlook,IMAP账户仍然会挂接到C:\Users\%username%\AppData\Local\Microsoft\Outlook\demo.ost上,但该文件只是D盘下数据文件的映射,实际不消耗任何磁盘空间。

Nginx SSL服务器证书安装

07/28/2020

由 SSL 证书管理控制台 下载已经申请的 www.track2web.com 证书并且上传证书文件到服务器

royakon@bongon~: scp www.track2web.com.zip royakon@track2web.com:/home/royakon/
royakon@track2web.com's password:
www.track2web.com.zip                    100%   19KB  40.6KB/s   00:00

解压缩,并拷贝 Nginx 目录下的 证书文件、私钥文件到 Nginx 安装目录

royakon@iZj6cgtta7qckqs3t2vx67Z:~/tmp$ unzip www.track2web.com.zip
Archive:  www.track2web.com.zip
  inflating: www.track2web.com.csr
   creating: Nginx/
  inflating: Nginx/1_www.track2web.com_bundle.crt
  inflating: Nginx/2_www.track2web.com.key
   creating: Apache/
  inflating: Apache/1_root_bundle.crt
  inflating: Apache/2_www.track2web.com.crt
  inflating: Apache/3_www.track2web.com.key
   creating: IIS/
  inflating: IIS/www.track2web.com.pfx
  inflating: IIS/keystorePass.txt
   creating: Tomcat/
  inflating: Tomcat/www.track2web.com.jks
  inflating: Tomcat/keystorePass.txt
royakon@iZj6cgtta7qckqs3t2vx67Z:~/tmp$ ls
Apache  IIS  Nginx  Tomcat  www.track2web.com.csr  www.track2web.com.zip
royakon@iZj6cgtta7qckqs3t2vx67Z:~/tmp$ sudo mv ./Nginx/*.* /etc/nginx/conf.d/11
royakon@iZj6cgtta7qckqs3t2vx67Z:~/tmp$ ls /etc/nginx/conf.d
1_www.track2web.com_bundle.crt  2_www.track2web.com.key

编辑配置文件增加证书

# http访问 301 跳转到 https
server {
    listen 80;
    server_name www.track2web.com track2web.com;
    return 301 https://$host$request_uri;
}
# https 配置
server {
    # 端口配置
    listen 443 ssl;
    root /home/royakon/public_html;
    server_name www.track2web.com track2web.com;
    if ($host != 'www.track2web.com'){
        rewrite ^/(.*)$ https://www.track2web.com/$1 permanent;
    }
    # SSL 配置
    ssl_certificate conf.d/1_www.track2web.com_bundle.crt;
    ssl_certificate_key conf.d/2_www.track2web.com.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;


    location / {
        if (-f $request_filename/index.html) {
            rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename/index.php) {
            rewrite (.*) $1/index.php;
        }
        if (!-f $request_filename) {
            rewrite (.*) /index.php;
        }
        try_files $uri $uri/ =404;
    }


    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    }
}

验证配置文件,重启 Nginx 生效

royakon@iZj6cgtta7qckqs3t2vx67Z~: sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
royakon@iZj6cgtta7qckqs3t2vx67Z~: sudo service nginx restart
Older Posts