本页内容
- 先决条件
- 安装 Apache、PHP 和 MariaDB
- 为 InvoicePlane 创建数据库
- 安装 InvoicePlane
- 为 InvoicePlane 配置 Apache
- 访问 InvoicePlane Web 界面
- 使用 Let's Encrypt SSL 保护 InvoicePlane
- 结论
InvoicePlane 是一款免费、开源且可自托管的应用程序,用于管理您的报价、发票、客户和付款。许多组织和自由职业者使用它来管理他们的付款和发票。它提供自定义模板、主题和其他工具,帮助您增强 InvoicePlane 的功能。它还支持多种语言和多种支付提供商,例如 Paypal、Stripe,甚至通过 Coinbase 支持 Bitcoin。
在本教程中,我们将向您展示如何在 Debian 11 上使用 Apache 安装 InvoicePlane。
先决条件
- 一台运行 Debian 11 的服务器。
- 一个指向您服务器 IP 的有效域名。
- 服务器上已配置 root 密码。
安装 Apache、PHP 和 MariaDB
首先,您需要在服务器上安装 Apache Web 服务器、MariaDB 数据库服务器、PHP 以及其他必需的 PHP 扩展。您可以通过运行以下命令来安装所有这些组件:
apt-get install apache2 mariadb-server php libapache2-mod-php php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql wget unzip php-cli php-zip php-curl -y
所有软件包安装完成后,编辑 PHP 配置文件并更改默认设置:
nano /etc/php/7.4/apache2/php.ini
更改以下行:
memory_limit = 256M upload_max_filesize = 128M max_execution_time = 360 date.timezone = UTC
保存并关闭文件,然后重启 Apache 服务以应用更改:
systemctl restart apache2
为 InvoicePlane 创建数据库
接下来,您需要保护 MariaDB 安装,并为 InvoicePlane 创建一个数据库和用户。
首先,使用以下命令保护 MariaDB 安装:
mysql_secure_installation
如下所示回答所有问题:
Set root password? [Y/n] Y Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y
接下来,使用以下命令连接到 MariaDB shell:
mysql -u root -p
连接成功后,使用以下命令为 InvoicePlane 创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE invplanedb;
MariaDB [(none)]> CREATE USER 'invplane'@'localhost' IDENTIFIED BY 'password';
接下来,使用以下命令向 InvoicePlane 授予所有权限:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON invplanedb.* TO 'invplane'@'localhost';
接下来,运行 FLUSH PRIVILEGES 命令,以便 MariaDB 重新加载权限表:
MariaDB [(none)]> FLUSH PRIVILEGES;
最后,退出 MariaDB shell:
MariaDB [(none)]> EXIT
安装 InvoicePlane
首先,使用以下命令下载 InvoicePlane 的最新版本:
wget -c -O v1.5.11.zip https://invoiceplane.com/download/v1.5.11
下载完成后,为 InvoicePlane 创建一个目录,并将下载的文件解压到 InvoicePlane 目录中:
mkdir /var/www/html/invoiceplane
unzip v1.5.11.zip -d /var/www/html/invoiceplane
接下来,进入 InvoicePlane 目录,并重命名配置文件和 .htaccess 文件:
cd /var/www/html/invoiceplane
cp ipconfig.php.example ipconfig.php
cp htaccess .htaccess
接下来,使用以下命令编辑 ipconfig.php 文件:
nano ipconfig.php
如下所示定义您的网站 URL 和数据库设置:
IP_URL=http://invoice.example.com DB_HOSTNAME=localhost DB_USERNAME=invplane DB_PASSWORD=password DB_DATABASE=invplanedb DB_PORT=3306
接下来,为 InvoicePlane 目录设置适当的权限和所有权:
chown -R www-data:www-data /var/www/html/invoiceplane/
chmod -R 755 /var/www/html/invoiceplane/
为 InvoicePlane 配置 Apache
接下来,您需要为 InvoicePlane 创建一个 Apache 虚拟主机配置文件。您可以使用以下命令创建它:
nano /etc/apache2/sites-available/invoiceplane.conf
添加以下行:
<VirtualHost *:80>
ServerAdmin
[email protected]
DocumentRoot /var/www/html/invoiceplane
ServerName invoice.example.com
<Directory /var/www/html/invoiceplane/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
保存并关闭文件,然后使用以下命令激活 Apache 虚拟主机和 rewrite 模块:
a2ensite invoiceplane.conf
a2enmod rewrite
接下来,重启 Apache 服务以应用配置更改:
systemctl restart apache2
要验证 Apache 状态,请运行以下命令:
systemctl status apache2
您将获得以下输出:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-01-21 08:42:34 UTC; 5s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 15965 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 15970 (apache2)
Tasks: 6 (limit: 2341)
Memory: 15.1M
CPU: 82ms
CGroup: /system.slice/apache2.service
??15970 /usr/sbin/apache2 -k start
??15971 /usr/sbin/apache2 -k start
??15972 /usr/sbin/apache2 -k start
??15973 /usr/sbin/apache2 -k start
??15974 /usr/sbin/apache2 -k start
??15975 /usr/sbin/apache2 -k start
Jan 21 08:42:34 debian11 systemd[1]: Starting The Apache HTTP Server...
访问 InvoicePlane Web 界面
现在,打开您的 Web 浏览器,使用 URL http://invoice.example.com 访问 InvoicePlane Web 界面。您应该会看到以下页面:

点击 Setup 按钮。您应该会看到语言选择页面:

选择您的语言并点击 Continue 按钮。您应该会看到先决条件页面:

点击 Continue 按钮。您应该会看到以下页面:

点击 Continue 按钮。您应该会看到以下页面:

点击 Continue 按钮。您应该会看到以下页面:


提供您的管理员用户账户信息、地址,然后点击 Continue 按钮。InvoicePlane 安装完成后,您应该会看到以下页面:

点击 Login 按钮。您应该会看到以下页面:

提供您的管理员用户名、密码,然后点击 Login 按钮。您应该在以下页面看到 InvoicePlane 仪表板:

使用 Let's Encrypt SSL 保护 InvoicePlane
使用 Let's Encrypt SSL 保护您的网站始终是一个好主意。您需要安装 Certbot 客户端来安装和管理 SSL。您可以使用以下命令安装它:
apt-get install python3-certbot-apache -y
Certbot 安装完成后,运行以下命令以使用 Let's Encrypt SSL 保护您的网站:
certbot --apache -d invoice.example.com
系统将要求您提供电子邮件并接受服务条款,如下所示:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator standalone, Installer None Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): [email protected] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Plugins selected: Authenticator apache, Installer apache Obtaining a new certificate Performing the following challenges: http-01 challenge for invoice.example.com Enabled Apache rewrite module Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/apache2/sites-available/invoice-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/apache2/sites-available/invoice-le-ssl.conf Enabling available site: /etc/apache2/sites-available/invoice-le-ssl.conf
接下来,如下所示选择是否将 HTTP 流量重定向到 HTTPS:
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
输入 2 并按 Enter 键为您的网站安装 Let's Encrypt SSL:
Enabled Apache rewrite module Redirecting vhost in /etc/apache2/sites-enabled/invoice.conf to ssl vhost in /etc/apache2/sites-available/invoice-le-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://invoice.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=invoice.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/invoice.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/invoice.example.com/privkey.pem Your cert will expire on 2022-04-23. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
结论
恭喜!您已在 Debian 11 上成功安装了带有 Apache 和 Let's Encrypt SSL 的 InvoicePlane。现在您可以在公司中部署 InvoicePlane,并开始通过 Web 浏览器管理您的付款和发票。