在debian中安装resilio sync

一、添加官方提供给基于debian系的源,创建一个新文件(如/etc/apt/source.list.d/resilio-sync.list),或是直接写进去/etc/apt/source.list:

echo "deb http://linux-packages.resilio.com/resilio-sync/deb resilio-sync non-free" | 
sudo tee /etc/apt/sources.list.d/resilio-sync.list

然后添加公钥:

wget -qO - https://linux-packages.resilio.com/resilio-sync/key.asc | apt-key add -

curl -LO http://linux-packages.resilio.com/resilio-sync/key.asc && apt-key add ./key.asc

二、更新源并安装resilio sync:

apt-get update
apt-get install resilio-sync

三、systemd以当前用户身份启动resilio sync服务:

默认情况下,开启rslsync自启,将会以rslsync用户身份启动,这意味着同步文件的时候,该目录owner需为rslsync用户。

编辑 /usr/lib/systemd/user/resilio-sync.service ,把WantedBy=multi-user.target替换为WantedBy=default.target保存后,执行

systemctl --user enable resilio-sync

Ok,最后如果你想要外界能够通过web管理resilio sync ,需要把resilio sync的监听端口改成0.0.0.0或是特定的外部ip而非127.0.0.1,配置文件位于~/.config/resilio-sync/config.json 内容类似于:

{
    "storage_path" : "/home/ioe/.config/resilio-sync/storage",
    "pid_file" : "/home/ioe/.config/resilio-sync/sync.pid",

    "webui" :
    {
    "listen" :"194.48.62.48:8888"
    }
}

然后启动resilio sync:

systemctl --user start resilio-sync

 

 

linux中查找文件中相同文本

前几天有朋友问到我这问题,说是要对比两个文件中的数据,找出内容一样的。

看了一番,还是在linux下用fgrep最为简单:

fgrep -xf a.txt b.txt 

这样就可以了,若要把内容保存至新文件中:

fgrep -xf a.txt b.txt > c.txt

另grep用可以做到,用法:

grep -F -x -f a.txt b.txt

 

 

在控制台中重置OpenMediaVault webui管理员密码

通过ssh登录在openmediavault所在的服务器上,运行omv-firstaid,选中第三项 Change control panel administrator password,然后输入两次密码即可。还有如果你的账号因多次登录失败,有可能被禁用状态,也可以通过omv-firstaid来重置(reset failed login attemp counter)

Linux中ipv4优先

默认不修改情况下,如linux主机中有ipv6地址, 会优先走ipv6通道,例如debian的源dns解析会默认返回AAAA记录(ipv6),要使用ipv4 连接优先而不必禁用ipv6,需要修改gai.conf配置文件使其生效。

debian系:修改/etc/gai.conf,取消下面这一行的注释

precedence ::ffff:0:0/96  100

redhat系:修改/etc/gai.conf,添加如下内容

label       ::1/128        0
label       ::/0           1
label       2002::/16      2
label       ::/96          3
label       ::ffff:0:0/96  4
precedence  ::1/128        50
precedence  ::/0           40
precedence  2002::/16      30
precedence  ::/96          20
precedence  ::ffff:0:0/96  100

 

Cent os 5 可用的备用源(5.11)

修改/etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/5.11/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://vault.centos.org/5.11/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://vault.centos.org/5.11/extras/$basearch/

gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

 

shell下生成随机字符

openssl :

openssl passwd -stdin < <(echo)

urandom:

10 位的md5 字符串

cat /dev/urandom | head -n 10 | md5sum | head -c 10  

linux uuid:

cat /proc/sys/kernel/random/uuid | cksum | cut -f1 -d " "

date产生随机数:

date +%s%N

Nextcloud issues

The test with getenv(“PATH”) only returns an empty response

修改php-fpm中www.conf,将下面行的内容注释取消,重启php

;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

nextcloud在nginx中的伪静态规则,在站点配置中添加一下内容:

location
~ ^/(data|config|\.ht|db_structure\.xml|README) {
deny all;
}

The “Strict-Transport-Security” HTTP header is not configured to least “15552000” seconds. For enhanced security we recommend enabling HSTS as described in our security tips.

在站点SSL配置文件添加一下内容(apache2: a2enmod headers)

NGINX:

add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";

APACHE:

 Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

 

Something wordpress

php:
/etc/php5/fpm/pool.d/www.conf >>
listen = 127.0.0.1:9000 (#listen = /var/run/php5-fpm.sock)
listen.allowed_clients = 127.0.0.1

Nginx Site Config


location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;

 

# NOTE: You should have “cgi.fix_pathinfo = 0;” in php.ini

# With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

WordPress Rewrite

add content to

location /{
if (!-e $request_filename) {
rewrite (.*) /index.php;
}
}

 

DataBase

CREATE DATABASE wp;

GRANT ALL PRIVILEGES ON wp.* TO "wpuser"@"localhost" IDENTIFIED BY "password";