Saturday, December 28, 2024

Deployment Zulip Steps

Here is a detailed guide on how to deploy Zulip on Debian 12 with PHP 7.4 or 8.4, Nginx 1.27, and MariaDB 11. Please note that Zulip does not support MariaDB and requires PostgreSQL.

1. Install Dependencies
Update the system
First, update the system packages:

sudo apt update
sudo apt upgrade -y

Install necessary dependencies
Zulip requires several dependencies, including Python, Node.js, and other necessary software:

sudo apt install python3-dev python3-pip python3-venv python3-setuptools python3-django libpq-dev libjpeg-dev libxml2-dev libssl-dev libffi-dev build-essential nginx curl git -y

Install Node.js and npm
Zulip requires Node.js for the frontend:

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejs

Install PostgreSQL (MariaDB is not supported)
Zulip uses PostgreSQL by default, not MariaDB. Install PostgreSQL:

sudo apt install postgresql postgresql-contrib -y

2. Configure PostgreSQL Database
1.Log in to PostgreSQL:

sudo -u postgres psql

2.Create the database and user:

CREATE DATABASE zulip;
CREATE USER zulipuser WITH PASSWORD 'yourpassword';
ALTER ROLE zulipuser SET client_encoding TO 'utf8';
ALTER ROLE zulipuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE zulipuser SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE zulip TO zulipuser;
q

3. Download and Configure Zulip
1.Clone the Zulip repository:

git clone https://github.com/zulip/zulip.git /opt/zulip
cd /opt/zulip

2.Run the installation script:

./scripts/setup/install

The installation script will:

Set up Python environment and dependencies
Configure the database
Set up Nginx and other services
The installation may take some time, follow the prompts to complete the configuration.
4. Configure Nginx
1.Create a new Nginx configuration file:

sudo nano /etc/nginx/sites-available/zulip

2.Add the following configuration:

server {
    listen 80;
    server_name yourdomain.com;
    root /opt/zulip;
    
    location / {
        proxy_pass http://localhost:9991;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Upgrade $http_upgrade;
    }
}

3.Enable the Nginx configuration and restart:

sudo ln -s /etc/nginx/sites-available/zulip /etc/nginx/sites-enabled/
sudo systemctl restart nginx

5. Start Zulip
1.Start the Zulip service:

sudo systemctl start zulip

2.Enable Zulip to start automatically on boot:

sudo systemctl enable zulip

6. Access Zulip
Open your browser and visit http://yourdomain.com or your server’s IP address. You will see the Zulip setup page. After completing the setup, you can start using Zulip.

7. Configure SSL (Optional)
To set up SSL for Zulip, you can use Let’s Encrypt:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com

Summary
With the above steps, you have successfully deployed Zulip on Debian 12. You can now access Zulip through a browser and optionally enable HTTPS for added security.