FarrosFR

Back

Installing Gemini CLI on VPS the Right WayBlur image

Installing Gemini CLI on a VPS is straightforward — until it isn’t.
Most people stop at npm install -g, but on many VPS setups (especially with aaPanel or custom Node builds), the binary won’t be available globally.

This guide shows how to install it properly so you can simply type:

gemini
bash

And it just works.

1. Install Node.js (If Not Installed)#

Check your Node version:

node -v
npm -v
bash

If you’re using aaPanel, Node is usually located under:

/www/server/nodejs/
bash

2. Install Gemini CLI Globally#

Run:

npm install -g @google/gemini-cli
bash

After installation, verify where global packages are installed:

npm root -g
npm config get prefix
bash

Example output:

/www/server/nodejs/v20.18.1
bash

That means the binary is located at:

/www/server/nodejs/v20.18.1/bin
bash

3. Fix the PATH (Critical Step)#

On many VPS environments, that directory is NOT included in $PATH.

Without fixing this, you’ll get:

gemini: command not found
bash

Temporary Fix#

export PATH=$PATH:/www/server/nodejs/v20.18.1/bin
bash

Permanent Fix#

Edit your shell profile:

nano ~/.bashrc
bash

Add:

export PATH=$PATH:/www/server/nodejs/v20.18.1/bin
bash

Reload:

source ~/.bashrc
bash

Now test:

gemini
bash

If everything is correct, the CLI should launch immediately.

4. Authenticate with Gemini#

Run:

gemini /auth
bash

Or set your API key manually:

export GEMINI_API_KEY=your_api_key_here
bash

To persist it:

nano ~/.bashrc
bash

Add:

export GEMINI_API_KEY=your_api_key_here
bash

Reload:

source ~/.bashrc
bash

Why PATH Matters (Opinionated Take)#

Most “installation guides” stop after npm install -g.
But on real production VPS environments, especially with custom Node paths, that’s incomplete.

If you cannot run a tool globally with a single command, the setup isn’t finished.

Clean environments matter.
Developer ergonomics matter.
Typing gemini and having it instantly available is how it should be.

Final Result#

Once configured correctly, you should be able to:

gemini
bash

If you’re setting up production environments and want a clean, reliable server stack, feel free to connect.

Installing Gemini CLI on VPS the Right Way
https://farrosfr.com/blog/installing-gemini-cli-on-vps-the-right-way
Author Mochammad Farros Fatchur Roji
Published at February 11, 2026