GNU/Linux >> LINUX-Kenntnisse >  >> Ubuntu

So installieren Sie Drupal mit Nginx und Lets Encrypt SSL unter Ubuntu 20.04 LTS

Drupal ist ein kostenloses Open-Source-Content-Management-System, mit dem Sie digitale Inhalte für das Web und Mobiltelefone erstellen und bereitstellen können. Es ist in PHP geschrieben und wird von vielen Organisationen auf der ganzen Welt verwendet. Mit Drupal können Sie verschiedene Arten von Websites erstellen, von kleinen Blogs bis hin zu einer großen Unternehmenswebsite. Es bietet eine benutzerfreundliche Oberfläche und leistungsstarke Bearbeitungswerkzeuge zum Verwalten von Inhalten.

In diesem Tutorial zeigen wir Ihnen, wie Sie Drupal mit Nginx installieren und mit Let’s Encrypt SSL unter Ubuntu 20.04 sichern.

Voraussetzungen

  • Ein Server mit Ubuntu 20.04.
  • Ein gültiger Domainname, der auf Ihren Server verweist.
  • Auf Ihrem Server ist ein Root-Passwort konfiguriert.

LEMP-Server installieren

Zuerst müssen Sie den Nginx-Webserver, die MariaDB-Datenbank, PHP und andere erforderliche Erweiterungen auf Ihrem Server installieren. Sie können alle mit dem folgenden Befehl installieren:

apt-get install nginx mariadb-server php7.4 php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip -y

Sobald alle Pakete installiert sind, bearbeiten Sie die Datei php.ini und passen Sie einige Einstellungen an:

nano /etc/php/7.4/fpm/php.ini

Ändern Sie die folgenden Zeilen:

short_open_tag = On 
cgi.fix_pathinfo=0
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 300
date.timezone = America/Chicago

Speichern und schließen Sie die Datei, wenn Sie fertig sind.

MariaDB-Datenbank konfigurieren

Sichern Sie zunächst die MariaDB-Installation und legen Sie das MariaDB-Root-Passwort mit dem folgenden Befehl fest:

mysql_secure_installation

Beantworten Sie alle Fragen wie unten gezeigt:

Enter current password for root (enter for none): 
Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Sobald die MariaDB gesichert ist, melden Sie sich mit dem folgenden Befehl bei der MariaDB-Shell an:

mysql -u root -p

Geben Sie Ihr MariaDB-Root-Passwort ein und erstellen Sie dann eine Datenbank und einen Benutzer für Drupal:

MariaDB [(none)]> CREATE DATABASE drupaldb;
MariaDB [(none)]> CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'password';

Als nächstes erteilen Sie der Drupal-Datenbank alle Berechtigungen mit dem folgenden Befehl:

MariaDB [(none)]> GRANT ALL ON drupaldb.* TO 'drupal'@'localhost' WITH GRANT OPTION;

Löschen Sie als Nächstes die Berechtigungen und verlassen Sie die MariaDB-Shell mit dem folgenden Befehl:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Wenn Sie fertig sind, können Sie mit dem nächsten Schritt fortfahren.

Drupal herunterladen

Zum Zeitpunkt der Erstellung dieses Tutorials ist die neueste Version von Drupal 8.8.5. Sie können es mit dem folgenden Befehl in das Nginx-Webstammverzeichnis herunterladen:

cd /var/www/html/
wget https://ftp.drupal.org/files/projects/drupal-8.8.5.tar.gz

Sobald der Download abgeschlossen ist, extrahieren Sie die heruntergeladene Datei mit dem folgenden Befehl:

tar -xvzf drupal-8.8.5.tar.gz

Benennen Sie als Nächstes das extrahierte Verzeichnis in drupal um und geben Sie mit dem folgenden Befehl die richtigen Berechtigungen:

mv drupal-8.8.5 drupal
chown -R www-data:www-data drupal
chmod -R 755 drupal

Wenn Sie fertig sind, können Sie mit dem nächsten Schritt fortfahren.

Nginx für Drupal konfigurieren

Erstellen Sie als Nächstes mit dem folgenden Befehl eine virtuelle Nginx-Host-Konfigurationsdatei für Drupal:

nano /etc/nginx/sites-available/drupal

Fügen Sie die folgenden Zeilen hinzu:

server {
    listen 80;
    listen [::]:80;
    root /var/www/html/drupal;
    index  index.php index.html index.htm;
    server_name  drupal.linuxbuz.com;

    client_max_body_size 100M;
    autoindex off;

    location ~ \..*/.*\.php$ {
        return 403;
    }

    location ~ ^/sites/.*/private/ {
        return 403;
    }

    # Block access to scripts in site files directory
    location ~ ^/sites/[^/]+/files/.*\.php$ {
        deny all;
    }

    location ~ (^|/)\. {
        return 403;
    }

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

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    # Don't allow direct access to PHP files in the vendor directory.
    location ~ /vendor/.*\.php$ {
        deny all;
        return 404;
    }

    location ~ '\.php$|^/update.php' {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
        try_files $uri @rewrite;
    }
    location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
        try_files $uri /index.php?$query_string;
    }
}

