Tag Archives: Node.js

Node.js on Ubuntu 24.04

How to Install Node.js on Ubuntu 24.04

Node.js is a fast, open-source JavaScript runtime that lets you build scalable server-side and network applications.

It is known for its non-blocking, event-driven architecture, making it ideal for building scalable network applications like APIs, chat apps, and real-time services.

Ubuntu 24.04 offers several ways to install Node.js depending on your needs, whether you prefer stability or the latest features.

This blog post will guide you through three reliable methods to install Node.js on Ubuntu 24.04.

Method 1: Installing Node.js Using apt (Default Repository)

Ubuntu provides Node.js in its default repositories, but it may not be the latest version.

First, update the package list to ensure you have the latest repositories:

# apt update && sudo apt upgrade -y

Run the following command to install Node.js and npm:

# apt install nodejs npm -y

Verify the installed version of Node.js running the following command:

# node --version

You should see the following output:

v18.19.1

Verify the NPM version with the following command:

# npm --version

You should get the following output:

9.2.0

Method 2: Install Latest Node.js Using NodeSource

This method gives you access to the most recent versions of Node.js.

First, add the Node.js repository running the following command:

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

Once added, install the Node.js with the following command:

# apt-get install nodejs

Verify the installed version of Node.js running the following command:

# node --version

You should see the following output:

v22.14.0

Verify the NPM version with the following command:

# npm --version

You should get the following output:

10.9.2

Method 3: Install Node.js Using NVM (Node Version Manager)

Use this method if you want to install and manage multiple Node.js versions easily.

# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
# source ~/.bashrc

To install the latest LTS version:

# nvm install --lts

To install a specific version you can use the following command:

# nvm install 20

Replace “20″ with the version number of Node.js you want to install.

Comments and Conclusion

Installing Node.js on Ubuntu 24.04 is straightforward with multiple flexible options:

  • Use apt for a quick setup
  • Use NodeSource for the latest stable versions
  • Use NVM for full control over Node.js versions

Now that Node.js is installed, you’re ready to start building apps and tools in JavaScript.

For additional help or useful information, we recommend you to check  the official Node.js documentation.

If you have any questions please leave a comment below.

How to Install Odoo 18 on Ubuntu 24.04

Odoo 18 is an open-source suite of business applications that provides a complete ERP (Enterprise Resource Planning) solution for organizations of various sizes. It offers a wide range of integrated tools and modules to help manage all aspects of a business, such as finance, sales, inventory, human resources, and more.

The open-source community edition is free, making it accessible to small businesses and developers. The enterprise edition, on the other hand, offers additional features, services, and support.

Odoo is highly customizable. Businesses can tailor modules to meet their specific needs, create custom workflows, or build entirely new apps using Odoo’s development framework.

In summary, Odoo is a versatile business management software that can streamline operations and provide real-time insights, making it an ideal solution for companies looking to optimize their business processes.

In this tutorial, we will show you how to install Odoo 18 on a Ubuntu 24.04 OS.

Step 1: Update Operating System

Update your Ubuntu 24.04 operating system to make sure all existing packages are up to date:

# apt update && apt upgrade

Then install all the required packages for the Odoo 18 setup on the Ubuntu 24.04 OS.

# apt install python3-minimal python3-dev python3-pip python3-venv python3-setuptools build-essential libzip-dev libxslt1-dev libldap2-dev python3-wheel libsasl2-dev node-less libjpeg-dev xfonts-utils libpq-dev libffi-dev fontconfig git wget

Step 2: Install PostgreSQL

Odoo uses PostgreSQL as a database backend, so you will need to install PostgreSQL on your server.

Follow these steps to install and configure PostgreSQL server:

# apt-get install postgresql

After the successful installation, start the PostgreSQL service and enable it to start after the system reboot:

# systemctl start postgresql
# systemctl enable postgresql

Verify that is active and running on your server:

# systemctl status postgresql
Output
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: enabled)
     Active: active (exited)
   Main PID: 19754 (code=exited, status=0/SUCCESS)
        CPU: 2ms

Now create an Odoo user in PostgreSQL:

# su - postgres -c "createuser -s odoo" 

