Skip to content

Instantly share code, notes, and snippets.

@Big-Vi
Created September 27, 2023 23:40
Show Gist options
  • Save Big-Vi/af0581b248ca5768f83c0ff06120e544 to your computer and use it in GitHub Desktop.
Save Big-Vi/af0581b248ca5768f83c0ff06120e544 to your computer and use it in GitHub Desktop.
Deploying LimeSurvey on Ubuntu using Nginx, MySQL & Certbot

Install Nginx

sudo apt update
sudo apt install nginx

Install MySQL and secure it

sudo apt install mysql-server
sudo mysql_secure_installation

Create MySQL database and user

sudo mysql -u root -p
CREATE DATABASE limesurvey_db;
CREATE USER 'root'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON limesurvey_db.* TO 'root'@'localhost';
FLUSH PRIVILEGES;
exit

Install PHP and required extensions

sudo add-apt-repository ppa:ondrej/php
sudo apt install php8.1-fpm php8.1-mysql php8.1-curl php8.1-gd php8.1-mbstring php8.1-xml php8.1-zip php8.1-imap

Download and Install LimeSurvey

cd /var/www/html
sudo wget https://download.limesurvey.org/latest-master/limesurvey6.2.8+230921.zip -O limesurvey.zip
sudo apt-get install unzip
sudo unzip limesurvey.zip
sudo mv limesurvey limesurvey.example.com
sudo rm limesurvey.zip

sudo chmod -R 777 /var/www/html/limesurvey.example.com/tmp
sudo chmod -R 777 /var/www/html/limesurvey.example.com/upload
sudo chmod -R 777 /var/www/html/limesurvey.example.com/application/config

Create Nginx configuration

sudo vi /etc/nginx/sites-available/limesurvey

Enable Nginx configuration

sudo ln -s /etc/nginx/sites-available/limesurvey /etc/nginx/sites-enabled/

Test Nginx configuration

sudo nginx -t

Restart Nginx

sudo systemctl restart nginx

Nginx config

server {
    listen 80;
    server_name limesurvey.example.com www.limesurvey.example.com;

    root /var/www/html/limesurvey.example.com;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

Install TLS using Certbot

sudo apt install certbot python3-certbot-nginx
certbot --nginx -d limesurvey.example.com -d www.limesurvey.example.com -m example@gmail.com --non-interactive --agree-tos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment