如何在 Debian 11 上使用 Apache 和 Free Lets Encrypt SSL 证书安装 InvoicePlane
在此页
- 先决条件
- 安装 Apache、PHP 和 MariaDB
- 为 InvoicePlane 创建数据库
- 安装 InvoicePlane
- 为 InvoicePlane 配置 Apache
- 访问 InvoicePlane 网络用户界面
- 使用 Lets Encrypt SSL 保护 InvoicePlane
- 结论
InvoicePlane 是一个免费、开源和自托管的应用程序,用于管理您的报价单、发票、客户和付款。许多组织和自由职业者使用它来管理他们的付款和发票。它提供自定义模板、主题和其他工具,可帮助您增加 InvoicePlane 的功能。它还支持多种语言和多种支付提供商,例如 Paypal、Stripe 甚至通过 Coinbase 的比特币。
在本教程中,我们将向您展示如何在 Debian 11 上使用 Apache 安装 InvoicePlane。
先决条件
- 运行 Debian 11 的服务器。
- 用您的服务器 IP 指向的有效域名。
- 在服务器上配置了根密码。
安装 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
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 虚拟主机并使用以下命令重写模块:
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 UI
现在,打开您的 Web 浏览器并使用 URL http://invoice.example.com 访问 InvoicePlane Web 界面。您应该会看到以下页面:

单击“设置”按钮。您应该看到语言选择页面:

选择您的语言,然后单击“继续”按钮。您应该看到先决条件页面:

单击继续按钮。您应该会看到以下页面:

单击继续按钮。您应该会看到以下页面:

单击继续按钮。您应该会看到以下页面:


提供您的管理员用户帐户信息、地址,然后单击“继续”按钮。安装 InvoicePlane 后,您应该会看到以下页面:

单击“登录”按钮。您应该会看到以下页面:

提供您的管理员用户名和密码,然后单击“登录”按钮。您应该在以下页面上看到 InvoicePlane 仪表板:

使用 Lets Encrypt SSL 保护 InvoicePlane
使用 Lets Encrypt SSL 保护您的网站始终是个好主意。您将需要安装 Certbot 客户端来安装和管理 SSL。您可以使用以下命令安装它:
apt-get install python3-certbot-apache -y
安装 Certbot 后,运行以下命令以使用 Lets 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):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 键为您的网站安装 Lets 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 和 Lets Encrypt SSL 的 InvoicePlane。您现在可以在您的公司中实施 InvoicePlane 并开始从 Web 浏览器管理您的付款和发票。