Speichern und schließen Sie die Datei und erstellen Sie dann einen symbolischen Link zum Verzeichnis für aktivierte Websites:

ln -s /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/

Legen Sie als Nächstes hash_bucket_size in der Nginx-Standardkonfigurationsdatei fest:

nano /etc/nginx/nginx.conf

Fügen Sie die folgende Zeile unter "http {/strong> "

    server_names_hash_bucket_size 64;

Speichern und schließen Sie die Datei und überprüfen Sie dann Nginx auf Syntaxfehler:

nginx -t

Sie sollten die folgende Ausgabe erhalten:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Starten Sie als Nächstes den Nginx-Dienst neu, um die Änderungen zu übernehmen:

systemctl restart nginx

Sobald Sie fertig sind, können Sie mit dem nächsten Schritt fortfahren.

Drupal mit Let's Encrypt SSL sichern

Es wird empfohlen, das Drupal mit Let's Encrypt SSL zu sichern. Fügen Sie zuerst das Certbot-Repository mit dem folgenden Befehl hinzu:

add-apt-repository ppa:ahasenack/certbot-tlssni01-1875471

Aktualisieren Sie als Nächstes das Repository und installieren Sie den Certbot-Client mit dem folgenden Befehl:

apt-get update -y
apt-get install certbot python3-certbot-nginx -y

Führen Sie nach der Installation des Certbot-Clients den folgenden Befehl aus, um Let’s Encrypt SSL für Ihre Website herunterzuladen und zu installieren:

certbot --nginx -d drupal.linuxbuz.com

Sie werden aufgefordert, Ihre gültige E-Mail-Adresse anzugeben und die unten aufgeführten Nutzungsbedingungen zu akzeptieren:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y



Obtaining a new certificate
Performing the following challenges:
http-01 challenge for drupal.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/drupal

Wählen Sie als Nächstes aus, ob HTTP-Datenverkehr an HTTPS umgeleitet werden soll:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Geben Sie 2 ein und drücken Sie Enter um die Installation abzuschließen:

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/drupal

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://drupal.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=drupal.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/drupal.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/drupal.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-08-12. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Zu diesem Zeitpunkt ist Ihre Drupal-Website mit Let's Encrypt SSL gesichert.

Zugriff auf den Drupal-Webinstallationsassistenten

Öffnen Sie nun Ihren Webbrowser und geben Sie die URL https://drupal.linuxbuz.com ein. Sie werden zur Drupal-Sprachauswahlseite weitergeleitet:

Wählen Sie Ihre gewünschte Sprache und klicken Sie auf Speichern und weiter Taste. Sie sollten die Seite Installationsprofil sehen:

Wählen Sie Ihr gewünschtes Installationsprofil aus und klicken Sie auf Speichern und weiter Taste. Sie sollten die Seite Datenbankkonfiguration sehen:

Klicken Sie auf Speichern und weiter Taste. Sie sollten die Site-Konfigurationsseite sehen:

Geben Sie Ihren Site-Namen, Admin-Benutzernamen und Ihr Passwort ein und klicken Sie auf Speichern und weiter Taste. Sie werden auf der folgenden Seite zum Drupal-Standard-Dashboard weitergeleitet:

Schlussfolgerung

Herzliche Glückwünsche! Sie haben Drupal erfolgreich mit Let’s Encrypt SSL auf Ubuntu 20.04 installiert und gesichert. Sie können jetzt mit der Anpassung Ihrer Drupal-Website beginnen. Weitere Informationen finden Sie in der offiziellen Drupal-Dokumentation.


Ubuntu
  1. So installieren Sie Nextcloud mit Nginx und Lets Encrypt SSL unter Ubuntu 20.04 LTS

  2. So installieren Sie Magento 2 mit Nginx und Lets Encrypt SSL unter Ubuntu 20.04 LTS

  3. So installieren Sie Seafile mit Nginx unter Ubuntu 20.04 LTS

  4. So installieren Sie Drupal 8 mit Nginx, PHP-FPM und SSL unter Ubuntu 15.10

  5. So installieren Sie Drupal 8.1 mit Nginx, PHP-FPM und SSL auf Ubuntu 16.04

So installieren Sie das NodeBB-Forum mit Nginx und Lets Encrypt SSL unter Ubuntu 20.04 LTS

So installieren Sie Moodle mit Nginx und Lets Encrypt SSL unter Ubuntu 20.04

So installieren Sie MediaWiki mit Nginx und Lets Encrypt SSL unter Ubuntu 20.04

So installieren Sie Gitea mit Nginx und kostenlosem Lets Encrypt SSL unter Ubuntu 20.04

So installieren Sie Let’s Encrypt SSL mit Nginx unter Ubuntu 16.04 LTS

So installieren Sie Nginx mit Let’s Encrypt SSL unter Ubuntu 20.04 LTS