自分のWebsiteにアクセスしても、Drupal8.5.4の設定画面が出てこない

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by kuronecozizi on July 1, 2018 at 8:06am

お世話になっております。

今回、"さくらのクラウド"に最新バージョンのDrupal8.5.4を導入しようとしています。
個人的には、Nginxの設定に誤りがあるためだ、と考えておりますが、様々なサイトを回ってみても、原因の特定ができませんでした。
Nginx,MariaDB, PHPはyumでインストールしましたし、DrupalはComposerでサーバー内に展開しましたので、所有権や権限の設定は自動で行われていると考えております。

上記の私見で誤りがあれば、ご指摘・ご教授いただけますと、大変勉強になりますので、どうぞよろしくお願いいたします。

【構成】
さくらのクラウド
CPU:1core
Memory:1GB
SSD:20GB

OS:CentOS 7.5(64bit)
DB:MariaDB 10.2.8
PHP:PHP7.2 / PHP7.2-fpm
Server:Nginx 1.15.0

Composer 1.6.5
Drupal8.5.4はComposerにより配置済み

怪しいと考えている【Nginxのコンフィグファイル】3点のコードを記します。

くろまる/etc/nginx/nginx.conf

user nginx;
master_process off; ## ADD!
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
index index.html index.htm index.php; ##ADD!
#default_type application/octet-stream; ##ADD!
include /etc/nginx/sites-enabled/*; ##ADD!
default_type application/octet-stream; ##ADD!

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

#access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;

keepalive_timeout 65;

gzip on;

include /etc/nginx/conf.d/.conf;

server {
server_name MY_SITE.NET;
root /var/www/html/drupal/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ドル;
}

# Don't allow direct access to PHP files in the vendor directory.
location ~ /vendor/.
.php$ {
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)(|/.)$;
# 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.2-fpm.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;
expires max;
log_not_found off;
}
}
}

くろまる/usr/lib/systemd/system/nginx.service

[Unit]
Description=nginx - high performance web server
Documentation=https://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target

くろまる/etc/init.d/nginx

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/etc/nginx/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
# make required directories
user=$nginx -V 2&gt;&amp;1 | grep &quot;configure arguments:.*--user=&quot; | sed &#039;s/[^*]*--user=\([^ ]*\).*/1円/g&#039; -
if [ -n "$user" ]; then
if [ -z "grep $user /etc/passwd" ]; then
useradd -M -s /bin/nologin $user
fi
options=$nginx -V 2&gt;&amp;1 | grep &#039;configure arguments:&#039;
for opt in $options; do
if [ echo $opt | grep &#039;.*-temp-path&#039; ]; then
value=echo $opt | cut -d &quot;=&quot; -f 2
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
fi
}

start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}

stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {
configtest || return $?
stop
sleep 1
start
}

reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}

force_reload() {
restart
}

configtest() {
$nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}

case "1ドル" in
start)
rh_status_q && exit 0
1ドル
;;
stop)
rh_status_q || exit 0
1ドル
;;
restart|configtest)
1ドル
;;
reload)
rh_status_q || exit 7
1ドル
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: 0ドル {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac

くろまる/etc/nginx/conf.d/default.conf

server {
root /var/www/html/drupal/web;

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;
}

# 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ドル;
}

# Don't allow direct access to PHP files in the vendor directory.
location ~ /vendor/.
.php$ {
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)(|/.)$;
# 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;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.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)$ {
expires max;
log_not_found off;
}
}

Nginxのfirewallにはhttpとhttpsの穴を開けております。
また、Nginx、PHPのエラーログの双方にエラーは出力されておりません。

どうぞよろしくお願いいたします。

Comments

どこまで通信が届いているか不明なので、まずは

  • /etc/nginx/nginx.conf をデフォルトの状態に戻す
  • /etc/nginx/conf.d/default.conf を削除

