Categories

Thursday, January 9, 2025
#919814419350 therichposts@gmail.com
Medusajs

How to install medusa in ubuntu server?

How to install medusa in ubuntu server?

Hello guys how are you? Welcome back on my blog Therichpost. Today in this post I am going to share How to install medusa in ubuntu server?

If you are new then you must check below two links:

Now guys here is the complete code snippet and please follow carefully:

Installing Medusa (an open-source content management system) on an Ubuntu server typically involves the following steps:


Step 1: Update System Packages

Before starting, ensure your system is up-to-date:

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js and npm

Medusa requires Node.js (version 16.x or later). Install it as follows:

  1. Add the Node.js repository:
   curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
  1. Install Node.js:
   sudo apt install -y nodejs
  1. Verify the installation:
   node -v
   npm -v

Step 3: Install PostgreSQL

Medusa uses PostgreSQL as the database. Install it with:

sudo apt install -y postgresql postgresql-contrib

Set up a database and user:

  1. Switch to the postgres user:
   sudo -i -u postgres
  1. Access the PostgreSQL shell:
   psql
  1. Create a database and user:
   CREATE DATABASE medusa;
   CREATE USER medusauser WITH ENCRYPTED PASSWORD 'yourpassword';
   GRANT ALL PRIVILEGES ON DATABASE medusa TO medusauser;
   \q
  1. Exit the postgres user:
   exit

Step 4: Install Redis

Medusa requires Redis for caching:

sudo apt install -y redis

Start and enable Redis:

sudo systemctl start redis
sudo systemctl enable redis

Step 5: Install Medusa CLI

Install the Medusa CLI globally:

npm install -g @medusajs/medusa-cli

Step 6: Create a New Medusa Project

Create a new Medusa project in a directory of your choice:

medusa new my-medusa-store
cd my-medusa-store

Step 7: Configure Environment Variables

Edit the .env file to configure your PostgreSQL and Redis settings:

nano .env

Update the following variables:

DATABASE_URL=postgres://medusauser:yourpassword@localhost:5432/medusa
REDIS_URL=redis://localhost:6379

Save and exit the file.


Step 8: Run Database Migrations

Run the database migrations to set up the database schema:

medusa migrations run

Step 9: Start the Medusa Server

Start the Medusa server in development mode:

npm run start

For production, use:

NODE_ENV=production npm run start

Step 10: Access Medusa

The Medusa server will typically run on http://localhost:9000. If you’re using a remote server, replace localhost with the server’s IP address.


Optional: Install Admin Panel

For managing your store, you can use the Medusa Admin Panel:

  1. Follow the guide here.
  2. Connect it to your Medusa backend.

Let me know if you face any issues during the setup! Please contact me I am full time freelancer.

Ajay

Thanks

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.