如何在 Ubuntu 18.04 LTS 上安装 Cezerin 电子商务平台如何在 Ubuntu 18.04 LTS 上安装 Cezerin 电子商务平台如何在 Ubuntu 18.04 LTS 上安装 Cezerin 电子商务平台如何在 Ubuntu 18.04 LTS 上安装 Cezerin 电子商务平台
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何在 Ubuntu 18.04 LTS 上安装 Cezerin 电子商务平台

在此页

  1. 要求
  2. 开始
  3. 安装 Node.js
  4. 安装 MongoDB
  5. 安装 Cezerin
  6. 将 Nginx 配置为反向代理
  7. 为 Cezerin 创建一个 Systemd 服务文件
  8. 结论

Cezerin 是一个免费、开源、基于 React 和 Node.js 的电子商务平台,可用于创建渐进式 Web 应用程序。它是一个具有 SEO 友好和服务器端呈现的单页电子商务应用程序。它提供了许多功能,例如产品类别、库存和库存管理、文件管理器、将主题导出到 zip 存档、从 zip 存档安装主题、支付网关、无密码等等。

在本教程中,我们将解释如何在 Ubuntu 18.04 LTS 上安装 Cezerin。

要求

  • 一台运行 Ubuntu 18.04 的服务器。
  • 在您的服务器上设置了根密码。
  • 在您的服务器上配置了静态 IP 地址 192.168.0.4

入门

首先,您需要使用最新版本更新您的服务器。您可以使用以下命令执行此操作:

apt-get update -y
apt-get upgrade -y

服务器更新后,重新启动它以应用所有更改:

安装 Node.js

接下来,您需要将最新版本的 Node.js 安装到您的服务器。默认情况下,最新版本的 Node.js 在 Ubuntu 18.04 默认存储库中不可用。因此,您需要将 Node.js 存储库添加到您的系统。

您可以使用以下命令添加 Node.js 存储库:

curl -sL https://deb.nodesource.com/setup_12.x | bash -

添加存储库后,使用以下命令安装 Node.js 和其他所需的包:

apt-get install nodejs build-essential -y

接下来,使用以下命令检查 Node.js 的版本:

node -v

您应该看到以下输出:

v12.5.0

使用以下命令检查 NPM 版本:

npm -v

您应该看到以下输出:

6.9.0

完成后,您可以继续安装 MongoDB。

安装 MongoDB

默认情况下,MongoDB 在 Ubuntu 18.04 默认存储库中不可用。因此,您需要将 MongoDB 存储库添加到您的系统中。

首先,使用以下命令导入 MongoDB GPG 密钥:

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

您应该看到以下输出:

Executing: /tmp/apt-key-gpghome.noPsOh3sgA/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
gpg: key 68818C72E52529D4: public key "MongoDB 4.0 Release Signing Key <>" imported
gpg: Total number processed: 1
gpg:               imported: 1

接下来,使用以下命令添加 MongoDB 存储库:

echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list

接下来,更新存储库并使用以下命令安装 MongoDB:

apt-get update -y
apt-get install mongodb-org -y

安装 MongoDB 后,使用以下命令启动 MongoDB 服务:

service mongod start

您还可以使用以下命令检查 MongoDB 的状态:

service mongod status

您应该看到以下输出:

? mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-07-03 08:57:58 UTC; 7s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 14712 (mongod)
   CGroup: /system.slice/mongod.service
           ??14712 /usr/bin/mongod --config /etc/mongod.conf

Jul 03 08:57:58 ubuntu1804 systemd[1]: Started MongoDB Database Server

完成后,您可以继续安装 Cezerin。

安装 Cezerin

首先,您需要从 Github 存储库下载最新版本的 Cezerin。您可以使用以下命令下载它:

cd /opt
git clone https://github.com/cezerin/cezerin.git

接下来,将目录更改为 cezerin 并使用以下命令安装所有必需的依赖项:

cd /opt/cezerin
npm update node-sass
npm install --unsafe-perm --allow-root
npm run build
npm run setup

安装所有必需的依赖项后,使用以下命令启动服务器:

