在本页
- 先决条件
- 安装 LAMP 服务器
- 配置 MariaDB
- 安装 webERP
- 为 webERP 配置 Apache
- 使用 Let's Encrypt SSL 保护 webERP
- 配置防火墙
- 访问 webERP Web 界面
- 结论
webERP 是一个免费、开源且完整的基于 Web 的会计和业务管理系统。你只需要一个 Web 浏览器和 PDF 阅读器即可使用 webERP。借助 webERP,你可以管理许多事项,包括采购订单、Web 商店、制造、销售、总账和货运。它用 PHP 编写,并使用 MariaDB 作为数据库后端。本教程将向你展示如何在 CentOS 8 上使用 Apache 和 Let's Encrypt SSL 安装 webERP。
先决条件
- 一台运行 CentOS 8 的服务器。
- 一个指向你服务器 IP 的有效域名。
- 服务器上配置了 root 密码。
安装 LAMP 服务器
首先,使用以下命令安装 Apache、MariaDB、PHP 和其他 PHP 扩展:
dnf install httpd mariadb-server php php-mysqli php-curl php-json php-cgi php-xmlrpc php-gd php-mbstring unzip -y
所有软件包安装完成后,使用以下命令启动 Apache 和 MariaDB 服务,并使其在系统重启时启动:
systemctl start httpd mariadb
systemctl enable httpd mariadb
完成后,你可以继续执行下一步。
配置 MariaDB
接下来,你需要设置 MariaDB root 密码并保护 MariaDB 安装。你可以使用以下命令来完成:
mysql_secure_installation
如下所示回答所有问题:
Enter current password for root (enter for none): Set root password? [Y/n] Y New password: Re-enter new password: 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 All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
接下来,使用以下命令登录 MariaDB shell:
mysql -u root -p
连接后,使用以下命令为 webERP 创建数据库和用户:
MariaDB [(none)]> create database weberp;
MariaDB [(none)]> create user weberp@localhost identified by 'password';
接下来,使用以下命令授予 webERP 数据库所有权限:
MariaDB [(none)]> grant all privileges on weberp.* to weberp@localhost identified by 'password';
接下来,使用以下命令刷新权限并退出 MariaDB:
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
完成后,你可以继续执行下一步。
安装 webERP
首先,使用以下命令下载最新版本的 webERP:
wget https://sourceforge.net/projects/web-erp/files/webERP_4.15.zip
下载完成后,使用以下命令将下载的文件解压到 Apache Web 根目录:
unzip webERP_4.15.zip -d /var/www/html
接下来,使用以下命令设置适当的权限和所有权:
chown -R apache:apache /var/www/html/webERP
chmod -R 755 /var/www/html/webERP
完成后,你可以继续执行下一步。
为 webERP 配置 Apache
接下来,你需要创建一个新的 Apache 虚拟主机配置文件来托管 webERP。你可以使用以下命令创建它:
nano /etc/httpd/conf.d/weberp.conf
添加以下行:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/webERP ServerName weberp.example.com <Directory /var/www/html/webERP/> Options FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/httpd/weberp.org-error_log CustomLog /var/log/httpd/weberp.org-access_log common </VirtualHost>
完成后保存并关闭文件。接下来,重启 Apache 服务以应用更改:
systemctl restart httpd
现在,使用以下命令验证 Apache 的状态:
systemctl status httpd
你应该会得到以下输出:
? httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
??php-fpm.conf
Active: active (running) since Sat 2021-05-01 05:57:27 EDT; 13s ago
Docs: man:httpd.service(8)
Main PID: 4896 (httpd)
Status: "Running, listening on: port 80"
Tasks: 213 (limit: 25014)
Memory: 24.8M
CGroup: /system.slice/httpd.service
??4896 /usr/sbin/httpd -DFOREGROUND
??4898 /usr/sbin/httpd -DFOREGROUND
??4899 /usr/sbin/httpd -DFOREGROUND
??4900 /usr/sbin/httpd -DFOREGROUND
??4901 /usr/sbin/httpd -DFOREGROUND
May 01 05:57:27 centos8 systemd[1]: Stopped The Apache HTTP Server.
May 01 05:57:27 centos8 systemd[1]: Starting The Apache HTTP Server...
此时,Apache Web 服务器已配置为托管 webERP。你现在可以继续下一步。
使用 Let's Encrypt SSL 保护 webERP
接下来,你需要安装 Certbot 客户端,以便为 webERP 安装 Let's Encrypt SSL。你可以使用以下命令安装它:
dnf install letsencrypt python3-certbot-apache
接下来,使用以下命令为你的域名获取并安装 SSL 证书:
certbot --apache -d weberp.example.com
系统会要求你提供电子邮件地址并接受服务条款:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator apache, Installer apache 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. Do you agree? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing, once your first certificate is successfully issued, 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 Account registered. Requesting a certificate for weberp.example.com Performing the following challenges: http-01 challenge for weberp.example.com Waiting for verification. Cleaning up challenges Deploying Certificate to VirtualHost /etc/httpd/conf.d/weberp.conf Redirecting all traffic on port 80 to ssl in /etc/httpd/conf.d/weberp.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://weberp.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Subscribe to the EFF mailing list (email: [email protected] ). IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/weberp.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/weberp.example.com/privkey.pem Your certificate will expire on 2021-06-09. 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
你现在可以使用 URL https://weberp.example.com 安全地访问你的网站。
配置防火墙
接下来,你需要通过防火墙允许端口 80 和 443。你可以使用以下命令允许它们:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
接下来,重新加载防火墙以应用更改:
firewall-cmd --reload
访问 webERP Web 界面
现在,打开你的 Web 浏览器,使用 URL https://weberp.example.com 访问 webERP Web 界面。你应该会看到以下页面:

选择你的语言并点击 NEXT STEP。你应该会看到以下页面:

提供你的数据库名称、用户、密码并点击 NEXT STEP。你应该会看到以下页面:


提供你的公司名称、时区、管理员用户名、密码并点击 INSTALL 按钮。安装完成后,你应该会看到以下页面:

提供你的管理员用户名、密码并点击 Login 按钮。你将被重定向到 webERP 仪表板:

结论
恭喜!你已在 CentOS 8 上使用 Apache 和 Let's Encrypt SSL 成功安装了 webERP。你现在可以探索 webERP 的更多功能,并将它们应用到你的生产环境中。