Thumbor is a powerful open-source image processing solution for websites, that allows you to resize, crop and optimize images in real-time. It is an excellent alternative to Cloudinary or Imgix, but it is self-hosted, which means you have full control over your images.
In this tutorial, we will explain how to install Thumbor on a Debian latest server.
Before starting, you must have the following:
The first step is to install the necessary packages for Thumbor to operate correctly. You can do this by running the following commands:
sudo apt-get update
sudo apt-get install -y python-pip python-dev libjpeg-dev libpng-dev libtiff-dev libtiff5-dev libffi-dev libssl-dev
Now, let's install Thumbor on Debian latest:
sudo pip install thumbor
Once the installation complete, you can test if Thumbor is running correctly by running:
thumbor -h
This command should show you the help menu of Thumbor.
Next, let's configure Thumbor. Create a directory for the configuration:
sudo mkdir /etc/thumbor
Then, create a Thumbor configuration file:
sudo nano /etc/thumbor/thumbor.conf
Paste the following Thumbor configuration and save it:
# /etc/thumbor/thumbor.conf
import os
# Security configuration
ALLOWED_SOURCES = []
ALLOWED_OPERATIONS = []
ALLOWED_DIMENSIONS = []
RESULT_STORAGE_EXPIRATION_SECONDS = 60 * 60 * 24 * 30 # 30 days of cache storage
# Server configuration
HTTP_SERVER_PORT = 8888
HTTP_TIMEOUT = 60
MAX_CONTENT_LENGTH = 0
LOADERS = ['thumbor.loaders.http_loader']
HTTP_LOADER_CURL_ASYNC_HTTP_CLIENT = 'tornado.curl_httpclient.AsyncHTTPClient'
DEFAULT_ENGINE = 'thumbor.engines.pil'
FILE_STORAGE_ROOT_PATH = '/var/lib/thumbor/storage'
FILE_STORAGE_EXPIRATION_SECONDS = 60 * 60 * 24 * 7 # 7 days of cache storage
FILE_STORAGE_SALT = 'changeit'
FILE_STORAGE_LAYOUT = 'by_file_extension'
# Logging configuration
LOG_LEVEL = 'DEBUG'
LOG_FORMAT = '[%(asctime)s] [%(process)d] [%(levelname)s] %(module)s:%(lineno)d %(message)s'
LOGGER_NAME = 'thumbor'
LOG_FILE_PREFIX = '/var/log/thumbor/thumbor-'
# Security key
# Generate a secure random string
# You can use this command to generate one:
# python -c "import base64; import os; print(base64.urlsafe_b64encode(os.urandom(32)).decode())"
# SECURITY_KEY = '<your-security-key>'
Make sure to edit the SECURITY_KEY
parameter with a secure random string.
Finally, verify that the configuration is valid by running:
thumbor -c /etc/thumbor/thumbor.conf -s
If everything is correct, you should see a message saying "Configuration OK."
Now, let's start the Thumbor server. You can do this by running:
thumbor -c /etc/thumbor/thumbor.conf
Thumbor should be running on port 8888
.
To test if Thumbor is working correctly, you can access the following URL on a web browser:
http://<your-server-ip>:8888/unsafe/http://www.example.com/image.jpg
This URL should return an image resized to a default size of 1280x1024.
Congratulations! You have successfully installed Thumbor on your Debian latest server. You can now start processing your images using this open-source image processing solution. Modifying the Thumbor configuration, you can customize the server based on your requirements.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!