してからnginxをreloadし、nginxのデフォルトページが閲覧できるか確認してみてください。
これがOKであれば、firewalldとsystemd, init.dは問題なく、nginxかphp-fpmに問題が絞り込めますので、まずは切り分けしてみてはどうでしょうか。

あと、ぱっと見気になる点だけコメントしておきます。

  • nginxパッケージのアップデートの際にconflictする可能性があるので、 /etc/nginx/nginx.conf は直接編集しないほうが良いです。最後に/etc/nginx/conf.d/*.conf がincludeされますので、overrideしたい設定はここに新規ファイルとして追加したほうがメンテしやすいです。
  • 上のコメントと絡みますが、nginx.conf の include /etc/nginx/conf.d/*.conf より下の設定は /etc/nginx/conf.d/default.conf 相当と思いますので不要なように見えます。

また、nginxでは.htaccessが使えないため、Drupalのコアに含まれる .htaccess (1つではないので注意してください) 相当の設定をnginxの設定として書く必要があります。
残念ながらこの辺りを理解せずに商用環境でnginxを使い、アレとかコレとかにアクセスできるサイトが結構あります(恐ろしい..)ので、注意が必要です。

手間であれば、apacheで動かしてしまったほうが楽ができます。

早速試しました。

  • /etc/nginx/nginx.conf をデフォルトの状態に戻す
  • /etc/nginx/conf.d/default.conf を削除


    の後、reloadし、デフォルトのWelcomeページのアドレスを curl しましたがタイムアウト。
    # curl 'http://MY_SERVER.net/usr/share/nginx/html/index.html'

    さらに、
    /etc/nginx/conf.d/default.conf に以下を記述して試してみました。

    server {
    listen 80;
    server_name MY_SERVER.net;
    location / {
    root /usr/share/nginx/html;
    index index.html index.htm;
    }
    }

    リロード後 curl してみましたがタイムアウトでした。

    # curl 'http://MY_SERVER.net'



    おかげ様で、firewalldとsystemd, init.dの設定をしっかりと見直すことができます。
    この3点のチェックの後、再びご報告いたします。



    >>あと、ぱっと見気になる点だけコメントしておきます。
    について、大変勉強になりました。ありがとうございます!

  • /etc/nginx/nginx.conf の直接編集ではなく、 .conf ファイルのoverrideでやっていきます。
  • 上記同様、デフォルトに戻す前の【 nginx.conf の include /etc/nginx/conf.d/
  • .conf より下の設定 】相当部分は、default.conf に記載するようにします。


    また、
    >>nginxでは.htaccessが使えないため、Drupalのコアに含まれる .htaccess (1つではないので注意してください) 相当の設定をnginxの設定として書く必要があります。
    についても研究していきたいと思います。
    ご指摘ありがとうございます!

    報告いたします。

    Posted by kuronecozizi on July 11, 2018 at 2:02pm

    firewalldとsystemd, init.dの設定を見直したり、デフォルトに戻したりしましたが結果は変わらず。

    そこで nginx を再インストールしてもう一度確かめましたが、nginxのWelcomeページは表示されませんでした。

    従いまして、こちらでご相談させていただきましたが、大変申し訳ございませんがサーバーを一旦削除しました。

    削除前のサーバーと同じ作業手順をそのまま行ったところ、普通にnginxのWelcome画面が表示され、拍子抜けしたところです。。。

    原因を明らかにできずに申し訳ありませんでした。

    blauerberg様、ありがとうございました。

    前出の報告後、Drupalの導入作業を続行いたしておりました。

    ブラウザで初めてサーバーにアクセスしたときに表示される、Drupalの初期設定について、別の質問を立ち上げさせていただきます。

    皆様どうぞよろしくお願いいたします。

    日本 コミュニティ: Drupal Japan User Group

    Group organizers

    Group categories

    Group notifications

    This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

    AltStyle によって変換されたページ (->オリジナル) /