How to set up Let’s Encrypt on old versions of Ubuntu

Today I wanted to add HTTPS support using Let’s Encrypt certificates for couple of old sites on very outdated legacy server, running Ubuntu 10.04.4 LTS and apache2.

The default “certbot” client which I’m using on other servers didn’t work because of outdated python and openssl version, so after some googling and trying couple of other clients, I finally found one that worked easy and flawlessly. It’s called acme.sh – https://github.com/Neilpang/acme.sh

Continue reading

HTTP/2 performance comparison (case study)

nginx-config

Couple of days ago nginx released nginx-1.10.0 stable version with http2 support.
I was already running nginx from their repos on couple of servers, and as the upgrade was possible just by running apt-get upgrade and adding a single parameter to config file, I decided to give it a try immediately.

I knew http2 use should impact sites with lots of http requests the most, so I compared the results from my hobby site for Latvian gamers – https://exs.lv/ – which has quite a lot of small images and other assets. I removed 3rd party ads so they don’t impact the load times and run couple of tests using gtmetrix.com. The results were pretty impressive for changing a single line of code. Continue reading

How to import an excel file into a MySQL database using PHP

Excel to MySQL illustration

I will provide basic code that’s needed to turn Excel or LibreOffice Calc file (.xlsx, .xls, .csv, .ods and some other formats) into a MySQL table with all the corresponding fields and data. This code will assume the first row of the document contains (unique) column names. That’s pretty much the only requirement.

First thing we need is PHPExcel package (it’s free and open source) for reading spreadsheet files. You can download it here: https://phpexcel.codeplex.com/. Download, extract and move it a folder where you can execute php files. We will include them in the following scripts. Continue reading

How to launch Chrome window with proxy using any ssh server

I will show how to use any server with ssh as a proxy, I’m doing this on Debian Linux, but it should be the same on all Debian derivatives, and very similar on any other Linux distribution. I use this method to watch Netflix and bypass country restrictions, and to test website access speed from different locations, but it can be used for many other purposes. Continue reading

How to kill processes by running time

htop-screenshot-8-cores

Heres a little trick to kill of unwanted processes that are running for more than X minutes on Linux.

I use this on a production server, where imagemagick and ffmpeg are executed many thousands of times per day and in normal conditions each process takes 0.x to 30 seconds. On rare cases they seem to run out of control and never finish execution or take longer than seems reasonable and worthwhile for the particular task. To free up resources taken by such processes, I decided it would be ok to just kill them if they are running for more than 10 minutes. It may not be a very safe and beautiful way to deal with such processes, but it’s working well for me for years now, so I’ll share… Continue reading