The author selected Software in the Public Interest to receive a donation as part of the Write for DOnations program.
作者选择了符合公共利益的软件来接受捐赠,这是Write for DOnations计划的一部分。
ERPNext is an Enterprise Resource Planning (ERP) suite that leverages the power and flexibility of open-source technologies. It excels at managing core business processes such as finance, sales, human resources, manufacturing, purchases, services, helpdesk needs, and more. Among the benefits of implementing a system like ERPNext are:
ERPNext是一个企业资源计划(ERP)套件,它利用了开源技术的强大功能和灵活性。 它擅长管理核心业务流程,例如财务,销售,人力资源,制造,采购,服务,服务台需求等。 实施像ERPNext这样的系统的好处包括:
ERPNext is based on Frappe, a full-stack web application framework written in Python that takes full advantage of the Node/JavaScript runtime environment and uses MariaDB as its database backend. One of the many advantages of Frappe-based applications, like ERPNext, is the bench command-line utility. The bench CLI saves administrators time by automating tasks such as installing, updating, configuring, and managing multiple Frappe/ERPNext sites.
ERPNext基于Frappe(Frappe) , Frappe是一个用Python编写的全栈Web应用程序框架,该框架充分利用了Node / JavaScript运行时环境,并使用MariaDB作为其数据库后端。 台式命令行实用程序 ,是基于Frappe的应用程序(如ERPNext)的众多优势之一。 台式CLI通过自动执行诸如安装,更新,配置和管理多个Frappe / ERPNext站点之类的任务来节省管理员时间。
In this tutorial you will install and configure an ERPNext stack on one server running Ubuntu 20.04. This will allow you to configure your stack for various development or production environments depending on your needs, and it will prepare you to build a more complex, fault-tolerant architecture.
在本教程中,您将在一台运行Ubuntu 20.04的服务器上安装和配置ERPNext堆栈。 这将允许您根据需要为各种开发或生产环境配置堆栈,并为您构建更复杂,容错的体系结构做准备。
One Ubuntu 20.04 server with at least 4 GB of RAM and a non-root sudo
user. You can set up your server and user by following our Ubuntu 20.04 initial server setup guide.
一台具有至少4 GB RAM和一个非root用户sudo
用户的Ubuntu 20.04服务器。 您可以按照我们的Ubuntu 20.04初始服务器设置指南来设置服务器和用户。
Note: When choosing your server’s specifications, keep in mind that ERP systems are resource-intensive. This guide calls for one server with 4 GB of RAM, which is sufficient for basic use cases, but specific hardware requirements may vary depending on the number of users as well as your business size.
注意:选择服务器规格时,请记住,ERP系统是资源密集型的。 本指南要求一台服务器具有4 GB的RAM,足以满足基本使用情况,但特定的硬件要求可能会因用户数量以及您的业务规模而异。
A fully registered domain name with an A record pointed to your server. If you are using a DigitalOcean Droplet then you can follow this guide to properly set up your DNS. This tutorial will use your_domain
throughout.
带有A记录的完全注册的域名指向您的服务器。 如果您使用的是DigitalOcean Droplet,则可以按照本指南正确设置DNS 。 本教程将整个使用your_domain
。
Although configuring a firewall for development is optional, for production it is a mandatory security practice.
尽管为开发配置防火墙是可选的,但对于生产来说,这是强制性的安全措施。
You will need to open the following ports on your ERPNext server:
您将需要在ERPNext服务器上打开以下端口:
80/tcp
and 443/tcp
for HTTP and HTTPS respectively
HTTP和HTTPS分别为80/tcp
和443/tcp
3306/tcp
for MariaDB connection (recommended only if you need remote access to database)
3306/tcp
用于MariaDB连接(仅在需要远程访问数据库时才建议使用)
143/tcp
and 25/tcp
for IMAP and STMP respectively
IMAP和STMP分别为143/tcp
和25/tcp
22/tcp
for SSH (if you have not already enabled OpenSSH
in your UFW settings)
SSH 22/tcp
(如果尚未在UFW设置中启用OpenSSH
)
8000/tcp
for testing your platform before deploying to production
8000/tcp
用于在部署到生产环境之前测试平台
To open multiple ports at once you can use the following command:
要一次打开多个端口,可以使用以下命令:
Alternatively, you can allow connections from specific IP addresses on specific ports using this command:
另外,您可以使用以下命令允许来自特定端口上特定IP地址的连接:
sudo ufw allow from server_IP to any port port_number
sudo ufw允许从server_IP到任何端口port_number
After opening all necessary ports enable the firewall:
打开所有必需的端口后,启用防火墙:
Now confirm the status of your firewall:
现在确认防火墙的状态:
UFW will output a list of your enabled rules. Make sure ERPNext’s necessary ports are open:
UFW将输出您已启用规则的列表。 确保ERPNext的必要端口已打开:
Output
Status: active
To Action From
-- ------ ----
22,25,80,143,443,3306,8000/tcp ALLOW Anywhere
22,25,80,143,443,3306,8000/tcp (v6) ALLOW Anywhere (v6)
For more information regarding UFW’s configuration, consult our guide on how to set up a firewall with UFW on Ubuntu 20.04.
有关UFW配置的更多信息, 请参阅我们的指南,了解如何在Ubuntu 20.04上使用UFW设置防火墙 。
Setting up a proper firewall is the first of two preliminary steps. Now you will configure keyboard mapping and character encoding on your server.
设置适当的防火墙是两个初步步骤中的第一步。 现在,您将在服务器上配置键盘映射和字符编码。
It’s highly recommended that you configure keyboard mapping for the console as well as the language and the character encoding on your host. This is necessary to avoid possible issues during the ERPNext 12 installation process. Take note that this configuration has nothing to do with the UI language on your actual ERPNext platform, but with the system locale configuration.
强烈建议您为控制台配置键盘映射以及主机上的语言和字符编码。 这是避免在ERPNext 12安装过程中可能出现的问题所必需的。 请注意,此配置与您实际的ERPNext平台上的UI语言无关,而与系统区域设置有关。
First, update your server:
首先,更新您的服务器:
Now configure keymap, language, and character encoding:
现在配置键盘映射,语言和字符编码:
The localectl
utility is used by Ubuntu 20.04 and other Linux distributions to control and change system-wide locale and keyboard layout settings before the user logs in, which is exactly what ERPNext 12 requires.
Ubuntu 20.04和其他Linux发行版使用localectl
实用程序在用户登录之前控制和更改系统范围的语言环境和键盘布局设置,这正是ERPNext 12的要求。
You will also need to add the following lines to your /etc/environment
file. Use nano
or your preferred text editor to open the file:
您还需要在/etc/environment
文件中添加以下行。 使用nano
或您喜欢的文本编辑器打开文件:
Now add the following content:
现在添加以下内容:
LC_ALL=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LANG=en_US.UTF-8
Save and close the file.
保存并关闭文件。
Reboot your server to apply all changes:
重新启动服务器以应用所有更改:
Give your server a few minutes to reboot and then use ssh
to reenter your instance. You are now ready to install your database.
给您的服务器几分钟的时间来重新引导,然后使用ssh
重新输入您的实例。 现在,您可以安装数据库了。
Now you will add MariaDB to your server stack. ERPNext 12 requires MariaDB 10.2+ for proper operation. Because Ubuntu 20.04 includes MariaDB 10.3 in its official repositories you can install this version using the apt
command:
现在,您将MariaDB添加到服务器堆栈中。 ERPNext 12需要MariaDB 10.2+才能正常运行。 因为Ubuntu 20.04在其官方存储库中包括MariaDB 10.3,所以您可以使用apt
命令安装此版本:
Alternatively, if prefer a newer MariaDB version, you can follow Step 3 of our guide on how to install an ERPNext Stack on Ubuntu 18.04. This will guide you through MariaDB’s online repository wizard, which will help you install the newest version—MariaDB 10.5.
另外,如果希望使用较新的MariaDB版本,则可以按照指南的步骤3进行操作,以了解如何在Ubuntu 18.04上安装ERPNext Stack 。 这将指导您完成MariaDB的在线存储库向导,该向导将帮助您安装最新版本-MariaDB 10.5。
After installing mariadb-server
, install the following packages:
安装mariadb-server
,请安装以下软件包:
ERPNext 12 is a Python application and thus it requires the python3-mysqldb
library for database management. libmysqlclient-dev
is required to access certain MariaDB developer features.
ERPNext 12是一个Python应用程序,因此它需要python3-mysqldb
库进行数据库管理。 libmysqlclient-dev
才能访问某些MariaDB开发人员功能。
Next, add an extra layer of security to the MariaDB server by running the mysql_secure_installation
script:
接下来,通过运行mysql_secure_installation
脚本为MariaDB服务器添加额外的安全性:
The mysql_secure_installation
script will prompt you with several questions:
mysql_secure_installation
脚本将提示您几个问题:
The first prompt will ask you about the root password, but since there is no password configured yet, press ENTER
.
第一个提示将询问您有关root密码的信息,但是由于尚未配置密码,请按ENTER
。
Next, when asked about changing the MariaDB root password, answer N
. Using the default password along with Unix authentication is the recommended setup for Ubuntu-based systems because the root account is closely related to automated system maintenance tasks.
接下来,当询问有关更改MariaDB 根密码的信息时,回答N
对于基于Ubuntu的系统,建议使用默认密码和Unix身份验证,因为root帐户与自动系统维护任务密切相关。
The remaining questions have to do with removing the anonymous database user, restricting the root account to log in remotely on localhost, removing the test database, and reloading privilege tables. It is safe to answer Y
to all those questions.
其余问题与删除匿名数据库用户,限制root帐户远程登录localhost,删除测试数据库以及重新加载特权表有关。 对所有这些问题回答Y
都是安全的。
After completing the mysql_secure_installation
script, MariaDB will start running using its default configuration. The standard ERPNext installation uses MariaDB’s root user for all database operations. While that approach may be convenient on single server setups, it is not considered a good security practice. Therefore, in the next section you will learn how to avoid this issue by creating a new user with special privileges.
完成mysql_secure_installation
脚本后,MariaDB将使用其默认配置开始运行。 标准的ERPNext安装使用MariaDB的根用户进行所有数据库操作。 尽管该方法在单服务器设置上可能很方便,但它不被认为是一种好的安全做法。 因此,在下一节中,您将学习如何通过创建具有特殊特权的新用户来避免此问题。
ERPNext expects to use MariaDB’s root user for managing database connections, but this is not always ideal. To overcome this limitation and let a non-root user manage MariaDB you will now manually create a database named after the user. Then you will be able to assign special privileges to the new user to drive ERPNext database operations.
ERPNext希望使用MariaDB的根用户来管理数据库连接,但这并不总是理想的。 为了克服此限制并让非root用户管理MariaDB,您现在将手动创建一个以该用户命名的数据库。 然后,您将能够为新用户分配特殊特权,以驱动ERPNext数据库操作。
Open up the MariaDB prompt:
打开MariaDB提示符:
Now create a new database named after the user you want to assign for MariaDB connections. This tutorial will use sammy
but you can choose a different name:
现在创建一个新数据库,该数据库以您要为MariaDB连接分配的用户命名。 本教程将使用sammy
但您可以选择其他名称:
CREATE DATABASE sammy;
创建数据库sammy ;
Confirm that the database was created using this SQL statement:
确认数据库是使用以下SQL语句创建的:
You will see an output similar to this:
您将看到类似于以下的输出:
Output
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sammy |
+--------------------+
Now create the MariaDB user sammy
with privileges similar to root and then give the user a strong password of your choice. Keep the password in a secure place; you will need it later:
现在,以类似于root的特权创建MariaDB用户sammy
,然后为该用户提供您选择的强密码。 将密码放在安全的地方; 您稍后将需要它:
GRANT ALL PRIVILEGES ON *.* TO 'sammy'@'%' IDENTIFIED BY 'mariadb_password' WITH GRANT OPTION;
将所有特权授予 *。*,以' mariadb_password '标识的' sammy '@'%', 并带有GRANT OPTION;
Now confirm both the user creation and the new user’s privileges:
现在确认用户创建和新用户的特权:
You will see an output like this:
您将看到类似以下的输出:
Output
+-----------+-------+------------+
| Host | User | Super_priv |
+-----------+-------+------------+
| localhost | root | Y |
| localhost | mysql | Y |
| % | sammy| Y |
+-----------+-------+------------+
3 rows in set (0.001 sec)
Now flush privileges to apply all changes:
现在刷新特权以应用所有更改:
Once you finish, exit the session:
完成后,退出会话:
Now that you have created a database user you only need to fine-tune MariaDB to ensure proper ERPNext 12 operation. Fortunately, the ERPNext team provides an excellent configuration template that you will use as a starting point for your implementation. In the next section, you will learn how to properly configure the MariaDB database using that template.
现在您已经创建了数据库用户,您只需要微调MariaDB即可确保ERPNext 12正常运行。 幸运的是,ERPNext团队提供了出色的配置模板,您可以将其用作实施的起点。 在下一部分中,您将学习如何使用该模板正确配置MariaDB数据库。
With MariaDB installed and secured it’s time to fine-tune it for ERPNext connections.
安装并保护了MariaDB之后,就可以对其进行微调以用于ERPNext连接了。
First, stop mariadb.service
:
首先,停止mariadb.service
:
Now use nano
or your favorite text editor to create a MariaDB configuration file called mariadb.cnf
:
现在,使用nano
或您喜欢的文本编辑器创建一个名为mariadb.cnf
的MariaDB配置文件:
Now add ERPNext’s official configuration template:
现在添加ERPNext的官方配置模板:
[mysqld]
# GENERAL #
user = mysql
default-storage-engine = InnoDB
socket = /var/lib/mysql/mysql.sock
pid-file = /var/lib/mysql/mysql.pid
# MyISAM #
key-buffer-size = 32M
myisam-recover = FORCE,BACKUP
# SAFETY #
max-allowed-packet = 256M
max-connect-errors = 1000000
innodb = FORCE
# DATA STORAGE #
datadir = /var/lib/mysql/
# BINARY LOGGING #
log-bin = /var/lib/mysql/mysql-bin
expire-logs-days = 14
sync-binlog = 1
# REPLICATION #
server-id = 1
# CACHES AND LIMITS #
tmp-table-size = 32M
max-heap-table-size = 32M
query-cache-type = 0
query-cache-size = 0
max-connections = 500
thread-cache-size = 50
open-files-limit = 65535
table-definition-cache = 4096
table-open-cache = 10240
# INNODB #
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 512M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb-buffer-pool-size = 5462M
innodb-file-format = barracuda
innodb-large-prefix = 1
collation-server = utf8mb4_unicode_ci
character-set-server = utf8mb4
character-set-client-handshake = FALSE
max_allowed_packet = 256M
# LOGGING #
log-error = /var/lib/mysql/mysql-error.log
log-queries-not-using-indexes = 0
slow-query-log = 1
slow-query-log-file = /var/lib/mysql/mysql-slow.log
# CONNECTIONS #
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
bind-address = 0.0.0.0
[mysql]
default-character-set = utf8mb4
[mysqldump]
max_allowed_packet=256M
Save and close the file. For more detailed information about these configurations, review this template file on ERPNext’s Github repo. This is a useful starting point for exploring these options.
保存并关闭文件。 有关这些配置的更多详细信息,请查看ERPNext的Github存储库上的此模板文件 。 这是探索这些选项的有用起点。
The configuration file, /etc/mysql/mariadb.conf.d/mariadb.cnf
, complements and also overrides a few values included in the default MariaDB configuration located at /etc/mysql/my.cnf
. This file gives you a curated template that greatly enhances database performance for ERPNext. Keep in mind, however, that while this template is a great starting point nothing prevents you from improving MariaDB’s performance even further by adjusting these parameters to fit your needs.
配置文件/etc/mysql/mariadb.conf.d/mariadb.cnf
补充并覆盖了/etc/mysql/my.cnf
的默认MariaDB配置中包含的一些值。 该文件为您提供了精选的模板,可以大大增强ERPNext的数据库性能。 但是请记住,虽然此模板是一个很好的起点,但是没有什么可以阻止您通过调整这些参数以满足您的需求来进一步提高MariaDB的性能。
Since ERPNext relies on the database connection for almost all of its internal operations, it is a good idea to test the connection before continuing.
由于ERPNext几乎所有内部操作都依赖于数据库连接,因此在继续之前测试连接是一个好主意。
Start mariadb.service
:
启动mariadb.service
:
To test the connection you can use the following command. Remember to replace sammy
and mariadb_password
with your credentials:
要测试连接,可以使用以下命令。 请记住用您的凭据替换sammy
和mariadb_password
:
mysql --user sammy --password mariadb_password --host=localhost --protocol=tcp --port=3306 test
mysql --user sammy --password mariadb_password --host = localhost --protocol = tcp --port = 3306测试
You will see an output showing MariaDB’s basic help content and several parameters. This means your connection was successful:
您将看到一个输出,显示MariaDB的基本帮助内容和几个参数。 这意味着您的连接成功:
Output
mysql Ver 15.1 Distrib 10.4.13-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Usage: mysql [OPTIONS] [database]
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
...
--ssl-verify-server-cert
Verify server's "Common Name" in its cert against
hostname used when connecting. This option is disabled by
default.
-t, --table Output in table format.
--tee=name Append everything into outfile. See interactive help (\h)
also. Does not work in batch mode. Disable with
--disable-tee. This option is disabled by default.
-u, --user=name User for login if not current user.
-U, --safe-updates Only allow UPDATE and DELETE that uses keys.
-U, --i-am-a-dummy Synonym for option --safe-updates, -U.
-v, --verbose Write more. (-v -v -v gives the table output format).
...
max-join-size 1000000
secure-auth FALSE
show-warnings FALSE
plugin-dir (No default value)
default-auth (No default value)
binary-mode FALSE
connect-expired-password FALSE
If you need to make any adjustments to MariaDB’s settings or fix any errors, remember to reload the service using the following command:
如果您需要对MariaDB的设置进行任何调整或修复任何错误,请记住使用以下命令重新加载服务:
Once you are done, enable MariaDB:
完成后,启用MariaDB:
Now that you have tested the database connection, you can continue with the installation of your ERPNext application.
现在,您已经测试了数据库连接,可以继续安装ERPNext应用程序。
Now that your database backend is ready you can continue setting up your ERPNext web application. In this section, you will learn how to install and configure all components required by ERPNext 12 and then install the application itself.
现在您的数据库后端已准备就绪,您可以继续设置ERPNext Web应用程序。 在本节中,您将学习如何安装和配置ERPNext 12所需的所有组件,然后安装应用程序本身。
Start by preparing the server with all the system packages required by ERPNext 12. Install system-wide dependencies using the following command:
首先使用ERPNext 12所需的所有系统软件包准备服务器。使用以下命令安装系统范围的依赖项:
The DEBIAN_FRONTEND=noninteractive
variable has been passed to the installation command in order to avoid Postfix prompts. For detailed information regarding Postfix configuration please read our guide on How To Install and Configure Postfix on Ubuntu 20.04
DEBIAN_FRONTEND=noninteractive
变量传递给安装命令,以避免出现Postfix提示。 有关Postfix配置的详细信息,请阅读有关如何在Ubuntu 20.04上安装和配置Postfix的指南。
Next, update pip3
, which is Python’s standard package manager, and then install the latest versions of three additional Python modules:
接下来,更新pip3
(它是Python的标准软件包管理器),然后安装三个其他Python模块的最新版本:
setuptools
facilitates the installation and upgrading of Python packages, cryptography
adds encryption capabilities to your stack, and psutil
aids with system monitoring. Now that you have installed all necessary global dependencies, you will now install all the services and libraries required by ERPNext 12.
setuptools
有助于Python软件包的安装和升级 , cryptography
为您的堆栈增加了加密功能 ,而psutil
有助于系统监视 。 现在,您已经安装了所有必需的全局依赖项,现在将安装ERPNext 12所需的所有服务和库。
ERPNext 12 can work with version 8+ of the Node.js server environment. In fact, at the time of this writing, the official ERPNext easy_install
script uses Node 8. But from a security perspective, it’s advisable to install a newer version because Node 8 reached its End Of Life (EOL) in 2020 and thus will not receive any more security patches. At the time of this writing, Ubuntu 20.04 contains version 10.19 of Node.js. Although this version is still maintained, for similar reasons (EOL in less than a year) it’s highly advisable to avoid using it. For this guide, Node.js version 12 LTS will be installed along with the corresponding npm
and yarn
package managers. Please note that the Frappe framework uses yarn
to install dependencies. If you decide to use an alternative installation method then make sure that you end up with version 1.12+ of yarn
running in your system.
ERPNext 12可以与Node.js服务器环境的8+版本一起使用。 实际上,在撰写本文时,正式的ERPNext easy_install
脚本使用的是Node8。但是,从安全角度考虑,建议安装较新的版本,因为Node 8将于2020年达到使用寿命(EOL),因此不会收到任何其他安全补丁。 在撰写本文时,Ubuntu 20.04包含Node.js的10.19版本。 尽管仍保留该版本,但出于类似原因(不到一年就停止销售),强烈建议避免使用它。 对于本指南,将安装Node.js 12 LTS版本以及相应的npm
和yarn
包管理器。 请注意,Frappe框架使用yarn
来安装依赖项。 如果决定使用其他安装方法,请确保最终在系统中运行的yarn
版本为1.12+。
Add the NodeSource repository to your system:
将NodeSource存储库添加到您的系统:
Now you can inspect the contents of the downloaded script:
现在,您可以检查下载的脚本的内容:
Once you are satisfied with the script’s contents you can run the script:
对脚本的内容满意后,就可以运行该脚本:
This script will automatically update the apt
list. Now you can install nodejs
on your server:
该脚本将自动更新apt
列表。 现在,您可以在服务器上安装nodejs
了:
Next, install yarn
globally using the npm
package manager:
接下来,使用npm
软件包管理器全局安装yarn
:
Now that you have installed Node you can continue to configure wkhtmltopdf
for your platform.
现在已经安装了Node,您可以继续为平台配置wkhtmltopdf
。
ERPNext uses the wkhtmltopdf
open source tool to convert HTML content into PDF using the Qt WebKit rendering engine. This feature is mostly used for printing invoices, quotations, and other reports. In the case of ERPNext 12, a specific version of wkhtmltopdf
is required, 0.12.5
with patched Qt.
ERPNext使用wkhtmltopdf
开源工具使用Qt WebKit呈现引擎将HTML内容转换为PDF。 此功能主要用于打印发票,报价单和其他报告。 对于ERPNext 12,需要特定版本的wkhtmltopdf
,带有修补Qt的0.12.5
。
To install wkhtmltopdf
, start by switching to a suitable directory to download the package, in this case /tmp
:
要安装wkhtmltopdf
,请首先切换到合适的目录以下载软件包,在本例中为/tmp
:
Download the appropriate wkhtmltopdf
version and package for Ubuntu 20.04 from the project’s page:
从项目页面下载适用于Ubuntu 20.04的wkhtmltopdf
版本和软件包:
Now install the package using the dpkg
tool:
现在,使用dpkg
工具安装软件包:
Next, copy all relevant executables to your /usr/bin/
directory:
接下来,将所有相关的可执行文件复制到您的/usr/bin/
目录中:
Once the files are in place, change their permissions to make them executable:
文件到位后,更改其权限以使其可执行:
Now that wkhtmltopdf
is properly installed we will add Redis to our database stack.
现在已经正确安装了wkhtmltopdf
我们将Redis添加到我们的数据库堆栈中。
ERPNext 12 uses Redis to enhance MariaDB’s performance. Specifically, Redis assists with caching.
ERPNext 12使用Redis增强了MariaDB的性能。 具体来说, Redis可帮助进行缓存 。
First, install Redis from the official Ubuntu 20.04 repository:
首先,从官方的Ubuntu 20.04存储库安装Redis:
Then enable Redis on startup:
然后在启动时启用Redis:
Now that you have added Redis to your stack let’s take a moment to summarize what you have accomplished so far. Up to this point, you have installed all the major components required by ERPNext 12, which include:
现在您已将Redis添加到堆栈中,让我们花点时间总结到目前为止已完成的工作。 至此,您已经安装了ERPNext 12所需的所有主要组件,包括:
The wkhtmltopdf
PDF documents generator
wkhtmltopdf
PDF文档生成器
Whether you are installing the ERP system for development or for production, you are now ready for the next step, which is installing the Frappe full-stack framework and the actual ERPNext 12 web application.
无论您是安装用于开发还是生产的ERP系统,现在都准备好进行下一步,即安装Frappe全栈框架和实际的ERPNext 12 Web应用程序。
Now that you have installed all of ERPNext’s stack requirements you can unleash the flexibility of Frappe’s bench
command-line utility. The bench
CLI was designed with the purpose of assisting users in the process of installing, setting up, and managing applications like ERPNext that are based on the Frappe Framework. In the coming sections, you will install the bench
CLI and then use it to complete the process of setting up ERPNext 12.
现在,您已经安装了ERPNext的所有堆栈要求,您可以释放Frappe的bench
命令行实用程序的灵活性。 bench
CLI旨在帮助用户在基于Frappe框架的ERPNext等应用程序的安装,设置和管理过程中提供帮助。 在接下来的部分中,您将安装bench
CLI,然后使用它来完成设置ERPNext 12的过程。
Make sure that the Frappe user (in this case sammy
) has the proper rights on its home
directory:
确保Frappe用户(在本例中为sammy
)对其home
目录具有正确的权限:
sudo chown sammy -R /home/sammy
sudo chown sammy -R / home / sammy
Now clone the frappe/bench
repository to your home directory. Remember to replace sammy
with your system username:
现在将frappe/bench
存储库克隆到您的主目录。 请记住用您的系统用户名替换sammy
:
git clone https://github.com/frappe/bench /home/sammy/.bench --depth 1 --branch master
git clone https://github.com/frappe/bench / home / sammy /.bench --depth 1 --branch master
Install the bench
CLI:
安装bench
CLI:
sudo pip3 install -e /home/sammy/.bench
须藤pip3 install -e / home / sammy /.bench
This guide is assuming that you are installing ERPNext 12 for testing/production scenarios and thus that you are using the master
branch. But if your intention is to develop applications or custom ERPNext modules, then the develop
branch might be a better option. In either case, you are now prepared to install the Frappe Framework. This will be your final step before installing ERPNext itself.
本指南假定您正在安装用于测试/生产方案的ERPNext 12,并且正在使用master
分支。 但是,如果您打算开发应用程序或定制的ERPNext模块,那么develop
分支可能是一个更好的选择。 无论哪种情况,您现在都准备安装Frappe Framework。 这是安装ERPNext本身之前的最后一步。
In this section, you will create a Frappe environment using the bench
CLI.
在本节中,您将使用bench
CLI创建Frappe环境 。
During Frappe’s installation you may exceed Ubuntu’s file watch limit, which by default is set to 8192. To avoid this issue set a higher limit using the following command:
在Frappe的安装过程中,您可能会超出Ubuntu的文件监视限制,该文件监视限制默认情况下设置为8192。为避免此问题,请使用以下命令设置更高的限制:
The tee
command will append the contents of your echo
command to the called file while also printing the output to your console.
tee
命令会将echo
命令的内容附加到被调用的文件,同时还将输出打印到控制台。
Next, initialize Frappe Framework 12. Replace Sammy with your system username:
接下来,初始化Frappe Framework12。用您的系统用户名替换Sammy:
bench init /home/sammy/frappe-bench --frappe-path https://github.com/frappe/frappe --frappe-branch version-12 --python python3
Bench init / home / sammy / frappe -bench --frappe-path https://github.com/frappe/frappe --frappe-branch版本12 --python python3
During execution you may see one error about your path, along with several warnings. Let the process continue until the end. Once it’s finished, you will see an output similar to the following one, indicating that your environment was successfully created:
在执行期间,您可能会看到有关路径的一个错误以及一些警告。 让过程继续进行到结束。 完成后,您将看到类似于以下内容的输出,表明您的环境已成功创建:
Output
...
Done in 82.23s.
INFO:bench.utils:setting up backups
no crontab for sammy
SUCCESS: Bench /home/sammy/frappe-bench initialized
Note: The bench init
process could halt if a spawn ENOMEM
error is encountered. This error is caused when your system runs out of memory. You must fix the issue before continuing, either by installing more physical memory or allocating SWAP space.
注意:如果遇到spawn ENOMEM
错误, bench init
过程可能会停止。 当系统内存不足时,会导致此错误。 您必须先解决此问题,然后再安装更多物理内存或分配SWAP空间。
Let’s take a closer look at the command used to create the environment:
让我们仔细看看用于创建环境的命令:
/home/sammy/frappe-bench
is the path where the Frappe Framework, the websites, and associated applications will be installed. A new directory, called frappe-bench
in this example, will be created to accommodate all necessary files.
/home/ sammy / frappe-bench
是将安装Frappe框架,网站和相关应用程序的路径。 在本示例中,将创建一个名为frappe-bench
新目录来容纳所有必需的文件。
--frappe-path
points to Frappe repository, which in this case is the official Github repository.
--frappe-path
指向Frappe存储库,在这种情况下,它是官方的Github存储库。
--frappe-branch
is the Frappe version to be installed. Because you want to install ERPNext 12, the chosen version is Frappe 12.
--frappe-branch
是要安装的Frappe版本。 因为您要安装ERPNext 12,所以选择的版本是Frappe 12。
--python
is the Python version that will be used. ERPNext 12 requires Python 3.6+. Prior versions, however, still use Python 2.7.
--python
是将要使用的Python版本。 ERPNext 12需要Python 3.6+。 但是,以前的版本仍使用Python 2.7。
For more information regarding bench
CLI commands please refer to the Bench Commands Cheatsheet.
有关更多信息, bench
CLI命令请参考台式命令的cheatsheet 。
The flexibility offered by the Frappe framework goes way beyond using isolated environments. You can also create different websites and install applications into them.
Frappe框架提供的灵活性远远超出了隔离环境的范围。 您还可以创建其他网站并将应用程序安装到其中。
In this section, you will set up a Frappe-based site and then install the ERPNext 12 application on it.
在本部分中,您将设置一个基于Frappe的站点,然后在其上安装ERPNext 12应用程序。
Change to the directory where Frappe was initialized.
转到初始化Frappe的目录。
cd /home/sammy/frappe-bench
cd / home / sammy / frappe-bench
Before continuing, you will need to install specific versions of Python libraries numpy
and pandas
into the Frappe virtual environment. Install these packages using the following command:
在继续之前,您需要将特定版本的Python库numpy
和pandas
到Frappe虚拟环境中。 使用以下命令安装这些软件包:
At this point the installation might halt for about 10 to 20 minutes while displaying this message:
此时,在显示以下消息时,安装可能会停止约10至20分钟:
Output
...
Building wheel for pandas (setup.py) ... -
This has to do with a bug related to pandas
and Ubuntu 20.04, which, at the time of writing, is still rather new. Nevertheless the packages will build, and once they complete you will see an output like this:
这与与pandas
和Ubuntu 20.04有关的错误有关,在撰写本文时,它仍是相当新的。 尽管如此,这些软件包仍会构建,一旦完成,您将看到类似以下的输出:
Output
...
Successfully built pandas
Installing collected packages: pandas
Successfully installed pandas-0.24.2
Now, you can continue with the installation. Download ERPNext 12 from its repository using the bench
CLI:
现在,您可以继续安装。 使用bench
CLI从其存储库下载ERPNext 12:
Next, create the new site, replacing your_domain
with the domain that you have associated with this server’s IP:
接下来,创建新站点,将your_domain
替换为与此服务器IP关联的域:
bench new-site your_domain --admin-password 'erpnext_admin_password' --mariadb-root-username sammy --mariadb-root-password 'mariadb_password'
板凳新站点请将改为 --admin密码“erpnext_admin_password” --mariadb根户名萨米 --mariadb根密码“mariadb_password”
Let’s take a moment to review the options used in the command above:
让我们花点时间回顾一下以上命令中使用的选项:
bench new-site
creates a new site based on the Frappe Framework.
bench new-site
基于Frappe Framework创建一个新站点。
your_domain
is the name for the new site. Make sure that your domain’s DNS has an A record pointing at your server’s IP.
your_domain
是新站点的名称。 确保您域的DNS具有指向您服务器IP的A记录。
erpnext_admin_password
is the desired password for ERPNext’s Administrator user. Keep this password in a safe place—you will need it shortly.
erpnext_admin_password
是ERPNext 管理员用户所需的密码。 将此密码保存在安全的地方-您很快将需要它。
mariadb_password
is the password that you created at the beginning of the guide for the MariaDB user sammy
.
mariadb_password
是您在指南开头为MariaDB用户sammy
创建的密码。
Following this, install the ERPNext application onto the site:
之后,将ERPNext应用程序安装到站点上:
bench --site your_domain install-app erpnext
板凳--site your_domain install-app erpnext
Once the installation completes, you will have a working ERPNext 12 application. Now let’s test it using a bench
command:
安装完成后,您将拥有一个有效的ERPNext 12应用程序。 现在让我们使用bench
命令对其进行测试:
The above will initiate a real-time monitoring console showing you various messages regarding the webserver and other services. Open a web browser and navigate to localhost:8000
(for local installations) or your_domain:8000
(if you are using a remote server). You will see the ERPNext login screen (we will proceed with login and setup in a later step, once we have made our site production-ready).
上面的命令将启动一个实时监视控制台,向您显示有关Web服务器和其他服务的各种消息。 打开Web浏览器,然后导航到localhost:8000
(对于本地安装)或your_domain :8000
(如果使用的是远程服务器)。 您将看到ERPNext登录屏幕(一旦我们准备好站点的生产,我们将在后续步骤中继续登录和设置)。
After visiting your test deployment, return to your terminal and press CTRL+C
. This will stop ERPNext and exit the monitoring console.
访问测试部署后,返回到终端并按CTRL+C
这将停止ERPNext并退出监视控制台。
If your main goal is creating modules or modifying ERPNext 12, then you could stop at this point. No more components are needed for development purposes. However, if what you need is a production-ready system that does not require a manual initialization, then you will need to install and configure a few additional components. This is your next step.
如果您的主要目标是创建模块或修改ERPNext 12,则可以在此停止。 出于开发目的,不需要更多组件。 但是,如果您需要的是不需要人工初始化的可用于生产环境的系统,那么您将需要安装和配置一些其他组件。 这是您的下一步。
Although your ERPNext 12 application is ready, the system as a whole is not yet prepared for production. To ensure ERPNext’s reliability and security you will need to enable a few additional services:
尽管您的ERPNext 12应用程序已准备就绪,但整个系统尚未准备好投入生产。 为了确保ERPNext的可靠性和安全性,您将需要启用一些附加服务:
Fail2ban provides an extra layer of protection against brute force attempts from malicious users and bots.
Fail2ban提供了一层额外的保护,可防止恶意用户和僵尸程序进行暴力破解。
Nginx functions mainly as a web proxy, redirecting all traffic from port 8000
to port 80
(HTTP) or port 443
(HTTPS)
Nginx主要用作Web代理,将所有流量从端口8000
重定向到端口80
(HTTP)或端口443
(HTTPS)
Supervisor ensures that ERPNext’s key processes are constantly up and running, restarting them as necessary.
主管确保ERPNext的关键流程不断启动并运行,并在必要时重新启动它们。
Up to this point, you have installed and configured ERPNext 12 manually, which has allowed you to customize the process to match any particular use case. Nevertheless, for the rest of the production setup, you can leverage the convenience of the bench
CLI and let it automate the installation and configuration of these remaining services.
到目前为止,您已经手动安装和配置了ERPNext 12,这使您可以自定义过程以匹配任何特定用例。 但是,在其余的生产设置中,您可以利用bench
CLI的便利性,并使其自动执行这些剩余服务的安装和配置。
Ensure you are in the Frappe working directory:
确保您位于Frappe工作目录中:
cd /home/sammy/frappe-bench
cd / home / sammy / frappe-bench
Now use the following command to finish setting up ERPNext 12 for production:
现在,使用以下命令完成针对生产的ERPNext 12的设置:
sudo bench setup production sammy --yes
须藤长凳设置生产萨米-是的
The above will install and configure Nginx, Supervisor, and Fail2Ban and set sammy
as the production environment owner.
上面的代码将安装并配置Nginx,Supervisor和Fail2Ban,并将sammy
设置为生产环境所有者。
The configuration files created by the bench
command are:
bench
命令创建的配置文件为:
Two Nginx configuration files located at /etc/nginx/nginx.conf
and /etc/nginx/conf.d/frappe-bench.conf
位于/etc/nginx/nginx.conf
和/etc/nginx/conf.d/ frappe-bench .conf
两个Nginx配置文件
One Fail2Ban proxy jail located at /etc/fail2ban/jail.d/nginx-proxy.conf
and one filter located at /etc/fail2ban/filter.d/nginx-proxy.conf
其中的fail2ban代理监狱位于/etc/fail2ban/jail.d/nginx-proxy.conf
和一个过滤器位于/etc/fail2ban/filter.d/nginx-proxy.conf
These default configurations will suffice for this tutorial, but you should feel free to explore and adjust these files to match your requirements. You can stop all services by running:
这些默认配置足以满足本教程的要求,但是您应该随意浏览和调整这些文件以符合您的要求。 您可以通过运行以下命令停止所有服务:
And then, once you are ready, you can restart your services:
然后,一旦准备就绪,就可以重新启动服务:
Now you are ready to test your installation.
现在,您可以测试安装了。
First of all, verify that key production services are running. Use the following systemctl
command and then pipe it to grep
:
首先,验证关键生产服务正在运行。 使用以下systemctl
命令,然后将其通过管道传递给grep
:
You will see an output like this:
您将看到类似以下的输出:
Output
fail2ban.service enabled
nginx.service enabled
supervisor.service enabled
After confirming that everything is working as expected, you can test ERPNext 12 live on your server. Open your favorite browser and navigate your_domain, or whereever you are hosting your ERPNext 12 application.
确认一切正常后,您可以在服务器上实时测试ERPNext 12。 打开您喜欢的浏览器并导航your_domain或托管ERPNext 12应用程序的任何位置。
After a few seconds, you should see the ERPNext 12 login screen. Use Administrator for the username (email) and the erpnext_admin_password
you created previously for the password.
几秒钟后,您应该看到ERPNext 12登录屏幕。 使用管理员输入用户名(电子邮件)和您先前为密码创建的erpnext_admin_password
。
In the next screen you will see a dropdown menu where you can select the UI language for the application:
在下一个屏幕中,您将看到一个下拉菜单,您可以在其中选择应用程序的UI语言:
Following language selection, ERPNext will prompt you about your country, timezone, and currency:
选择语言后,ERPNext会提示您有关国家,时区和货币的信息:
Once you complete your region information, you will be able to create your first ERPNext user. The information you provide will be used as the user’s login credentials.
完成区域信息后,您将可以创建第一个ERPNext用户。 您提供的信息将用作用户的登录凭据。
In the next screen, you will be asked about what ERPNext calls Domains. If you are not sure what your domain is, then select Distribution and click the Next button.
在下一个屏幕中,系统将询问您有关ERPNext称为Domains的信息 。 如果不确定您的域是什么,请选择“ 分发” ,然后单击“ 下一步”按钮。
Next, you will need to provide a company name and abbreviation.
接下来,您需要提供公司名称和缩写。
On the last screen, ERPNext will ask you what your company does, its bank name, the type of charts of accounts, and the fiscal year period. You will be able to enter additional banks later. For now, fill in all the fields as you like and then click the Complete Setup button.
在最后一个屏幕上,ERPNext将询问您公司的工作,银行名称,会计科目表的类型以及会计年度。 您稍后可以输入其他银行。 现在,根据需要填写所有字段,然后单击“ 完成设置”按钮。
Next, you will see a progress bar.
接下来,您将看到一个进度条。
Once the setup process completes, the ERPNext 12 main Dashboard will appear.
设置过程完成后,将显示ERPNext 12主仪表板。
You now have fully installed and configured an ERPNext 12 application.
现在,您已经完全安装并配置了ERPNext 12应用程序。
Now that you have properly installed your ERPNext 12 application, you might want to start implementing the system for your business needs. A good starting point is clicking the Getting Started button on the ERPNext Dashboard. ERPNext will then help you configure the platform for all your business and e-commerce needs.
现在,您已经正确安装了ERPNext 12应用程序,您可能想要开始实施满足您业务需求的系统。 一个好的起点是单击ERPNext仪表板上的“ 入门”按钮。 然后,ERPNext将帮助您为所有业务和电子商务需求配置平台。
You may also wish to enhance ERPNext’s speed. If that is the case, then you can read about ERPNext performance tuning, which will guide you through best practices and how to debug performance-related issues.
您可能还希望提高ERPNext的速度。 如果是这种情况,那么您可以阅读有关ERPNext性能调优的信息 ,它将指导您完成最佳实践以及如何调试与性能相关的问题。
翻译自: https://www.digitalocean.com/community/tutorials/how-to-install-an-erpnext-stack-on-ubuntu-20-04