Table of Contents
- Prerequisites
- Server Setup
- DeployHQ Configuration
- Deployment Process
- Post-Deployment Steps
1. Prerequisites
- A GitHub account
- Access to the Gemini Search repository
- A DeployHQ account
- A VPS or cloud server (We'll use Ubuntu 22.04 LTS)
- Domain name (optional)
2. Server Setup
2.1 Initial Server Configuration
First, SSH into your server:
ssh root@your_server_ip
Update the system:
apt update && apt upgrade -y
2.2 Create a Non-Root User
# Create new user
adduser deploy
# Add user to sudo group
usermod -aG sudo deploy
# Switch to new user
su - deploy
2.3 Install Required Software
Install Node.js and npm:
# Install Node.js repository
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
# Install Node.js and npm
sudo apt install -y nodejs
# Verify installation
node --version
npm --version
Install Nginx:
bash
sudo apt install nginx -y
2.4 Configure Nginx
Create a new Nginx configuration:
sudo nano /etc/nginx/sites-available/gemini-search
Add the following configuration:
server {
listen 80;
server_name your_domain.com; # Or your server IP
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Enable the site:
sudo ln -s /etc/nginx/sites-available/gemini-search /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
2.5 Install PM2 for Process Management
sudo npm install -g pm2
2.6 Set Up Project Directory
# Create application directory
sudo mkdir -p /var/www/gemini-search
sudo chown deploy:deploy /var/www/gemini-search
3. DeployHQ Configuration
3.1 Setting Up Your DeployHQ Account
- Sign up at deployhq.com
- Create a new project
3.2 Repository Configuration
- Connect to GitHub
- Select the Gemini Search repository
- Configure branch settings:
Repository: ammaarreshi/Gemini-Search
Branch: main
3.3 Server Configuration in DeployHQ
- Go to "Servers" → "Add Server"
- Configure SFTP connection:
Protocol: SFTP
Hostname: your_server_ip
Username: deploy
Authentication: SSH Key
Deploy Path: /var/www/gemini-search
3.4 Deployment Configuration
Create a deployment configuration file:
# Build Pipeline
build:
- npm install
- npm run build
# Config File
environment:
- GOOGLE_API_KEY=${GOOGLE_API_KEY}
# SSH Commands
post_deploy:
- pm2 restart gemini-search || pm2 start npm --name "gemini-search" -- start
4. Deployment Process
4.1 Initial Deployment
- In DeployHQ dashboard, click "Deploy"
- Select the main branch
- Start deployment
4.2 Set Up PM2 Startup Script
On your server:
pm2 startup systemd
sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u deploy --hp /home/deploy
pm2 save
5. Post-Deployment Steps
5.1 SSL Configuration (Optional)
Install Certbot:
sudo apt install certbot python3-certbot-nginx -y
# Obtain SSL certificate
sudo certbot --nginx -d your_domain.com
5.2 Verify Deployment
1- Check application status:
pm2 status
2- View logs:
pm2 logs gemini-search
3- Test the application:
- Open your browser
- Visit
http://your_domain.com
orhttp://your_server_ip
- Test the search functionality
5.3 Monitoring Setup
Set up basic monitoring:
# Monitor memory usage
pm2 monit
# Set up PM2 monitoring
pm2 plus
5.4 Backup Configuration
Create a backup script:
#!/bin/bash
backup_dir="/backup/gemini-search"
date=$(date +%Y%m%d)
# Create backup directory
mkdir -p $backup_dir
# Backup application files
tar -czf $backup_dir/app_$date.tar.gz /var/www/gemini-search
# Backup nginx configuration
cp /etc/nginx/sites-available/gemini-search $backup_dir/nginx_$date.conf
Troubleshooting
Common Issues and Solutions
1- Application Not Starting
# Check PM2 logs
pm2 logs gemini-search
# Verify environment variables
nano /var/www/gemini-search/.env
2- Nginx Issues
# Check Nginx status
sudo systemctl status nginx
# Check Nginx error logs
sudo tail -f /var/log/nginx/error.log
3- Permission Issues
# Fix permissions
sudo chown -R deploy:deploy /var/www/gemini-search
Maintenance Tasks
Regular Updates
# Update system packages
sudo apt update && sudo apt upgrade -y
# Update Node.js packages
cd /var/www/gemini-search
npm update
# Restart application
pm2 restart gemini-search
Monitoring Commands
# Check application status
pm2 status
# Monitor resources
pm2 monit
# View logs
pm2 logs gemini-search
This comprehensive guide should give you everything needed to set up and maintain your Gemini Search deployment. Remember to regularly check for updates and monitor your application's performance.