Libravatar is a service that provides a globally accessible avatar or profile picture based on an email address. In this tutorial, we will explain how to install and setup Libravatar on Ubuntu Server.
To install Libravatar, you will need:
To begin with, we need to make sure that our system is up to date and has all of the necessary packages for installing Libravatar. Run the following command to update the system:
sudo apt update && sudo apt upgrade -y
After the system is updated successfully, we'll install the required packages for Libravatar using the following command:
sudo apt install python3 python3-pip python3-virtualenv python3-dev python3-setuptools python3-wheel nginx git -y
We'll set up Nginx as a reverse proxy to access the Libravatar service. Create a new configuration file called /etc/nginx/sites-available/lavravatar
with the following contents:
server {
listen 80;
server_name myexample.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Note that myexample.com
should be replaced with your domain name.
If you don't have a valid domain name, you may use an internal IP address instead.
After saving the file, activate the configuration by creating a symbolic link in the sites-enabled
directory as follows:
sudo ln -s /etc/nginx/sites-available/lavravatar /etc/nginx/sites-enabled/
Verify the Nginx configuration for syntax errors:
sudo nginx -t
If the output returns with no errors, you can restart Nginx to apply the new configuration:
sudo systemctl restart nginx
We'll set up Libravatar in a Python virtual environment. First, create a new directory to store the code:
sudo mkdir /opt/lavravatar
Then, switch to the newly created directory:
cd /opt/lavravatar
Create a virtual environment by running the following command:
sudo python3 -m venv env
Activate the environment:
source env/bin/activate
Clone the latest version of Libravatar from the official repository:
sudo git clone https://github.com/lavr/lavr.git
Move into the Lavr directory:
cd lavr
Install the required Python packages by running the following command:
sudo pip install -r requirements.txt
Copy the configuration file from the sample:
cp config.ini.sample config.ini
Open the configuration file running the following command:
sudo nano config.ini
Update the configuration file with the following parameters:
[general]
# Set the FQDN for the S3 bucket URL
s3_url = https://s3.amazonaws.com/avatar.example.com/
# Set the Nginx Domain
nginx_domain = myexample.com
# Optional. Set a secret key. This will be used to encrypt session data.
secret = a_random_password
Also, update the storage section with your Amazon S3 credentials:
[storage]
# Set S3 credentials. Alternatively, you can use IAM instance roles:
aws_access_key_id = AWS_ACCESS_KEY_ID
aws_secret_access_key = AWS_SECRET_ACCESS_KEY
s3_bucket_name = libravatar.example.com
s3_region_name = us-east-1
After saving the changes to the configuration file, start the server with the following command:
sudo python3 lavr.py runserver
The server should now be accessible at http://localhost:8000
. You must keep the terminal open as long as you want to keep the server running.
To test that the installation is working, you can open a web browser and visit http://your_domain_name/avatar/my_email_address
.
For example, if your domain name is example.com
and your email address is user@example.com
, visit:
http://example.com/avatar/user%40example.com
Note that we replaced the @
symbol with %40
in the URL. This is because URLs do not support the @
symbol.
If all goes well, you should see the default Gravatar image or an uploaded avatar image if you have one.
In this tutorial, we walked through the installation and configuration of Libravatar on Ubuntu Server. With Libravatar set up, you can now have consistent avatars across multiple accounts on different websites using the same email address.
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!