# Redirect HTTP -> HTTPS
server{listen80;server_namewww.example.comexample.com;includesnippets/letsencrypt.conf;return301https://example.com$request_uri;}# Redirect WWW -> NON WWW
server{listen443sslhttp2;server_namewww.example.com;ssl_certificate/etc/letsencrypt/live/example.com/fullchain.pem;ssl_certificate_key/etc/letsencrypt/live/example.com/privkey.pem;ssl_trusted_certificate/etc/letsencrypt/live/example.com/chain.pem;includesnippets/ssl.conf;return301https://example.com$request_uri;}server{listen443sslhttp2;server_nameexample.com;root/var/www/my_drupal/web;# SSL parameters
ssl_certificate/etc/letsencrypt/live/example.com/fullchain.pem;ssl_certificate_key/etc/letsencrypt/live/example.com/privkey.pem;ssl_trusted_certificate/etc/letsencrypt/live/example.com/chain.pem;includesnippets/ssl.conf;# log files
access_log/var/log/nginx/example.com.access.log;error_log/var/log/nginx/example.com.error.log;location=/favicon.ico{log_not_foundoff;access_logoff;}location=/robots.txt{allowall;log_not_foundoff;access_logoff;}location~\..*/.*\.php${return403;}location~^/sites/.*/private/{return403;}# Block access to scripts in site files directory
location~^/sites/[^/]+/files/.*\.php${denyall;}# 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~(^|/)\.{return403;}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${denyall;return404;}location~'\.php$|^/update.php'{fastcgi_split_path_info^(.+?\.php)(|/.*)$;includefastcgi_params;# Block httpoxy attacks. See https://httpoxy.org/.
fastcgi_paramHTTP_PROXY"";fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;fastcgi_paramPATH_INFO$fastcgi_path_info;fastcgi_paramQUERY_STRING$query_string;fastcgi_intercept_errorson;fastcgi_passunix:/run/php-fpm/www.sock;}# 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;}location~*\.(js|css|png|jpg|jpeg|gif|ico|svg)$ {try_files$uri@rewrite;expiresmax;log_not_foundoff;}}
cd /var/www/my_drupalsudo -u nginx /usr/local/bin/composer require drupal/pathauto
通过前置sudo -u nginx我们正在以用户身份运行命令nginx
Using version ^1.3 for drupal/pathauto
./composer.json has been updated
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
- Installing drupal/token (1.5.0): Downloading (100%)
- Installing drupal/ctools (3.2.0): Downloading (100%)
- Installing drupal/pathauto (1.3.0): Downloading (100%)
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
> DrupalProject\composer\ScriptHandler::createRequiredFiles
正如您从上面的输出中看到的,composer 还为我们安装了所有包依赖项。
更新 Drupal 核心#
在升级之前,最好备份文件和数据库。您可以使用备份和迁移模块或手动备份您的数据库和文件。
要备份安装文件,您可以使用以下命令rsync命令当然,您需要使用正确的安装目录路径:
sudo rsync -a /var/www/my_drupal/ /var/www/my_drupal_$(date +%F)