In this tutorial, we'll deploy Jekyll static site on Rocky Linux 10 with Nginx.
Jekyll is a static site generator. It takes text written in your favorite markup language and uses layouts to create a static website. You can tweak the site’s look and feel, URLs, the data displayed on the page, and more.
Deploying a static site with Jekyll and serving it through Nginx on Rocky Linux 10 is a reliable, high-performance way to host fast, secure content. In this guide, we’ll walk through each step from installing dependencies to configuring Nginx so that our site is production-ready. Let’s dive in!
Prerequisites
Before starting, make sure our new Rocky Linux 10 server is ready. The following components should be installed and configured:
- A Rocky Linux 10 installed dedicated server or KVM VPS.
- A normal user with root privileges.
- A domain name pointing A record to server IP.
Deploy Jekyll Static Site on Rocky Linux 10 with Nginx
Step 1: Update Rocky Linux and install Nginx
We begin by updating the system and installing required packages.
sudo dnf update -y
sudo dnf install -y nginx git curl
Enable and start the Nginx service:
sudo systemctl enable --now nginx
Allow HTTP and HTTPS through the firewall:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Step 2: Install Ruby and build dependencies
Jekyll requires Ruby and compilation tools.
sudo dnf install -y ruby ruby-devel gcc-c++ make openssl-devel redhat-rpm-config
sudo dnf groupinstall -y "Development Tools"
Verify the installation:
ruby -v
gem -v
Step 3: Install Jekyll and Bundler
We install Jekyll and Bundler in the user environment.
echo 'export GEM_HOME="$HOME/.gem"' >> ~/.bashrc
echo 'export PATH="$HOME/.gem/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
gem install bundler jekyll
Check versions:
jekyll -v
bundle -v
Step 4: Create the Jekyll website
Create a new project:
mkdir -p ~/sites
cd ~/sites
jekyll new mysite
cd mysite
Install required gems:
bundle install
Build the production site:
JEKYLL_ENV=production bundle exec jekyll build
Step 5: Prepare the web root
Create the Nginx web directory and deploy the site files.
sudo mkdir -p /var/www/mysite
sudo rsync -av --delete _site/ /var/www/mysite/
sudo chown -R nginx:nginx /var/www/mysite
Step 6: Configure Nginx
Create a server configuration file:
sudo tee /etc/nginx/conf.d/mysite.conf > /dev/null <<EOF
server {
listen 80;
server_name example.com www.example.com;
root /var/www/mysite;
index index.html;
location / {
try_files \$uri \$uri/ =404;
}
}
EOF
Note: Replace exmaple.com with your domain name.
Test and reload Nginx:
sudo nginx -t
sudo systemctl reload nginx
Step 7: Configure SELinux permissions
If SELinux is enabled, assign the correct context:
sudo dnf install -y policycoreutils-python-utils
sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/mysite(/.*)?"
sudo restorecon -Rv /var/www/mysite
Step 8: Enable HTTPS with Let’s Encrypt
Install Certbot:
sudo dnf install -y certbot python3-certbot-nginx
Generate the SSL certificate:
sudo certbot --nginx -d example.com
Test auto-renewal:
sudo certbot renew --dry-run
Step 9: Update workflow
Whenever we update the website, we run:
cd ~/sites/mysite
git pull
bundle install
JEKYLL_ENV=production bundle exec jekyll build
sudo rsync -av --delete _site/ /var/www/mysite/
sudo systemctl reload nginx
In this tutorial, we've deployed Jekyll static site on Rocky Linux 10 with Nginx. By following these steps, we’ve set up a modern Jekyll workflow on Rocky Linux 10 and configured Nginx to deliver our static site efficiently and securely. With our automated deploy script, updating content becomes a breeze just write, commit, and let our server handle the rest. Enjoy sharing your creations!
