Skip to content

Instantly share code, notes, and snippets.

@meniam
Created January 26, 2022 23:24
Show Gist options
  • Save meniam/d31a7dc4035b171a402d493de53928ff to your computer and use it in GitHub Desktop.
Save meniam/d31a7dc4035b171a402d493de53928ff to your computer and use it in GitHub Desktop.
Installing Sentry on Debian

Installing Sentry on Debian

Install aptitude packages

sudo apt-get update
sudo apt-get install python python-setuptools python-pip python-dev libxslt1-dev libxml2-dev libmysqlclient-dev

Install and activate virtualenv

sudo pip install -U virtualenv
virtualenv /clients/sentry/
source /clients/sentry/bin/activate

Install sentry

cd /clients/sentry
pip install -U sentry
pip install -U sentry[mysql]

Initialise sentry configuration

sentry init
nano /clients/.sentry/sentry.conf.py
//Change ENGINE to 'django.db.backends.mysql'
//Change NAME to 'sentry'
//Change USER to 'sentry'
//Change PASSWORD to your desired password
//Change HOST to 'localhost'
//Change PORT to '3306'
//Change SENTRY_URL_PREFIX to 'http://sentry.{your_domain}'
//Change EMAIL_HOST to 'smtp.mailgun.org'
//Change EMAIL_HOST_PASSWORD to mailgun SMTP password
//Change EMAIL_HOST_USER to mailgun SMTP username

Create MySQL database and user

mysql -uroot -p
CREATE DATABASE sentry;
CREATE USER 'sentry'@'localhost' IDENTIFIED BY 'password'; //Change password
GRANT ALL PRIVILEGES ON sentry.* TO 'sentry'@'localhost';
FLUSH PRIVILEGES;
exit;

Run database migration

sentry upgrade

Create the first user

sentry createuser

Setup nginx proxy

Create a new virtual host and insert the following:

server {
    listen 0.0.0.0:80;
    server_name sentry.{your_domain};
    location / {
        proxy_pass         http://localhost:9000;
        proxy_redirect     off;
        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;
    }
}

Be sure to restart nginx after:

sudo service nginx restart

Add sentry processes to supervisor

sudo nano /etc/supervisor/supervisord.conf

Insert the following:

[program:sentry-web]
directory=/clients/sentry/
command=/clients/sentry/bin/sentry --config=/clients/.sentry/sentry.conf.py start
autostart=true
autorestart=true
redirect_stderr=true
user=siteadmin

[program:sentry-worker]
directory=/clients/sentry/
command=/clients/sentry/bin/sentry --config=/clients/.sentry/sentry.conf.py celery worker -B
autostart=true
autorestart=true
redirect_stderr=true
user=siteadmin

[program:redis-server]
command=/usr/local/bin/redis-server
autostart=true
autorestart=true
redirect_stderr=true
user=siteadmin

Reread configuration and boot processes:

sudo supervisorctl reread
sudo supervisorctl update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment