Installing Sentry On Premise Using Docker Compose on Ubuntu 18.04

Here is tutorial how to install Sentry On Premise

I recommend to have minimum 4GB of RAM. If not, you can install more swap to accommodate this.

Install Docker

sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

# Install docker compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version

Install Sentry On Premise

git clone https://github.com/getsentry/onpremise.git docker-sentry
cd docker-sentry
docker volume create --name=sentry-data && docker volume create --name=sentry-postgres
cp -n .env.example .env
docker-compose build
docker-compose run --rm web config generate-secret-key
nano .env
# add secret key to .env
docker-compose run --rm web upgrade
docker-compose up -d

Then modify config.yml with your mail credentials

Install NGinx

sudo apt-get install nginx
sudo ln -s /etc/nginx/sites-available/<yourdomainname> /etc/nginx/sites-enabled/<yourdomainname>

Then edit file /etc/nginx/sites-available/<yourdomainname>

server {
    listen 80;
    listen [::]:80;
    server_name <yourdomainname>;
    root /var/www/html;
    
    index index.html index.htm index.php;
    
    charset utf-8;

    location / {
        proxy_pass http://127.0.0.1:9000;
        add_header Strict-Transport-Security "max-age=31536000";
    }
    
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/<yourdomainname>-error.log error;

    client_max_body_size 128m;
}

Test NGINX installation then reload configuration if fine

sudo nginx -t
sudo service nginx restart

Setup your DNS to point on your server

Then try opening your domain

WordPress Hosting Optimization

Umumnya web wordpress itu kemooot banget. Hari ini saya mencoba membuat blog wordpress untuk Masjid Garuda (http://masjidgaruda.rajawali.web.id/) dengan teknik WordPress Hosting Optimization. Kayaknya kalau pakai turbolinks + html cache bakal kenceng webistenya. Setelah mencari-cari, konfigurasi dan plugin yang cocok, jalan, dan akhirnya dipakai adalah:

  • Host Virtual Machine di DigitalOcean yang $10 (Hosting udah pakai SSD)
  • NGINX web server
  • Ajaxify WordPress Site
  • WP Super Cache

Saya pun setup website-nya di server Digital Ocean yang $10 per bulan. Berikut ini komparasinya:

  1. Shared hosting biasa vs host VM: 3 request per second vs 65 request per second
  2. Shared hosting biasa vs host VM: 5 second page load vs 1 second page load
  3. Apache web server vs NGinx web server: 65 request per second vs 75 request per second
  4. Tanpa WP Super Cache vs Dengan WP Super Cache: 75 request per second vs 5500 request per second
  5. Tanpa WP Super Cache vs Dengan WP Super Cache: 1 second page load vs 65 milisecond page load
  6. Transisi halaman tanpa Ajaxify WordPress Site vs dengan Ajaxify WordPress Site: 3 second page render vs 300 milisecond page render

*Catatan: hasil diperoleh dari rata-rata ujicoba dan angka yang tertulis dibulatkan. Hasil mungkin berbeda dengan percobaan lain, tapi kurang lebih mirip lah.

Laravel: Should I Choose HHVM or PHP-FPM

My conclusion:
HHVM beats PHP-FPM by 20% to 45% at both request per second and average response time.

Well, if you also include database operation, the time margin should be around the same (the percentage may differ though), considering both HHVM and PHP-FPM consume about same time for database operation.

I ran the test for Lumen 5.2 and Laravel 5.2 using Apache Bench. The PHP version used is 5.6.13 and NGinx version 1.4.6.

If you are curious of “even better performance for Laravel”, try ReactPHP+NGinx (refer to http://marcjschmidt.de/blog/2014/02/08/php-high-performance.html) because it eliminates Laravel bootstrap’s code just being ran once at server startup, instead of ran at each request (See also https://github.com/php-pm/php-pm). But there is a fatal drawback: If your code throw uncatched exception, your server dies. Also other drawbacks such as reload server on code change and potential memory leaks.

If you need the test results / source code, just contact me. I don’t feel like putting them on this blog.

Enable Upload Large File on PHP + Nginx

  1. Open file php.ini (should be located at /etc/php5/fpm/php.ini if you are using PHP-FPM. Otherwise, just find it using: sudo updatedb && locate php.ini)
  2. Edit these 3 variables:
    1. upload_max_filesize => 2M to (whatever you want. I tend use 128M)
    2. post_max_size => 2M to (same as above. just note if you expect to upload multiple files, set this variable higher than above)
    3. max_input_time => 60 to (your client’s expected maximum upload time. should be max file size divided by minimum client’s upload speed)
  3. Open your nginx configuration, add this parameters:
    1. client_max_body_size xxM; (same as post_max_size)
    2. fastcgi_read_timeout xxM; (same as max_input_time)
  4. Restart PHP-FPM and nginx: sudo service php5-fpm restart && sudo service nginx restart
  5. That’s all folks!