This will add a new role odoo in the PostgreSQL server.

Step 3: Install Node.js

To install Node.js and npm on your Ubuntu 24.04 OS use the following command:

# apt install nodejs npm

Also, install the following module to enable RTL support:

# npm install -g rtlcss

Step 4: Installation of wkhtmltopdf

To generate PDF reports successfully, wkhtmltopdf is necessary. PDF reports are a crucial component of any organization.

First install the xfonts dependency before installing wkhtmltopdf:

# apt-get install xfonts-75dpi xfonts-base

Now download and install wkhtmltopdf using the following commands:

# wget  http://security.ubuntu.com/ubuntu/pool/universe/w/wkhtmltopdf/wkhtmltopdf_0.12.6-2build2_amd64.deb
# dpkg -i wkhtmltopdf_0.12.6-2build2_amd64.deb

Verify if the wkhtmltopdf installation is successful by checking the version:

# wkhtmltopdf --version
wkhtmltopdf 0.12.6

Step 5: Create an Odoo User

Create a new system user for managing the Odoo processes on the Odoo server.

# adduser --system --group --home=/opt/odoo --shell=/bin/bash odoo

Step 6: Install Odoo 18

Switch to the user that you have created before to avoid encountering issues related to access rights.

# su - odoo

Now, download the Odoo 17 source code from the git repository and install it:

# git clone https://www.github.com/odoo/odoo --depth 1 --branch 18.0 /opt/odoo/odoo

Next run the following command to generate a new Python virtual environment.

# python3 -m venv odoo-env

Activate the virtual environment with the following command:

# source odoo-env/bin/activate

Then install the required Python packages:

(odoo-env) $ pip3 install wheel
(odoo-env) $ pip3 install -r odoo/requirements.txt

After completing the process of installing all requirements to deactivate the virtual environment run the following command:

(odoo-env) $ deactivate

Execute the following command to create a directory for custom addons:

# mkdir /opt/odoo/custom-addons

Next exit from the Odoo user:

# exit

Create an Odoo log directory and provide it the required write permissions.

# mkdir /var/log/odoo18
# chown odoo:odoo /var/log/odoo18

Step 7: Create Odoo Configuration File

Create the Odoo configuration file.

# nano /etc/odoo.conf

Then paste the following configuration into it.

[options]
admin_passwd = Strong_admin_Password
db_host = False
db_port = False
db_user = odoo
db_password = False
logfile = /var/log/odoo18/odoo-server.log
addons_path = /opt/odoo/odoo/addons,/opt/odoo/custom-addons
xmlrpc_port = 8069

Remember to update the value of the “Strong_admin_Password” key above with a more secure password.

Step 8: Create a Systemd Service File

Create a systemd service file to manage the Odoo service:

# nano /etc/systemd/system/odoo.service

Paste the following content into the odoo.service file:

[Unit]
Description=Odoo
Requires=postgresql.service
After=network.target postgresql.service

[Service]
Type=simple
SyslogIdentifier=odoo
PermissionsStartOnly=true
User=odoo
Group=odoo
ExecStart=/opt/odoo/odoo-env/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

Reload system daemon and start the service:

# systemctl daemon-reload
# systemctl start odoo
# systemctl enable odoo

To confirm everything is working normally, check the status of service:

# systemctl status odoo

Output:

● odoo.service - Odoo
     Loaded: loaded (/etc/systemd/system/odoo.service; enabled; preset: enabled)
     Active: active (running)
   Main PID: 21764 (python3)
      Tasks: 4 (limit: 2218)
     Memory: 73.3M (peak: 73.5M)
        CPU: 973ms
     CGroup: /system.slice/odoo.service
             └─21764 /opt/odoo/odoo-env/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf

Step 9: Access Odoo 18 server

Open your web browser and type http://your-IP-address:8069 and you will see the following screen:

Comments and Conclusion

That’s it. You have successfully installed Community version of Odoo 18 on Ubuntu 24.04.

For additional help or useful information, we recommend you to check  the official Odoo 18 documentation.

If you have any questions please leave a comment below.

How to Install Strapi with Nginx on Debian 12

Strapi is a most advanced open source content management system (CMS) designed to help developers to build powerful API.

Strapi follows a “headless” architecture, which means it separates the content management backend from the frontend presentation, giving developers the freedom to use various technologies and frameworks on the frontend.

In this tutorial, we will show you how to install Strapi on Debian 12 OS.

Step 1: Update Operating System

Update your Debian 12 operating system to make sure all existing packages are up to date:

# apt update && apt upgrade

Step 2: Install Nginx webserver

You can install Nginx via apt package manager by executing the following command.

# apt install nginx

You can start the Nginx service and configure it to run on startup by entering the following commands:

# systemctl start nginx
# systemctl enable nginx

Verify the status of the Nginx service using systemctl status command:

# systemctl status nginx

Output:

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:nginx(8)
    Process: 627 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 646 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 655 (nginx)
      Tasks: 2 (limit: 2273)
     Memory: 3.8M
        CPU: 27ms
     CGroup: /system.slice/nginx.service
             ├─655 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─656 "nginx: worker process"

Step 3: Install Node.js

Strapi is based on Node.js, for that reason, you need to have Node.js installed on your server.

To install Node.js and npm on your Debian OS use the following command:

# apt install nodejs npm

You can verify the Node.js version with the following command:

# node --version

You should see the following output:

v18.13.0

Also, verify the npm version with the following command:

# npm --version

You should get the following output:

9.2.0

Step 4: Install PostgreSQL

Strapi uses PostgreSQL as a database backend, so you will need to install PostgreSQL on your server.

You can run the following command to install the PostgreSQL server:

# apt-get install postgresql-15

After the successful installation, start the PostgreSQL service and enable it to start after the system reboot:

# systemctl start postgresql
# systemctl enable postgresql

Verify that is active and running on your server:

# systemctl status postgresql
Output
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; preset: enabled)
     Active: active (exited)
   Main PID: 13153 (code=exited, status=0/SUCCESS)
        CPU: 1ms

Next, connect to the PostgreSQL shell:

# su postgres
# psql

Then, we create the Strapi database:

postgres=# CREATE DATABASE strapidb; 
postgres=# CREATE USER strapi WITH PASSWORD 'Your-Strong-Password'; 
postgres=# GRANT ALL PRIVILEGES ON DATABASE strapidb to strapi; 
postgres=# \q

Return to your root user account.

# exit

Step 5: Create a Strapi Application

Once PostgreSQL and Node.js have been installed, we can proceed to install Strapi.

You can use the npx command line utility to easily create a Strapi app.

# cd /opt
# npx create-strapi-app@latest strapi --no-run

You will see the following output.

Need to install the following packages:
  create-strapi-app@4.12.1
Ok to proceed? (y) y

Proceed with the creation by pressing y.

In the interactive shell, select custom installation then your database client, database name and user name as provisioned.

? Choose your installation type Custom (manual settings)
? Choose your preferred language JavaScript
? Choose your default database client postgres
? Database name: strapidb
? Host: 127.0.0.1
? Port: 5432
? Username: strapi
? Password: ********************
? Enable SSL connection: No

Next, navigate to the strapi directory and build the application with the following command.

# cd strapi
# npm run build

Output:

> strapi@0.1.0 build
> strapi build

Building your admin UI with development configuration...

✔ Webpack
  Compiled successfully in 1.12m

Admin UI built successfully

Then run Strapi in development mode.

# npm run develop

If everything is fine, you will get the following output.


Press the CTRL+C to stop the application.

Step 6: Run Strapi with PM2

In this step we will describe you to how to run Strapi app with PM2 command. PM2 is a Production Process Manager for Node.js applications.

First, install PM2 application by running the following command:

# npm install pm2@latest -g

Now create a pm2 ecosystem file which is where you can setup some environment variables for each pm2 app you want to install and run.

# nano /root/ecosystem.config.js

Paste the following content in the file.

module.exports = {
  apps: [
    {
      name: 'strapi',
      cwd: '/opt/strapi',
      script: 'npm',
      args: 'start',
      env: {
        NODE_ENV: 'production',
        DATABASE_HOST: 'localhost',
        DATABASE_PORT: '5432',
        DATABASE_NAME: 'strapidb',
        DATABASE_USERNAME: 'strapi',
        DATABASE_PASSWORD: 'Your-Strong-Password'
      },
    },
  ]
};

