

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:
geminibashAnd it just works.
1. Install Node.js (If Not Installed)#
Check your Node version:
node -v
npm -vbashIf you’re using aaPanel, Node is usually located under:
/www/server/nodejs/bash2. Install Gemini CLI Globally#
Run:
npm install -g @google/gemini-clibashAfter installation, verify where global packages are installed:
npm root -g
npm config get prefixbashExample output:
/www/server/nodejs/v20.18.1bashThat means the binary is located at:
/www/server/nodejs/v20.18.1/binbash3. 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 foundbashTemporary Fix#
export PATH=$PATH:/www/server/nodejs/v20.18.1/binbashPermanent Fix#
Edit your shell profile:
nano ~/.bashrcbashAdd:
export PATH=$PATH:/www/server/nodejs/v20.18.1/binbashReload:
source ~/.bashrcbashNow test:
geminibashIf everything is correct, the CLI should launch immediately.
4. Authenticate with Gemini#
Run:
gemini /authbashOr set your API key manually:
export GEMINI_API_KEY=your_api_key_herebashTo persist it:
nano ~/.bashrcbashAdd:
export GEMINI_API_KEY=your_api_key_herebashReload:
source ~/.bashrcbashWhy 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:
geminibashIf you’re setting up production environments and want a clean, reliable server stack, feel free to connect.