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:
- Add the Node.js repository:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
- Install Node.js:
sudo apt install -y nodejs
- 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:
- Switch to the
postgres
user:
sudo -i -u postgres
- Access the PostgreSQL shell:
psql
- Create a database and user:
CREATE DATABASE medusa; CREATE USER medusauser WITH ENCRYPTED PASSWORD 'yourpassword'; GRANT ALL PRIVILEGES ON DATABASE medusa TO medusauser; \q
- 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:
- Follow the guide here.
- 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
Recent Comments