Setting Up Redis, MySQL, and Nginx on Ubuntu 20.04

Installing Redis from Source

To deploy Redis, download the source code from the official Redis website. Extract the archive and prepare the build enviroment:

tar -xvf redis-x.x.x.tar.gz
cd redis-x.x.x
sudo apt update
sudo apt install build-essential pkg-config

Compile the source code using the provided makefile:

make MALLOC=libc
sudo make install

Configure the systemd service to manage the Redis process by copying the configuration files to /etc/redis/ and the unit file to /etc/systemd/system/. Finally, reload the daemon and start the service:

sudo systemctl daemon-reload
sudo systemctl enable --now redis

Installing MySQL 8.0

For MySQL, it is recommended to use the generic Linux binary distribution. Download the .tar.xz file from the MySQL archives and extract it to /usr/local/mysql.

xz -d mysql-VERSION-linux-glibc2.17-x86_64.tar.xz
tar -xvf mysql-VERSION-linux-glibc2.17-x86_64.tar
mv mysql-VERSION-linux-glibc2.17-x86_64 /usr/local/mysql

Ensure the required dependencies are installed, such as libaio1 and libncurses5. Create the system user and group:

sudo groupadd mysql
sudo useradd -r -g mysql -s /bin/false mysql

Initialize the data directory and set appropriate permissions:

sudo mkdir -p /usr/local/mysql/data
sudo chown -R mysql:mysql /usr/local/mysql
sudo /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data

Create a my.cnf file in /etc/ to define your data directory, socket location, and port settings. Create a systemd unit file to enable the service via systemctl.

Installing Nginx

Nginx can be compiled from source to include specific modules. First, install the necessary development headers:

sudo apt install libpcre3-dev zlib1g-dev libssl-dev

Download the latest Nginx stable source, extract it, and prepare the build configuration:

./configure --prefix=/usr/local/nginx \
           --user=www-data \
           --group=www-data \
           --with-http_ssl_module \
           --with-http_stub_status_module
make
sudo make install

You can then start Nginx using the absolute path or by creating a symbolic link to /usr/local/bin/nginx. Test the installation by running the binary with the configuraton flag:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

Tags: Redis MySQL nginx Ubuntu compilation

Posted on Thu, 03 Sep 2026 16:49:47 +0000 by mforan