turnstile

Drupal paywall plugin
Log | Files | Refs | README | LICENSE

setup-drupal.sh (2052B)


      1 #!/bin/bash
      2 set -e
      3 
      4 # Variables
      5 DRUPAL_VERSION=10.3.0
      6 DB_NAME=drupal
      7 DB_USER=drupaluser
      8 DB_PASS=drupalpass
      9 INSTALL_DIR=/var/www/html
     10 DRUPAL_DIR=$INSTALL_DIR/drupal
     11 
     12 echo "===> Updating packages..."
     13 apt update && apt upgrade -y
     14 
     15 echo "===> Installing dependencies..."
     16 apt install -y nginx php php-fpm php-pgsql php-gd php-xml php-mbstring php-curl php-zip php-apcu php-cli unzip curl wget postgresql postgresql-contrib
     17 
     18 echo "===> Creating PostgreSQL database and user..."
     19 sudo -u postgres psql <<EOF
     20 CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';
     21 CREATE DATABASE $DB_NAME OWNER $DB_USER ENCODING 'UTF8';
     22 EOF
     23 
     24 echo "===> Downloading latest Drupal 10..."
     25 cd /tmp
     26 
     27 wget https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz
     28 tar -xzf drupal-${DRUPAL_VERSION}.tar.gz
     29 rm -rf $DRUPAL_DIR
     30 mv drupal-${DRUPAL_VERSION} $DRUPAL_DIR
     31 
     32 echo "===> Setting permissions..."
     33 chown -R www-data:www-data $DRUPAL_DIR
     34 chmod -R 755 $DRUPAL_DIR
     35 
     36 echo "===> Configuring Nginx for Drupal..."
     37 cat > /etc/nginx/sites-available/drupal <<EOF
     38 server {
     39     listen 80;
     40     server_name localhost;
     41 
     42     root $DRUPAL_DIR;
     43     index index.php index.html index.htm;
     44 
     45     location / {
     46         try_files \$uri /index.php?\$query_string;
     47     }
     48 
     49     location ~ \.php\$ {
     50         include snippets/fastcgi-php.conf;
     51         fastcgi_pass unix:/run/php/php8.2-fpm.sock;
     52         fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
     53         include fastcgi_params;
     54     }
     55 
     56     location ~ /\.ht {
     57         deny all;
     58     }
     59 
     60     location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
     61         expires max;
     62         log_not_found off;
     63     }
     64 }
     65 EOF
     66 
     67 echo "===> Enabling Drupal Nginx site..."
     68 ln -sf /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/drupal
     69 rm -f /etc/nginx/sites-enabled/default
     70 
     71 echo "===> Restarting services..."
     72 systemctl restart php8.3-fpm
     73 systemctl restart nginx
     74 systemctl enable php8.3-fpm nginx postgresql
     75 
     76 echo "===> Done!"
     77 echo "Visit http://localhost to finish installing Drupal 10."
     78 echo "Database: $DB_NAME | User: $DB_USER | Password: $DB_PASS"