How to Install Libravatar on Debian Latest
Libravatar is a service that provides a free and open-source avatar service. It is based on the email address and allows users to upload avatars that can be accessed across different websites and services. In this tutorial, you will learn how to install Libravatar on Debian Latest.
Prerequisites
Before starting this tutorial, make sure you have the following:
- A Debian Latest system
- A sudo user account
Step 1: Install the Dependencies
To install Libravatar, first, we need to install its dependencies. We can do this by running the following command:
sudo apt-get update
sudo apt-get install -y python3-dev python3-pip python3-venv uwsgi uwsgi-plugin-python3 git memcached nginx
Step 2: Create a Python Virtual Environment
Next, we need to create a virtual environment for Libravatar. We can do this by running the following commands:
mkdir ~/libravatar
cd ~/libravatar
python3 -m venv env
Step 3: Clone the Libravatar Repository
After creating the virtual environment, we need to clone the Libravatar repository using the git command.
git clone https://github.com/lavr/lavr.git
Step 4: Install the Libravatar Requirements
Once you have cloned the repository, you need to navigate to the libravatar folder and install the required libraries using pip.
cd ~/libravatar/lavr
# activate the virtual environment
source ~/libravatar/env/bin/activate
pip3 install -r requirements.txt
Step 5: Configure Django Settings
After installing the requirements, we need to configure the Django settings of Libravatar. Create a file named .env in the lavr folder and add the following contents:
# Django settings
SECRET_KEY=<your_secret_key>
DEBUG=True
ALLOWED_HOSTS=*
# Database settings
DATABASE_URL=sqlite:////path/to/your/db.sqlite3
# Django storage
DEFAULT_FILE_STORAGE=django.core.files.storage.FileSystemStorage
STATICFILES_STORAGE=django.contrib.staticfiles.storage.ManifestStaticFilesStorage
# Memcached caching
CACHES={"default":{"BACKEND":"django.core.cache.backends.memcached.MemcachedCache","LOCATION":"127.0.0.1:11211","TIMEOUT":3600}}
# Email settings
DEFAULT_FROM_EMAIL=<your_email>
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=<your_smtp_host>
EMAIL_PORT=<your_smtp_port>
EMAIL_USE_TLS=True
EMAIL_HOST_USER=<your_email_username>
EMAIL_HOST_PASSWORD=<your_email_password>
Step 6: Create the Database
After configuring the Django settings, create the database using the following command:
python manage.py migrate
Step 7: Create a Superuser
Next, create a superuser account for the Libravatar service using the following command:
python manage.py createsuperuser
Step 8: Run the Libravatar Service
After creating the superuser account, run the Libravatar service using the following command:
uwsgi --socket :8080 --module lavr.wsgi --home ~/libravatar/env --chmod-socket=666
Step 9: Configure Nginx Server Block
To access the Libravatar service from a web browser, we need to configure an Nginx server block. Create a new configuration file in the /etc/nginx/sites-available/ directory for the Libravatar service using the following command:
sudo nano /etc/nginx/sites-available/libravatar.example.com
Add the following contents to the file:
server {
listen 80;
server_name libravatar.example.com;
location / {
include uwsgi_params;
uwsgi_pass unix:///run/uwsgi/app/lavr/socket;
}
location /media/ {
alias /path/to/your/lavr/media/;
}
location /static/ {
alias /path/to/your/lavr/static/;
}
}
Note: Replace the values with the appropriate values
Step 10: Enable the Nginx Server Block
After creating the Nginx server block, enable it by creating a symbolic link to the /etc/nginx/sites-enabled/ directory.
sudo ln -s /etc/nginx/sites-available/libravatar.example.com /etc/nginx/sites-enabled/
Step 11: Restart Nginx and Test the Libravatar Service
Finally, restart Nginx to apply the changes and test the Libravatar service.
sudo systemctl restart nginx
You can now access the Libravatar service by visiting http://libravatar.example.com. Log in to the admin panel using the superuser account created earlier.
Conclusion
In this tutorial, you installed Libravatar on a Debian Latest system. You also created a virtual environment for Libravatar, installed its dependencies, configured Django settings, created a superuser account, and finally ran the Libravatar service with Nginx.