How to Install Cezerin eCommerce platform on Ubuntu 18.04 LTS
Cezerin is a free, open-source, React and Node.js based eCommerce platform that can be used for creating a Progressive Web Apps. It is a single page e-commerce application with SEO friendly and server-side rendering. It provides lots of features such as Product categories, Inventory and stock management, File manager, Export themes to zip archive, Install a theme from zip archive, Payment Gateways, Passwordless and many more.
In this tutorial, we will explain how to install Cezerin on Ubuntu 18.04 LTS.
Requirements
- A server running Ubuntu 18.04.
- A root password is setup on your server.
- A static IP address 192.168.0.4 is configured on your server
Getting Started
First, you will need to update your server with the latest version. You can do it with the following command:
apt-get update -y
apt-get upgrade -y
Once your server is updated, restart it to apply all the changes:
Install Node.js
Next, you will need to install the latest version of Node.js to your server. By default, the latest version of Node.js is not available in the Ubuntu 18.04 default repository. So, you will need to add Node.js repository to your system.
You can add the Node.js repository with the following command:
curl -sL https://deb.nodesource.com/setup_12.x | bash -
Once the repository is added, install Node.js with other required package with the following command:
apt-get install nodejs build-essential -y
Next, check the version of Node.js with the following command:
node -v
You should see the following output:
v12.5.0
Check the NPM version with the following command:
npm -v
You should see the following output:
6.9.0
Once you finished, you can proceed to install MongoDB.
Install MongoDB
By default, MongoDB is not available in the Ubuntu 18.04 default repository. So you will need to add the MongoDB repository to your system.
First, import the MongoDB GPG key with the following command:
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
You should see the following output:
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 <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
Next, add the MongoDB repository with the following command:
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
Next, update the repository and install MongoDB with the following command:
apt-get update -y
apt-get install mongodb-org -y
Once the MongoDB has been installed, start the MongoDB service with the following command:
service mongod start
You can also check the status of MongoDB with the following command:
service mongod status
You should see the following output:
? 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
Once you have finished, you can proceed to install Cezerin.
Install Cezerin
First, you will need to download the latest version of Cezerin from the Github repository. You can download it with the following command:
cd /opt
git clone https://github.com/cezerin/cezerin.git
Next, change the directory to the cezerin and install all the required dependencies with the following command:
cd /opt/cezerin
npm update node-sass
npm install --unsafe-perm --allow-root
npm run build
npm run setup
Once all the required dependencies have been installed, start the server with the following command:
npm start
Once the server started successfully, you should see the following output:
> [email protected] start /opt/cezerin
> concurrently npm:start-*
[start-api] > node -r esm src/api/server/index.js
[start-api] [start-store] [start-store] > [email protected] 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 is now installed and running on port 3000. Now, open your web browser and type the URL http://192.168.0.4:3000. You will be redirected to the Cezerin default dashboard as shown in the following page:
Configure Nginx as a Reverse Proxy
By default, Cezerin runs on port 3000. So you will need to configure Nginx as a reverse proxy to access Cezerin using port 80.
To do so, first install Nginx with the following command:
apt-get install nginx -y
Once the Nginx has been installed, create a new Nginx virtual host file for Cezerin with the following command:
nano /etc/nginx/sites-available/cezerin.conf
Add the following lines:
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/;
}
}
Save and close the file, when you are finished. Then, enable the Virtual host with the following command:
ln -s /etc/nginx/sites-available/cezerin.conf /etc/nginx/sites-enabled/
Next, check the Nginx for any configuration error with the following command:
nginx -t
If everything is fine, you should see the following output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Finally, restart the Nginx service to apply all the changes we have made with the following command:
systemctl restart nginx
Create a Systemd Service File for Cezerin
Next, you will need to create a systemd service file to manage Cezerin service. You can do this with the following command:
nano /etc/systemd/system/cezerin.service
Add the following lines:
[Unit]
Description=Cezerin Server
# 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
Save and close the file, when you are finished. Then, reload the configuration file with the following command:
systemctl daemon-reload
Next, start the Cezerin service and enable it to start on boot time with the following command:
systemctl start cezerin
systemctl enable cezerin
You can also check the status of Cezerin service with the following command:
systemctl status cezerin
You should see the following output:
? 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]: > [email protected] start /opt/cezerin
Jul 03 09:51:33 ubuntu1804 nodejs-example[18516]: > concurrently npm:start-*
That’s it! you can now access your Cezerin web interface using the URL http://192.168.0.4.
Conclusion
Congratulations! you have successfully installed and configured Cezerin on Ubuntu 18.04 server. You can now easily host your own online store using Cezerin. Feel free to ask me if you have any questions.
Đăng ký liền tay Nhận Ngay Bài Mới
Subscribe ngay
Cám ơn bạn đã đăng ký !
Lỗi đăng ký !
Add Comment