如何使用nginx在Ubuntu 18.04 LT上安装Kanboard

时间:2020-02-23 14:44:41  来源:igfitidea点击:

在这篇文章中,我们将介绍在Ubuntu 18.04 LTS Linux服务器上安装和配置Kanboard的步骤。
Kanboard是一个专注于Kanban方法的项目管理软件。
Kanban是最初由丰田开发的项目管理方法,以更高效。
Kanban旨在可视化工作流程并限制我们正在进行的工作。
它鼓励重点避免多任务处理和快速识别瓶颈。

Kanboard的功能

以下是Kanboard的主要功能:它是一个免费的,开放的源代码,我们可以根据业务活动,根据业务活动,对报告和分析器的本机支持,我们可以拥有多个项目,该项目能够拖放一个易于使用的Web仪表板可以从具有现代化的任何位置访问的,以将功能与插件和集成到其他外部服务扩展

Kanboard依赖项

-Data Store–默认情况下,看板使用SQLite,但您可以将其替换为MySQL/MariaDB或PostgreSQL之类的关系数据库。MySQL>=5.6或MariaDB>=10。对于需要高可用性配置的大型团队,建议使用Mysql/Postgres
-Web服务器:您可以使用Nginx、Apache或Caddy服务器
-PHP>=5.6.0
-需要PHP扩展

可选的PHP扩展

zip 用于从网站安装插件
ldap 仅用于ldap身份验证

在Ubuntu 18.04 LTS上安装Kanboard

以下是在Ubuntu 18.04上安装和配置Kanboard的步骤。
我们将使用MariaDB作为我们的首选数据存储和Nginx Web服务器。

第1步:安装MariaDB数据库服务器

使用以下教程在Ubuntu 18.04上安装MariaDB数据库服务器:

在Ubuntu 18.04和Centos 7上安装MariaDB 10.x

安装完成后,使用用户创建数据库。
首先,将数据库CLI身份登录为root用户。

$mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 39
Server version: 10.3.9-MariaDB-1:10.3.9+maria~bionic-log mariadb.org binary distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

然后运行命令以创建具有所需权限的数据库和用户

CREATE DATABASE kanboard CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;;
GRANT ALL PRIVILEGES ON kanboard.* TO 'kanboard'@'localhost' IDENTIFIED BY 'StrongPassword';
FLUSH PRIVILEGES;
\q

第2步:安装nginx和php

接下来,我们可以安装nginx Web服务器和所需的PHP扩展

sudo apt update
sudo apt install php php-{fpm,mbstring,cli,json,opcache,zip,xml,gd,ldap,mysql,json,sqlite3}
sudo apt-get install nginx

第3步:下载并安装Kanboard

我们有两种选择可下载Kanboard:从稳定的ReleaseFrom GitHub开发分支

要下载Kanboard的特定稳定版本,请检查Kanboard发布页面。
截至本文,最新版本为1.2.5

export VER=1.2.5
wget https://github.com/kanboard/kanboard/archive/v${VER}.tar.gz
tar xvf v${VER}.tar.gz
rm -f v${VER}.tar.gz
sudo mv kanboard-${VER}//var/www/kanboard

要下载开发版本,请使用

sudo git clone https://github.com/kanboard/kanboard.git /var/www/kanboard

创建配置文件

复制Kanboard配置模板。

sudo cp /var/www/kanboard/config.default.php /var/www/kanboard/config.php
sudo vim /var/www/kanboard/config.php

文件 config.php应包含数据库访问值。

//Database driver: sqlite, mysql or postgres (sqlite by default)
define('DB_DRIVER', 'mysql');
//Mysql/Postgres username
define('DB_USERNAME', 'kanboard');
//Mysql/Postgres password
define('DB_PASSWORD', 'StrongPassword');
//Mysql/Postgres hostname
define('DB_HOSTNAME', 'localhost');
//Mysql/Postgres database name
define('DB_NAME', 'kanboard');

Kanboard的这种广泛的配置参考有助于适当的其他功能,如LDAP认证,SMTP设置,Brute-Force Protection,Logging,Secure HTTP标头设置等

设置适当的权限

sudo chown -R www-data:www-data /var/www/kanboard

第4步:配置nginx

创建nginx配置文件 /etc/nginx/conf.d/kanboard.conf具有以下内容

server {
        listen       80;
        #listen       443 ssl;
	#ssl_certificate /etc/nginx/ssl/kanboard.crt;
	#ssl_certificate_key /etc/nginx/ssl/kanboard.key;
        server_name  kanboard.example.com;
        index        index.php;
        root         /var/www/kanboard;
        client_max_body_size 32M;
        location/{
            try_files $uri $uri//index.php$is_args$args;
        }
        location ~ \.php${
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_index index.php;
            include fastcgi_params;
        }
        location ~* ^.+\.(log|sqlite)${
            return 404;
        }
        location ~ /\.ht {
            return 404;
        }
        location ~* ^.+\.(ico|jpg|gif|png|css|js|svg|eot|ttf|woff|woff2|otf)${
            log_not_found off;
            expires 7d;
            etag on;
        }
        gzip on;
        gzip_comp_level 3;
        gzip_disable "msie6";
        gzip_vary on;
        gzip_types
            text/javascript
            application/javascript
            application/json
            text/xml
            application/xml
            application/rss+xml
            text/css
            text/plain;
    }

如果我们希望使用,请取消注释SSL配置行 https

使用Let’s Encrypt SSL

此示例适用于HTTP到HTTPS重定向,Let’s Encrypt SSL证书

# HTTP
server {
	listen 80;
        server_name  kanboard.example.com;
        root         /var/www/kanboard;
	location/{
        	rewrite     ^ https://kanboard.example.com$request_uri? permanent;
    }
}
	
# HTTPS
server {
        listen       443 ssl;
	ssl_certificate /etc/letsencrypt/live/kanboard.example.com/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/kanboard.example.com/privkey.pem;
        server_name  kanboard.example.com;
        index        index.php;
        root         /var/www/kanboard;
        client_max_body_size 32M;
        location/{
            try_files $uri $uri//index.php$is_args$args;
        }
        location ~ \.php${
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_index index.php;
            include fastcgi_params;
        }
        location ~* ^.+\.(log|sqlite)${
            return 404;
        }
        location ~ /\.ht {
            return 404;
        }
        location ~* ^.+\.(ico|jpg|gif|png|css|js|svg|eot|ttf|woff|woff2|otf)${
            log_not_found off;
            expires 7d;
            etag on;
        }
        gzip on;
        gzip_comp_level 3;
        gzip_disable "msie6";
        gzip_vary on;
        gzip_types
            text/javascript
            application/javascript
            application/json
            text/xml
            application/xml
            application/rss+xml
            text/css
            text/plain;
    }

检查配置语法

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

如果返回 OK然后你可以启动nginx服务

sudo systemctl restart nginx
sudo systemctl enable nginx

第5步:访问Kanboard Web UI

通过使用我们喜欢的Web浏览器打开链接http://kanboard.example.com来访问Kanboard Web UI。
代替 kanboard.example.com使用正确的域名。

登录使用:

用户名:管理员密码:admin

你应该像下面那样进入仪表板

重置管理员密码

要安全,通过导航到admin>用户管理> admin来安全地重置管理员密码

通过再次注销和登录来保存和测试。