如何在FreeBSD 12上安装InvoicePlane

注:本教程在Vultr VPS上测试通过,如需部署请前往Vultr.com

发票平面 是一个免费的开源发票应用程序。其源代码可以在此找到 Github仓库。本指南将向您展示如何在新的FreeBSD 12 Vultr实例上安装InvoicePlane。

要求

Nginx的
MySQL 5.5或更高版本或等效的MariaDB
PHP 7.0或更高版本
必须安装并激活以下PHP扩展:

php-gd
php-hash
php-json
php-mbstring
php-mcrypt
php-mysqli
php-openssl
php-recode
php-xmlrpc
php-zlib

在你开始之前

检查FreeBSD版本。

uname -ro
# FreeBSD 12.0-RELEASE

确保您的FreeBSD系统是最新的。

freebsd-update fetch install
pkg update && pkg upgrade -y

安装必要的软件包。

pkg install -y sudo vim unzip curl wget bash socat git

使用您的首选用户名创建一个新的用户帐户。我们将使用 johndoe

adduser

# Username: johndoe
# Full name: John Doe
# Uid (Leave empty for default): 
# Login group [johndoe]: 
# Login group is johndoe. Invite johndoe into other groups? []: wheel
# Login class [default]: 
# Shell (sh csh tcsh nologin) [sh]: bash
# Home directory [/home/johndoe]: 
# Home directory permissions (Leave empty for default): 
# Use password-based authentication? [yes]: 
# Use an empty password? (yes/no) [no]: 
# Use a random password? (yes/no) [no]: 
# Enter password: your_secure_password
# Enter password again: your_secure_password
# Lock out the account after creation? [no]: 
# OK? (yes/no): yes
# Add another user? (yes/no): no
# Goodbye!

跑过 visudo 命令并取消注释 %wheel ALL=(ALL) ALL 行,以允许成员 wheel 组以执行任何命令。

visudo

# Uncomment by removing hash (#) sign
# %wheel ALL=(ALL) ALL

现在,使用以下命令切换到新创建的用户 su

su - johndoe

注意: 更换 johndoe 使用您的用户名。

设置时区。

sudo tzsetup

安装PHP和必需的PHP扩展

安装PHP以及必要的PHP扩展。

sudo pkg install -y php72 php72-mbstring php72-tokenizer php72-pdo php72-pdo_mysql php72-openssl php72-hash php72-json php72-phar php72-filter php72-zlib php72-dom php72-xml php72-xmlwriter php72-xmlreader php72-pecl-imagick php72-curl php72-session php72-ctype php72-iconv php72-gd php72-simplexml php72-zip php72-filter php72-tokenizer php72-calendar php72-fileinfo php72-intl php72-phar php72-soap php72-xmlrpc php72-opcache php72-mysqli php72-bcmath php72-gmp

检查版本。

php --version

# PHP 7.2.19 (cli) (built: Jun 20 2019 01:25:01) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

软链接 php.ini-productionphp.ini

sudo ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini

启用并启动PHP-FPM。

sudo sysrc php_fpm_enable=yes
sudo service php-fpm start

安装MariaDB

安装MariaDB。

sudo pkg install -y mariadb102-client mariadb102-server

检查版本。

mysql --version
# mysql  Ver 15.1 Distrib 10.2.24-MariaDB, for FreeBSD12.0 (amd64) using readline 5.1

启动并启用MariaDB。

sudo sysrc mysql_enable="yes" 
sudo service mysql-server start

跑过 mysql_secure_installation 脚本来提高您的MariaDB安装的安全性。

sudo mysql_secure_installation

以root用户身份登录MariaDB。

mysql -u root -p
# Enter password:

创建一个新的MariaDB数据库和用户。记住该新用户的凭据。

CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;

安装Nginx

安装Nginx。

sudo pkg install -y nginx

检查版本。

nginx -v
# nginx version: nginx/1.16.0

启用并启动Nginx。

sudo sysrc nginx_enable=yes
sudo service nginx start

sudo vim /usr/local/etc/nginx/invoiceplane.conf 并为InvoicePlane设置Nginx。

server {
  listen 80;
  listen [::]:80;

  server_name example.com;

  root /usr/local/www/invoiceplane;

  index index.php index.html;

  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }

  location ~ .php$ {
    fastcgi_index index.php;
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass 127.0.0.1:9000;
  }
}

保存文件并退出。

现在我们需要包括 invoiceplane.conf 在主要 nginx.conf 文件。

sudo vim /usr/local/etc/nginx/nginx.conf 并将以下行添加到 http {} 块。

include invoiceplane.conf;

测试配置。

sudo nginx -t

重新加载Nginx。

sudo service nginx reload

安装InvoicePlane

下载InvoicePlane的最新稳定版本并解压缩存档。

cd /usr/local/www/
sudo curl -O -J -L https://invoiceplane.com/download/v1.5.9
sudo unzip v1.5.9.zip
sudo rm v1.5.9.zip
sudo mv ip invoiceplane

导航到 /usr/local/www/invoiceplane 夹。

cd /usr/local/www/invoiceplane

制作一份 ipconfig.php.example 文件并重命名副本 ipconfig.php

sudo cp ipconfig.php.example ipconfig.php

打开 ipconfig.php 文件并向其中添加您的URL。

sudo vim ipconfig.php
# Something like this
IP_URL=https://example.com

注意: 别忘了更换 https://example.com 带有您自己的URL的URL。

更改所有权 /usr/local/www/invoiceplane 目录到 www

sudo chown -R www:www /usr/local/www/invoiceplane

从Web浏览器运行InvoicePlane安装程序,然后按照说明进行操作。

https://your-domain.com/index.php/setup

安装完成后,您可以使用在安装过程中选择的电子邮件地址和密码登录InvoicePlane。

如果要确保安装安全,可以禁用安装程序。为此,请更换管线 DISABLE_SETUP=falseDISABLE_SETUP=true 在你的 ipconfig.php 文件。

注:本教程在Vultr VPS上测试通过,如需部署请前往Vultr.com