使⽤可道云kodbox在ubuntu云服务器上搭建⾃⼰的私有云盘(详细教程)
⽬录
前⾔
可道云是⼀个国产的云盘产品,⽤起来还蛮稳定的,还⽀持对象存储、WebDev挂载等等,在此推荐⼀波(可道云记得打钱)。官⽹:
环境:
主机:阿⾥云ecs学⽣机Ubuntu18.04
依赖包:nginx 1.14\php\mariadb\redis
可道云:v1.14
傻⽠式部署
⾯板⽅式
可道云官⽅提供了⼀些⾯板⽅式部署,例如:宝塔⾯板、AppNode,在宝塔⾯板的软件商店⾥可以到并⼀键部署,我的实现⽅式为⾃定义部署,在此就不赘述了。
Docker⽅式
可道云官⽅还提供了Docker的部署,在此推荐使⽤Docker-compose实现其nginx+fpm的部署⽅式,官⽅在其Docker主页⾥也提供了详细教程,也不赘述了。
Docker主页:
⾃定义部署
上述的部署⽅式虽然很简单,但是很多⼈并没有依赖于⾯板,⽽Docker的可扩展性和可操作性不强,官⽅在Docker容器内部署了⼀个nginx,导致可能会与主机环境下的nginx冲突。因此,我最终是在主机环境下⾃定义搭建,教程如下:
1.依赖环境安装
1.1 Nginx
安装Nginx,命令:
sudo apt-get install nginx
验证安装:
nginx -v
成功安装后会显⽰版本号。
1.2 MariaDB
安装MariaDB-server,命令:
sudo apt install mariadb-server
安全⽅式安装,命令:
sudo mysql_secure_installation
随后按照mariadb的提⽰进⾏配置就可以了。
1.3 Redis
不想使⽤Redis做缓存的同学可以跳过这⼀步,不过还是建议使⽤Redis来做缓存,更安全⾼效。
安装Redis,命令:
sudo apt-get install redis-server
验证安装:
ps -aux|grep redis
应该会看到类似如下信息:
redis 5699 0.1 0.1 51452 3728 ? Ssl 12:05 0:00 /usr/bin/redis-server 127.0.0.1:6379
1.4 PHP
建议将php放在最后进⾏安装,防⽌依赖出问题。
安装php及各种插件,命令:
sudo apt-get install php7.2-fpm php7.2-mysql php7.2-curl php7.2-json php7.2-mbstring php7.2-xml php7.2-intl php7.2-gd php7.2-redis 验证安装:
php -v
sudo service php7.2-fpm status
第⼀条命令应该会正确显⽰出php版本7.2,第⼆条命令应该会显⽰php7.2-fpm服务处于active状态。
2.环境配置
2.1 Nginx配置
将/etc/f修改为如下配置:
worker_processes auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid run/nginx.pid;
events {
use epoll;
worker_connections 51200;
multi_accept on;
}
http {
include pes;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 10G;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 720;
php好看主页源码fastcgi_connect_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_read_timeout 3600;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
server_tokens off;
include /etc/nginx/sites-enabled/*;
include /etc/nginx/conf.d/*;
}
#daemon off;
在配置kodbox对应的conf⽂件之前,⾸先要修改⼀下php-fpm配置⽂件/etc/php/7.2/fpm/pool.f:sudo vim /etc/php/7.2/fpm/pool.f
listen = /run/php/php7.2-fpm.sock
修改为
listen = 127.0.0.1:9000
随后在/etc/nginx/sites-enabled下,删除原有的default⽂件,新建⽂件f,并编辑为以下内容,记得注意fastcgi_pass:
server {
listen 80;## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on;## listen for ipv6
root /var/www/html;
index index.php index.html index.htm;
#return 301 $host$request_uri;
# Make site accessible from localhost/
server_name _;
# Disable sendfile as per docs.vagrantup/v2/synced-folders/virtualbox.html
sendfile on;
# Add stdout logging
# error_log /dev/stdout info;
# access_log /dev/stdout;
# Add option for x-forward-for (real ip when behind elb)
#real_ip_header X-Forwarded-For;
#set_real_ip_from 172.16.0.0/12;
# block access to sensitive information about git
location /.git {
deny all;
return 403;
}
# pass the PHP scripts to FastCGI server listening on socket
#
# enable pathinfo
location ~ [^/]\.php(/|$){
try_files $uri=404;
fastcgi_pass 127.0.0.1:9000;#这⾥注意,填写与php-fpm的listen相对应的端⼝
fastcgi_index index.php;
set$path_info$fastcgi_path_info;
set$real_script_name$fastcgi_script_name;
if($fastcgi_script_name ~ "^(.+?\.php)(/.+)$"){
set$real_script_name$1;
set$path_info$2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
include fastcgi_params;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|webp|tiff|ttf|svg)$ {
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
# deny access to . files, for security
#
location ~ /\. {
log_not_found off;
log_not_found off;
deny all;
}
location ^~ /.well-known {
allow all;
auth_basic off;
}
location = /favicon.ico {
log_not_found off;
}
}
重启nginx和php-fpm:
sudo service php7.2-fpm restart
sudo service nginx restart
2.2 数据库配置
使⽤如下命令进⼊mariadb交互界⾯:
sudo mysql
创建⼀个新⽤户admin备⽤:
GRANT ALL PRIVILEGES ON*.*TO'admin'@'localhost' IDENTIFIED BY '填密码'; FLUSH PRIVILEGES;
随后退出数据库,使⽤刚刚创建的⽤户来登录数据库:
mysql -uadmin -p
创建⼀个新数据库⽤于存放云盘数据:
create database kod_box default character set utf8;
2.3 kodbox
今天的主⾓Kodbox,⾸先把它的最新版本压缩包下载下来:
wget static.kodcloud/update/download/kodbox.1.14.zip
sudo cp kodbox.1.14.zip /var/www/html/
cd /var/www/html
unzip kodbox.1.14.zip
将/var/www/html整个⽬录的权限设置为777
cd /var/www
sudo chmod -R 777 html/
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论