para a instalação do drupal9 num contentor (CT) com o Debian Buster, previamente atualizado (apt update -yy && apt upgrade -yy)
, começamos por instalar o servidor web que no nosso caso será o nginx.
apt install nginx
durante a instalação podemos compreender que aconteceu um problema (ou podemos utilizar o comando systemctl status nginx
):
Setting up nginx-full (1.14.2-2+deb10u4) ...
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
invoke-rc.d: initscript nginx, action "start" failed.
* nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2021-11-13 20:58:00 UTC; 29ms ago
Docs: man:nginx(8)
Process: 11569 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
o erro acontece porque os contentores não suportam a stack de rede ipv6. como tal temos que editar o ficheiro /etc/nginx/sites-enabled/default e comentar a linha responsável pela ativação do servidor na pilha de rede ipv6, de acordo com o que se segue:
server {
listen 80 default_server;
# listen [::]:80 default_server;
depois da alteração reiniciamos o nginx.
systemctl restart nginx
um dos primeiros passos para a instalação do drupal será a criação duma pasta dentro de /var/www:
mkdir /var/www/drupal9
antes da instalação do gestor de dependências PHP Composer temos que instalar o próprio PHP (aproveitamos para instalar o php-fpm e as livrarias necessárias para correr o drupal):
apt install php-cli php-fpm php-curl php-gd php-mbstring php-xml php-zip php-mysql php-apcu
e instalamos o gestor de dependências Composer:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
e para que possamos utilizar o Composer a partir de qualquer diretoria executamos:
mv composer.phar /usr/local/bin/composer
de seguida obtemos o código do drupal com o composer:
composer create-project drupal/recommended-project /var/www/drupal9
entretanto instalamos o Sistema de Gestão de Bases de Dados (SGBD) MariaDB:
apt install -y mariadb-server
e criamos a BD que será utilizada pelo nosso Drupal (BD: drupal; utilizador: drupal: palavra-passe: drupal):
mariadb
CREATE DATABASE drupal CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER drupal@localhost IDENTIFIED BY 'drupal';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON drupal.* TO 'drupal'@'localhost' IDENTIFIED BY 'drupal';
seguidamente criamos o bloco servidor responsável por servir a nossa aplicação. para isso criamos o ficheiro /etc/nginx/sites-available/drupal.conf e copiamos para ele o que se segue:
server {
server_name 8XgrupoY.lingolingo.pt;
root /var/www/drupal9/web; ## <-- Your only path reference.location = /favicon.ico {
log_not_found off;
access_log off;
}location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}# Very rarely should these ever be accessed outside of your lan
location ~* \.(txt|log)$ {
allow 192.168.0.0/16;
deny all;
}location ~ \..*/.*\.php$ {
return 403;
}location ~ ^/sites/.*/private/ {
return 403;
}# Block access to scripts in site files directory
location ~ ^/sites/[^/]+/files/.*\.php$ {
deny all;
}# Allow "Well-Known URIs" as per RFC 5785
location ~* ^/.well-known/ {
allow all;
}# Block access to "hidden" files and directories whose names begin with a
# period. This includes directories used by version control systems such
# as Subversion or Git to store control files.
location ~ (^|/)\. {
return 403;
}location / {
# try_files $uri @rewrite; # For Drupal <= 6
try_files $uri /index.php?$query_string; # For Drupal >= 7
}location @rewrite {
#rewrite ^/(.*)$ /index.php?q=$1; # For Drupal <= 6
rewrite ^ /index.php; # For Drupal >= 7
}# Don't allow direct access to PHP files in the vendor directory.
location ~ /vendor/.*\.php$ {
deny all;
return 404;
}# Protect files and directories from prying eyes.
location ~* \.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$ {
deny all;
return 404;
}# In Drupal 8, we must also match new paths where the '.php' appears in
# the middle, such as update.php/selection. The rule we use is strict,
# and only allows this pattern with the update.php front controller.
# This allows legacy path aliases in the form of
# blog/index.php/legacy-path to continue to route to Drupal nodes. If
# you do not have any paths like that, then you might prefer to use a
# laxer rule, such as:
# location ~ \.php(/|$) {
# The laxer rule will continue to work if Drupal uses this new URL
# pattern with front controllers other than update.php in a future
# release.
location ~ '\.php$|^/update.php' {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
# Ensure the php file exists. Mitigates CVE-2019-11043
try_files $fastcgi_script_name =404;
# Security note: If you're running a version of PHP older than the
# latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
# See http://serverfault.com/q/627903/94922 for details.
include fastcgi_params;
# Block httpoxy attacks. See https://httpoxy.org/.
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
# PHP 5 socket location.
#fastcgi_pass unix:/var/run/php5-fpm.sock;
# PHP 7 socket location.
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
}location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
try_files $uri @rewrite;
expires max;
log_not_found off;
}# Fighting with Styles? This little gem is amazing.
# location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
try_files $uri @rewrite;
}# Handle private files through Drupal. Private file's path can come
# with a language prefix.
location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
try_files $uri /index.php?$query_string;
}# Enforce clean URLs
# Removes index.php from urls like www.example.com/index.php/my-page --> www.example.com/my-page
# Could be done with 301 for permanent or other redirect codes.
if ($request_uri ~* "^(.*/)index\.php/(.*)") {
return 307 $1$2;
}
}
ativamos o bloco servidor:
ln -s /etc/nginx/sites-available/drupal.conf /etc/nginx/sites-enabled
e recarregamos o servidor:
systemctl reload nginx
antes de prosseguirmos para a instalação propriamente dita alteramos o dono da pasta que será servida (/var/www/drupal/web/) e depois criamos um snapshot:
chown -Rv www-data:www-data /var/www/drupal9/web/
https://www.drupal.org/docs/installing-drupal/drupal-quick-start-command
https://getcomposer.org/download/
https://www.drupal.org/download
https://www.drupal.org/docs/installing-drupal