Note: /opt/strapi is the path to your project, you are required to replace this with your own path before you proceed.

Once modified, save the file then start the app in the background with the command:

# pm2 start /root/ecosystem.config.js

You can see that the status of the app is set to online.

# pm2 list

To allow the app to start automatically on boot, use the command:

# pm2 startup -u root

Save the process:

# pm2 save

Your Strapi service is now running in the background in production mode.

Step 7: Configure Nginx for Strapi

Create a new Nginx virtual host configuration file.

# nano /etc/nginx/conf.d/strapi.conf

Add the following configurations:

upstream strapi {
server 127.0.0.1:1337;
}

server {

listen 80;
server_name your-domain.com www.your-domain.com;

location / {
        proxy_pass http://strapi;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass_request_headers on;
      }
}

Save and close the file, then edit the Nginx main configuration file.

# nano /etc/nginx/nginx.conf

Add the following line after the line http{: but before the line include /etc/nginx/conf.d/*.conf;.

server_names_hash_bucket_size 64;

Save the file, then verify the Nginx configuration.

# /usr/sbin/nginx -t

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

Restart the Nginx service to implement the changes.

# systemctl restart nginx

Step 8: Access Strapi Web Interface

Now, open your web browser and access the Strapi web UI using the URL http://your-domain.com/admin. You should see the Strapi default page:

Then click on the Let’s start button. You should see the Strapi dashboard:

Comments and Conclusion

Congratulations. You have learned how to install Strapi on Debian 12 OS. You can now create your own application easily using Strapi.

For additional help or useful information, we recommend you to check  the official Strapi documentation.

How to Install Vue.js on Ubuntu 22.04

Vue.js is a popular open-source JavaScript framework used for building user interfaces and single-page applications. It was created by Evan You and was first released in February 2014. Vue.js is a progressive framework, meaning it can be adopted incrementally as needed, allowing developers to start small and add more functionality as needed. Vue.js provides a reactive and composable system for building user interfaces, which makes it a popular choice for creating modern web applications.

In this tutorial, we will show you how to install Vue.js on Ubuntu 22.04 OS.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to make sure all existing packages are up to date:

# apt update && sudo apt upgrade -y

Step 2: Install Node.js

Vue.js is built on top of Node.js, so we need to install it first.

The Node.js version included in the default Ubuntu 22.04 repositories is v12.22.9 which is an older LTS version.

We’ll install Node.js version 18.x LTS on our Ubuntu OS.

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

After the repository is added successfully, run the following command to install Node.js:

# apt install nodejs

You can verify the installation by running the following command:

# node --version

You should see the version number of Node.js installed on your system:

v18.14.1

The next step is to update the npm version:

# npm install npm@latest -g

Verify the npm version with the following command:

# npm --version

You should get the following output:

9.5.0

Step 3: Install Vue CLI on Ubuntu 22.04

Vue CLI is a command-line interface for building and scaffolding Vue.js projects.

Run the following command to install Vue CLI globally:

# npm install -g @vue/cli

Verify the Vue CLI installation by running the following command:

# vue --version

You should see the version number of Vue CLI installed on your system:

@vue/cli 5.0.8

Step 4: Create Vue.js Application

Now that we have installed Node.js and Vue CLI, we can create a Vue.js application.

You can create a Vue.js project run the following command:

# vue create linuxtuto-project

Sample Output:

You can accept the default options or customize them as needed.

Next, change the directory to the Vue.js application:

# cd linuxtuto-project

Once you are in the project folder you can start Vue.js application in development mode with the following command:

# npm run serve

By default the Vue.js  application start on port 8080.

Open your favorite browser and enter the URL http://your-IP-address:8080 to access your Vue.js application.

You should see the default Vue.js welcome page.

Conclusion

Congratulations. You have learned how to Install Vue.js and create a sample app on Ubuntu 22.04. Whether you’re a beginner or an experienced developer, Vue.js is a great choice for building web applications.

In order to get more information on this topic you can visiting the official website of Vue.js.