npm start

服务器成功启动后,您应该会看到以下输出:

>  start /opt/cezerin
> concurrently npm:start-*

[start-api] 
[start-api] >  start-api /opt/cezerin
[start-api] > node -r esm src/api/server/index.js
[start-api] 
[start-store] 
[start-store] >  start-store /opt/cezerin
[start-store] > node -r esm dist/store/server/index.js
[start-store] 
[start-api] info: API running at http://localhost:3001
[start-api] info: MongoDB connected successfully
[start-store] info: Store running at http://localhost:3000

Cezerin 现已安装并在端口 3000 上运行。现在,打开 Web 浏览器并输入 URL http://192.168.0.4:3000。您将被重定向到 Cezerin 默认仪表板,如下页所示:

配置 Nginx 作为反向代理

默认情况下,Cezerin 运行在 3000 端口。因此您需要将 Nginx 配置为反向代理以使用端口 80 访问 Cezerin。

为此,首先使用以下命令安装 Nginx:

apt-get install nginx -y

安装 Nginx 后,使用以下命令为 Cezerin 创建一个新的 Nginx 虚拟主机文件:

nano /etc/nginx/sites-available/cezerin.conf

添加以下行:

upstream cezerin {
  server 127.0.0.1:3000 weight=100 max_fails=5 fail_timeout=5;
}

server {
  listen          80;
  server_name     192.168.0.4;

  location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://cezerin/;
  }
}

完成后保存并关闭文件。然后,使用以下命令启用虚拟主机:

ln -s /etc/nginx/sites-available/cezerin.conf /etc/nginx/sites-enabled/

接下来,使用以下命令检查 Nginx 是否存在任何配置错误:

nginx -t

如果一切正常,您应该会看到以下输出:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

最后,重新启动 Nginx 服务以应用我们使用以下命令所做的所有更改:

systemctl restart nginx

为 Cezerin 创建系统服务文件

接下来,您需要创建一个 systemd 服务文件来管理 Cezerin 服务。您可以使用以下命令执行此操作:

nano /etc/systemd/system/cezerin.service

添加以下行:

[Unit]
Description=Cezerin Server

[Service]
ExecStart=/usr/bin/npm start
# Required on some systems
WorkingDirectory=/opt/cezerin
Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=10
# Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs-example

[Install]
WantedBy=multi-user.target

完成后保存并关闭文件。然后,使用以下命令重新加载配置文件:

systemctl daemon-reload

接下来,启动 Cezerin 服务并使用以下命令使其在启动时启动:

systemctl start cezerin
systemctl enable cezerin

您还可以使用以下命令检查 Cezerin 服务的状态:

systemctl status cezerin

您应该看到以下输出:

? cezerin.service - Cezerin Server
   Loaded: loaded (/etc/systemd/system/cezerin.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-07-03 09:51:29 UTC; 11s ago
 Main PID: 18516 (npm)
    Tasks: 43 (limit: 1114)
   CGroup: /system.slice/cezerin.service
           ??18516 npm
           ??18538 sh -c concurrently npm:start-*
           ??18541 node /opt/cezerin/node_modules/.bin/concurrently npm:start-*
           ??18550 /bin/sh -c npm run start-api
           ??18551 npm
           ??18557 /bin/sh -c npm run start-store
           ??18559 npm

Jul 03 09:51:29 ubuntu1804 systemd[1]: Stopped Cezerin Server.
Jul 03 09:51:29 ubuntu1804 systemd[1]: Started Cezerin Server.
Jul 03 09:51:33 ubuntu1804 nodejs-example[18516]: >  start /opt/cezerin
Jul 03 09:51:33 ubuntu1804 nodejs-example[18516]: > concurrently npm:start-*

就是这样!您现在可以使用 URL http://192.168.0.4 访问您的 Cezerin Web 界面。

结论

恭喜!您已在 Ubuntu 18.04 服务器上成功安装和配置 Cezerin。您现在可以使用 Cezerin 轻松托管自己的在线商店。如果您有任何问题,请随时问我。

©2015-2025 艾丽卡 support@alaica.com