Ubuntu 安装KodBox(可道云)

 

 

 安装环境:Ubuntu 18.04  Apache2.4.7 php7.0 Mariadb Rdis Nginx

更新apt-get

sudo apt-get update
sudo apt-get upgrade -y

安装Nginx

sudo apt-get install nginx

验证安装是否成功

nginx -v

安装MariaDB-server

sudo apt install mariadb-server -y

打开数据库服务并设置开机自启

sudo systemctl start mariadb
sudo systemctl enable mariadb

安全方式安装mysql

sudo mysql_secure_installation

安装Redis(选装)

sudo apt-get install redis-server

验证安装

ps -aux|grep redis

安装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

nginx配置

sudo vim /etc/nginx/nginx.conf

全体复制

#user  nobody;
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       mime.types;
    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;
    
    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;

修改php-fpm配置文件

sudo vim /etc/php/7.2/fpm/pool.d/www.conf
将:listen = /run/php/php7.2-fpm.sock
改成:listen = 127.0.0.1:9000

修改nginx配置文件

cd /etc/nginx/sites-enabled

删除原有的default文件,新建文件kodbox.conf,并编辑为以下内容:

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 https://$host$request_uri;
    # Make site accessible from http://localhost/
    server_name _;
    
    # Disable sendfile as per https://docs.vagrantup.com/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; 
            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

Mariadb配置

sudo mysql

如果密码要设置的过于简单则需要修改密码策略

SHOW VARIABLES LIKE 'validate_password%';
set global validate_password_policy=LOW;

设置密码长度

set global validate_password_length=6;

这里就可以填写简单的密码了

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY '填密码';
FLUSH PRIVILEGES;

登录Mariadb,用刚刚创建的用户和密码来登录数据库

mysql -uadmin -p

创建一个新数据库用于存放云盘数据

create database kod_box default character set utf8;

安装KodBox(可以去官网或者别的地方下载,也可以执行以下命令下载解压给权限)

先进如/var/www/html目录将文件下载解压到这里(里面如果有index.html文件要删除

cd /var/www/html

安装解压工具(装过的可以不用装)

sudo apt-get install unzip

下载解压给权限命令

wget https://static.kodcloud.com/update/download/kodbox.1.25.zip
unzip kodbox.1.25.zip && chmod -Rf 777 ./*

访问http://你的域名或IP

 

 

 

 

 

 

posted @ 2021-12-03 03:34  Sakimir  阅读(816)  评论(0)    收藏  举报