首页
关于本博客
友情链接
推荐
linux/shell
Search
1
LEDE官方固件安装中文语言包的方法
11,100 阅读
2
LEDE固件踢出弱信号客户端,实现WiFi无缝漫游脚本
9,254 阅读
3
基于CloudFlare API的纯Shell动态DNS(DDNS)脚本
8,240 阅读
4
一次OpenVPN交叉编译笔记
6,775 阅读
5
利用iptables的string模块来屏蔽域名(关键词匹配)
6,221 阅读
study
OpenWrt/LEDE
网络技术
数通
HCNP/CCNP
linux
shell
CentOS
Ubuntu/Debian
php
Linux应用
VPS推荐
洛杉矶VPS
欧洲VPS
搬瓦工
C/C++
虚拟化
IDC
杂项
MySQL
运维笔记
zabbix
seafile
openvpn
QEMU/KVM
windows
html
nginx
互联网应用
IP地址段汇总
登录
Search
标签搜索
nginx
OpenWrt
openvpn
SSH
cloudflare
seafile
iptables
VPS
linux
openssl
ddns
CentOS
Linux启动脚本
seafile网盘
vsftpd
openvpn配置模板
ftp
反向代理
seafile服务器
letsencrypt
自渡
累计撰写
78
篇文章
累计收到
2
条评论
首页
栏目
study
OpenWrt/LEDE
网络技术
数通
HCNP/CCNP
linux
shell
CentOS
Ubuntu/Debian
php
Linux应用
VPS推荐
洛杉矶VPS
欧洲VPS
搬瓦工
C/C++
虚拟化
IDC
杂项
MySQL
运维笔记
zabbix
seafile
openvpn
QEMU/KVM
windows
html
nginx
互联网应用
IP地址段汇总
页面
关于本博客
友情链接
推荐
linux/shell
搜索到
78
篇与
自渡
的结果
2018-11-24
在CentOS7下搭建私有云存储Seafile服务器
关于私有云存储系统,有基于PHP的OwnCloud,NextCloud等等,然而这些基于PHP的网盘系统,它们的运行效率是远远不及底层基于C语言的seafile,并且在上传大文件时,经常会中断。我个人之前一直是使用NextCloud,在发现Seafile之后,我果断抛弃了它,改用Seafile。Seafile社区版产品特性:1、支持端到端加密技术来保证数据的安全。用户可创建加密数据库,密钥不保存在服务器,所有数据在服务器上均是加密,就算有服务器的root权限也无法读取。2、内核是由C语言编写,运行速度快,并且稳定。3、数据在服务器上被分块存储,支持增量同步。4、支持在线预览mp4电影,支持在线编辑txt、Markdown。安装过程介绍:系统环境操作系统:centos7,不要使用CentOS6,因为涉及到glibc的更新,一不小心可能导致系统崩溃。内存要求:最好是1G以上,因为要用到mysql,如果内存过于低,可能导致mysql进程被系统自动杀死。用到的程序:MySQL/MariaDB,Seafile主程序,nginx(可选)。安装MariaDBSeafile的数据库可以用自行编译的MySQL,这里就不再讲编译MySQL的过程,因为在https://www.zavierlab.com/post/49.html都有说明编译过程。在这里直接使用了yum安装MariaDB。yum -y install mariadb mariadb-server安装完毕后,启动mariadb服务器systemctl start mariadb将mariadb加入开机启动项systemctl enable mariadb默认数据库root密码为空,为了安全应该为mariadb服务器设置root密码。系统会提示输入两次密码,密码不会在命令行中显示,输完直接回车即可。mysqladmin -u root password安装Seafile主程序首先安装依赖包yum -y install epel-release yum -y install wget python-imaging MySQL-python python-memcached python-ldap python-urllib3 python2-pip安装pillow和moviepypip install pillow moviepy安装ffmpeg和ffmpeg-develwget http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm rpm -Uvh nux-dextop-release*rpm yum -y install ffmpeg ffmpeg-devel创建seafile工作目录并下载seafile源码和解压mkdir -p /usr/local/seafile wget http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.2.5_x86-64.tar.gz tar -zxvf seafile-server_6.2.5_x86-64.tar.gz解压后目录如下├── ccnet │ ├── ccnet.sock │ ├── misc │ ├── mykey.peer │ └── seafile.ini ├── conf │ ├── ccnet.conf │ ├── seafdav.conf │ ├── seafile.conf │ ├── seahub_settings.py │ └── seahub_settings.pyc ├── logs │ ├── ccnet.log │ ├── controller.log │ ├── seafile.log │ ├── seahub_django_request.log │ └── seahub.log ├── pids │ ├── ccnet.pid │ └── seaf-server.pid ├── seafile-data │ ├── commits │ ├── fs │ ├── httptemp │ ├── library-template │ ├── storage │ └── tmpfiles ├── seafile-server-6.2.5 │ ├── check_init_admin.py │ ├── reset-admin.sh │ ├── runtime │ ├── seaf-fsck.sh │ ├── seaf-fuse.sh │ ├── seaf-gc.sh │ ├── seafile │ ├── seafile.sh │ ├── seahub │ ├── seahub.sh │ ├── setup-seafile-mysql.py │ ├── setup-seafile-mysql.sh │ ├── setup-seafile.sh │ └── upgrade ├── seafile-server-latest -> seafile-server-6.2.5 └── seahub-data └── avatars执行安装脚本,并回答问题cd seafile-server-latest && ./setup-seafile-mysql.sh What is the name of the server? It will be displayed on the client. 3 - 15 letters or digits #自定义服务器名 [ server name ] seafile What is the ip or domain of the server? For example: www.mycompany.com, 192.168.1.101 #可以是你的服务器IP或者你的域名 [ This server's ip or domain ] Where do you want to put your seafile data? Please use a volume with enough free space #数据目录,这里一般保持默认 [ default "/usr/local/seafile/seafile-data" ] Which port do you want to use for the seafile fileserver? #seafile文件服务器监听端口,一般是默认,有冲突自行更改 [ default "8082" ] ------------------------------------------------------- Please choose a way to initialize seafile databases: ------------------------------------------------------- #1是在mariadb里创建seafile新用户和数据库,2是使用已有的数据库,这里使用的是1 [1] Create new ccnet/seafile/seahub databases [2] Use existing ccnet/seafile/seahub databases [ 1 or 2 ] #数据库地址,一般是本地,保持默认 What is the host of mysql server? [ default "localhost" ] #端口号,保持默认 What is the port of mysql server? [ default "3306" ] #输入root密码(不会显示) What is the password of the mysql root user? [ root password ] verifying password of user root ... done #自定义seafile数据库用户,默认用户名是seafile Enter the name for mysql user of seafile. It would be created if not exists. [ default "seafile" ] #为seafile数据库用户设置密码 Enter the password for mysql user "seafile": [ password for seafile ] verifying password of user seafile ... done #以下三项保持默认即可 Enter the database name for ccnet-server: [ default "ccnet-db" ] Enter the database name for seafile-server: [ default "seafile-db" ] Enter the database name for seahub: [ default "seahub-db" ] #到这里数据库都已经创建完毕,确认无误后按ENTER即可开始安装 --------------------------------- This is your configuration --------------------------------- server name: 你的服务器名 server ip/domain: 你的IP或域名 seafile data dir: /usr/local/seafile/seafile-data fileserver port: 8082 database: create new ccnet database: ccnet-db seafile database: seafile-db seahub database: seahub-db database user: seafile --------------------------------- Press ENTER to continue, or Ctrl-C to abort安装完毕后便是启动seafile进程,为了安全,seafile不能以root身份运行,所以应该先在系统里面创建一个名为seafile的普通用户,并以普通用户的身份运行。useradd -s /sbin/nologin seafile启动seafile以及seahub,首次启动会要求创建管理员帐号,根据提示输入即可。cd /usr/local/seafile/seafile-server-latest sudo -u seafile ./seafile.sh start sudo -u seafile ./seahub.sh start如果配置无误,seafile应该已经成功启动,这时,在浏览器上输入IP或者域名加端口号的格式即可访问。http://你的IP地址:8000因为文件服务器seahub和seafile端口号分别为8000,8082用起来不是很方便,所以可以用Nginx反向代理的形式,并且绑定域名,实现单一端口访问网盘。下面附上参考官方给出的Nginx反向代理的配置。server { listen 80; server_name seafile.yourdomain.com; proxy_set_header X-Forwarded-For $remote_addr; location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; proxy_read_timeout 1200s; # used for view/edit office file via Office Online Server client_max_body_size 0; access_log /var/log/nginx/seahub.access.log; error_log /var/log/nginx/seahub.error.log; } location /seafhttp { rewrite ^/seafhttp(.*)$ $1 break; proxy_pass http://127.0.0.1:8082; client_max_body_size 0; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 36000s; proxy_read_timeout 36000s; proxy_send_timeout 36000s; send_timeout 36000s; } location /media { root /usr/local/seafile/seafile-server-latest/seahub; } }前端使用SSL的配置。后端因为是反代本地,因此不需要SSL。server { listen 443; ssl on; ssl_certificate SSL证书目录; ssl_certificate_key SSL密钥; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; server_name seafile.yourdomain.com; proxy_set_header X-Forwarded-For $remote_addr; location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; proxy_read_timeout 1200s; # used for view/edit office file via Office Online Server client_max_body_size 0; access_log /var/log/nginx/seahub.access.log; error_log /var/log/nginx/seahub.error.log; } location /seafhttp { rewrite ^/seafhttp(.*)$ $1 break; proxy_pass http://127.0.0.1:8082; client_max_body_size 0; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 36000s; proxy_read_timeout 36000s; proxy_send_timeout 36000s; send_timeout 36000s; } location /media { root /usr/local/seafile/seafile-server-latest/seahub; } }修改/usr/local/seafile/conf/ccnet.conf:SERVICE_URL = https://seafile.yourdomain.com修改/usr/local/seafile/conf/seahub_settings.py:FILE_SERVER_ROOT = 'https://yourdomain.com/seafhttp
2018年11月24日
4,476 阅读
0 评论
0 点赞
2018-11-22
企业NAS部署(二)之实现用户自助修改密码
搭建好nas后,问题又来了,就是用户密码问题。之前部署NAS,用户密码都是在命令行下导入的,修改密码也只能通过命令行,要让用户使用Linux命令行来修改或者重置密码,那是不可能的。而我唯一能想到的,就是用php写一个web页面,通过表单提交的方式,让php来替用户执行shell命令,达到自助修改密码的目的。PHP代码<?php function replaceSpecialChar($strParam){ $regex = "/\ |\/|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\'|\`|\-|\=|\\\|\|/"; return preg_replace($regex,"",$strParam); } ?> <html> <head> <meta charset="utf-8"> <title>NAS密码自助修改页面</title> </head> <body bgcolor="#CCFFCC"> <br><br> <p><center><h2>NAS密码自助修改</h2></center></p> <form action="changepass.php" method="POST" submit=""><center> <p><span>NAS用户名:</span><input type="text" name="username" placeholder="用户名"></p> <p><span>NAS新密码:</span><input type="password" name="passwd" placeholder="新密码"></p> <p><button>修改</button></p> </center></form> <br><br> <p><h2>操作说明</h2></p> <li>请勿使用特殊字符作为账户名或密码,使用特殊字符将导致密码错误。</li> <li>该系统仅可修改已注册用户的密码,无法添加新用户。</li> <?php $username=$_POST["username"]; $username=replaceSpecialChar($username); $passwd=$_POST["passwd"]; $passwd=replaceSpecialChar($passwd); if (!$_POST["username"]){ echo ""; }elseif (!$_POST["passwd"]){ echo ""; }else{ exec("(sudo echo ".$passwd.";echo ".$passwd.") | sudo smbpasswd -s -a ".$username.""); echo "<br><strong>操作提示:</strong>修改成功,当前用户名".$username."对应的密码已被修改为".$passwd.",请牢记。"; } ?> </body> </html>使用说明要求的环境:php+nginx,关于二者的编译与安装,在本站https://www.zavierlab.com/post/49.html这个页面里已有详细说明,不再重复写。通过编译安装的php,其配置文件在/usr/local/php/etc/php.ini里面,要想使用php执行shell命令,就必须确保配置里面exec函数没有被禁用。查看办法是打开该配置文件,找到disable_function = 这一行(一般在305行),等号后面的函数表示被禁用的函数。该代码内使用到了sudo命令,所以必须给php使用的用户适当的sudo免密码权限,以确保能够正常执行echo和smbpasswd命令。假设php是以www用户身份运行的,则必须给www用户适当的sudo权限,方法是:使用vi在/etc/sudoers.d/下创建一个名为www的文件并编辑vi /etc/sudoers.d/www 加入以下内容 #分别设置echo和smbpasswd命令的别名 Cmnd_Alias CHANGE_SMBPASS = /usr/bin/smbpasswd Cmnd_Alias ECHO = /bin/echo #设置www用户在执行smbpasswd和echo命令时,无需密码 www ALL=(ALL) NOPASSWD:CHANGE_SMBPASS,ECHO 编辑后保存即可生效。接下来还需要用nginx配置web服务器并对php代码进行解析,配置如下:现在/home/wwwroot/下创建一个changenaspwd目录,将该php文件传入目录内,且将该文件命名为index.phpmkdir -p /home/wwwroot/changenaspwd 在/usr/local/nginx/conf/vhost/下创建一个文件,文件名自定义,扩展名必须为.confvi /usr/local/nginx/conf/vhost/changenaspwd.conf配置文件如下:server { listen 80 default; access_log /home/wwwlogs/changenaspwd.log; root /home/wwwroot/changenaspwd; index index.php; location ~ [^/]\.php(/|$) { fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; } }保存后,同时启动php和nginxservice nginx start service php-fpm start
2018年11月22日
1,603 阅读
0 评论
0 点赞
2018-11-22
企业NAS部署(一)之基础配置
最近在帮企业部署内网网络存储(nas)系统,方便不同部门之间通过内网共享文件。Linux下的samba软件,能够很好地代替windows共享来完成该项目。服务器信息操作系统:CentOS 6.10硬盘:128G SSD+1TB HDD安装相关软件使用yum安装sambayum -y install samba在配置NAS之前关闭SELinux以及在iptables放行相关端口,或者关闭iptables,由于在内网,无需防火墙,因此我直接清空了自带的iptables规则setenforce 0 sed -i 's/SELINUX=enforcing/SELINUX=disable/g' /etc/selinux/config iptables -F service iptables saveSamba安装完毕后,默认的配置文件在/etc/samba/smb.conf,所有的共享参数均在此配置。首先是编辑/etc/samba/smb.conf,通过nano或者vi和WinSCP皆可,先编辑[global]全局选项[global] workgroup = WORKGROUP #工作组名,win下默认是WORKGROUP server string = Samba Server For Linux #自定义字符串,用于描述服务器 log file = /var/log/samba/log.%m #生成日志 max log size = 50 #指定日志大小 security = user #安全级别,这里表示所有用户均需要通过验证才可访问 passdb backend = smbpasswd #密码认证方式,有多种选项,这里选择smbpasswd方便后期员工自助修改密码 smb passwd file = /etc/samba/smbpasswd #这里指定了账户密码的存放文件路径 max connections = 0 #0表示无限制连接,也可手动指定一个数值来限制连接数 load printers = no #加载打印机共享,这里不设定打印机全局选项配置完毕后,就可以开始配置共享目录了,首先创建一个目录,专门用于存放NAS文件mkdir -p /media/samba编辑配置文件smb.conf中的文件夹选项,另起一行,示例如下#客户端看到的文件夹名称 [部门1] #该共享文件夹在服务器中对应的真实目录 path = /media/samba/部门1 #对该共享具有读取权限的用户 valid users = user1 user2 user3... #用户创建的文件和目录的默认权限 create mask = 0755 directory mask = 0755 #在首页是否隐藏,yes为不隐藏,no为隐藏 browseable = yes #对该共享具有写入权限的用户 write list = user1 user2 user3... #对该共享具有完全控制权限的用户 admin users = user1 user2 user3... #是否允许访客访问,yes为允许,no为禁止 guest ok = no [部门2] path = /media/samba/部门2 valid users = user1 user2 user3... create mask = 0755 directory mask = 0755 browseable = yes write list = user1 user2 user3... admin users = user1 user2 user3... guest ok = no #可根据实际需求,在配置内继续添加其他共享 ...创建真实目录mkdir -p /media/samba/部门1 mkdir -p /media/samba/部门2因为samba用户认证是使用本地用户名+smb独立密码的形式来认证,即用户名必须在系统内存在,所以我创建了一个名为smbuser的组,然后将公司员工的账号批量导入。在设置NAS密码时,使用的是smbpasswd,smbpasswd是一个交互式命令,其使用方法如下:smbpasswd -a 用户名 New password:(输入密码,密码不会显示在此处)因为这是一个交互式命令,所以给批量设置默认密码带来了许多麻烦,而幸好有expect命令来解决这个交互的问题。批量导入方法如下:安装expectyum -y install expect写一个批量导入脚本#!/usr/bin/expect spawn smbpasswd -a 用户1 expect "*password:" send "用户1的密码\r" expect "*password:" send "用户1的密码\r" interact spawn smbpasswd -a 用户2 expect "*password:" send "用户2的密码\r" expect "*password:" send "用户2的密码\r" interact ...然后赋予脚本执行权限并且执行就行了chmod +x 脚本名 ./脚本名配置基本已经完成了,接下去便是启动smb服务器service smb start将smb加入开机启动项chkconfig smb on
2018年11月22日
2,211 阅读
0 评论
0 点赞
2018-11-03
在Linux下安装MySQL后为root账户设置密码
安装完mysql后,root账户默认为空密码,常用的方法是使用mysqladmin命令来设置新密码。使用编译安装时,应该做软连接将mysqladmin加入/bin/目录下。ln -s /usr/local/mysql/bin/mysqladmin /bin/mysqladmin使用mysqladmin命令。mysqladmin -u root password "新密码"或者以下命令直接回车,系统会提示输入新密码,密码不会在命令行中显示,输入两次即可。mysqladmin -u root password
2018年11月03日
1,285 阅读
0 评论
0 点赞
2018-11-03
OpenVPN的配置模板(二)之点对点模式
其实OpenVPN早期的版本仅有点对点模式,即仅有单一的客户端和服务器,官方称之为office模式。而一对多的服务器模式是在后续版本中才有的。在该模式下客户端与服务器采用静态密钥或者TLS密钥来验证彼此的身份,不使用证书的方式。此文主要整理了点对点模式的配置模板。生成静态密钥的命令是openvpn --genkey --secret /etc/openvpn/static.key服务端配置(使用静态密钥)#配置通讯协议以及标注服务器端 proto tcp-server #使用tun/tap设备,默认是tun dev tun #通讯端口 port 1194 #定义本地IP为10.8.0.1,对端(即客户端)IP为10.8.0.2 ifconfig 10.8.0.1 10.8.0.2 #配置连接建立后要执行的脚本,如添加路由等,默认不使用 ;up /etc/openvpn/office.up #静态密钥的路径 secret /etc/openvpn/static.key #加密算法 cipher AES-128-CBC #使用LZO压缩 comp-lzo adaptive #告知客户端使用LZO压缩 push "comp-lzo adaptive" #此选项使VPN在重连时不重新读取key且不会将tun设备关闭 persist-tun persist-key #配置日志级别 verb 4 #10秒钟ping一次对端以确定对方是否在线,60秒未响应则断开连接 keepalive 10 60 #将OpenVPN以openvpn用户和组的身份运行,提高安全性 user openvpn group openvpn #生成日志路径 log /var/log/openvpn.log log-append /var/log/openvpn.log客户端配置#配置协议 proto tcp-client dev tun port 1194 #服务器IP地址 remote x.x.x.x #在服务器中断后自动连接 resolv-retry infinite nobind #客户端本地IP为10.8.0.2,服务端IP为10.8.0.1 ifconfig 10.8.0.2 10.8.0.1 #静态密钥存放地址 secret /etc/openvpn/static.key cipher AES-128-CBC comp-lzo adaptive persist-tun persist-key verb 3 keepalive 10 60
2018年11月03日
4,835 阅读
0 评论
0 点赞
1
...
7
8
9
...
16