質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Amazon CloudFront

Amazon CloudFrontは、AWSの高速且つ高パフォーマンスなコンテンツ配信(CDN) サービス。容量の大きいコンテンツをキャッシュさせてWebサーバの負荷を軽減し、サーバダウンの防止など安定した配信が可能になります。

HTTPS

HTTPS(Hypertext Transfer Protocol Secure)はHypertext Transfer プロトコルとSSL/TLS プロトコルを組み合わせたものです。WebサーバとWebブラウザの間の通信を暗号化させて、通信経路上での盗聴や第三者によるなりすましを防止します。

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

phpMyAdmin

phpMyAdminはオープンソースで、PHPで書かれたウェブベースのMySQL管理ツールのことです。

SSL

SSL(Secure Sockets Layer)とは、暗号化されたプロトコルで、インターネット上での通信セキュリティを提供しています。

Q&A

解決済

1回答

4773閲覧

AWSのLAMP環境でphpMyAdminにログインできない

Athenahack

総合スコア2

Amazon CloudFront

Amazon CloudFrontは、AWSの高速且つ高パフォーマンスなコンテンツ配信(CDN) サービス。容量の大きいコンテンツをキャッシュさせてWebサーバの負荷を軽減し、サーバダウンの防止など安定した配信が可能になります。

HTTPS

HTTPS(Hypertext Transfer Protocol Secure)はHypertext Transfer プロトコルとSSL/TLS プロトコルを組み合わせたものです。WebサーバとWebブラウザの間の通信を暗号化させて、通信経路上での盗聴や第三者によるなりすましを防止します。

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

phpMyAdmin

phpMyAdminはオープンソースで、PHPで書かれたウェブベースのMySQL管理ツールのことです。

SSL

SSL(Secure Sockets Layer)とは、暗号化されたプロトコルで、インターネット上での通信セキュリティを提供しています。

0グッド

0クリップ

投稿2021/08/13 02:35

編集2021/08/13 09:36

###前提・実現したいこと
AWSのlightsailを使用して、通常のAmazonLinux2に諸々インストールしてLAMP環境を構築しています。
またphpMyAdminを利用したく、同一Webサーバー内にてphpMyAdmin運用をしようとしています。

●環境
AWS Lightsail(Amazon linux 2)
PHP7.4 / MySQL 8.0 / Apache 2.4
phpMyAdmin

●使用サービス
Certificate Manager(証明書取得で使用)
Cloudfront(ACMで取得したSSL証明書の設定で使用)
Route53 (ドメイン取得、各レコード設定で使用)

これを参照してSSL化しました。
https://dev.classmethod.jp/articles/make-amazon-lightsail-instance-https/

###発生している問題・エラーメッセージ
SSL化をした段階でphpMyAdminにログインしようとすると

「Failed to set session cookie. Maybe you are using HTTP instead of HTTPS to access phpMyAdmin.」 が表示されます。 日本語訳だと セッションCookieの設定に失敗しました。 phpMyAdminへのアクセスにHTTPSではなくHTTPを使用している可能性があります。

SSL化する前まではログインできていたので、SSL化した後にphpmyadmin/以降のディレクトリにアクセスできないという事象になります。

###解決したいこと

おそらくapacheのSSL設定まわりかcloudfrontのHTTPやHTTPSの設定ができていないんだと思います。

SSL化する前まで~~はログインできていたので、~~もログインできていなかった気がします。
SSL化した後にphpmyadmin/以降のディレクトリにアクセスできないという事象になります。

###追記  起きている事象のパターンかきます

まずSSL化状態の

https://○○○/phpMyAdminでアクセスすると英語表記になります。

ログインしようとすると下記504エラーが出力されます。

#####タイムアウトの上限設定が原因?
apache設定ファイルでタイムアウトを上限まで変えましたが同様です。CloudFront側でもタイムアウトを上限まで上げましたが同様でした。

「504 ERROR The request could not be satisfied. CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner. If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.」

おそらくタイムアウト設定は関係なく、CloudFrontでSSL化した際の設定とかApache設定ファイルに問題があるかとは理解してます。

#####httpとhttpsそれぞれでアクセスしたときの違い

https://○○○/phpMyAdmin

英語表記になる。
ログインすると上記の504エラー出る → サイト更新すると一番最初に記載した問題の下記が出力されます

「Failed to set session cookie. Maybe you are using HTTP instead of HTTPS to access phpMyAdmin.」

http://○○○/phpMyAdmin

日本語表記になる。 SSL化する前のインストールした状態と同じ。

ログインすると上記の504エラー出る → サイト更新すると一番最初に記載した問題の下記が出力されます
SSL化する前のphpMyAdminインストールした当初はログインできていたのですが、今は504エラーが出ます。


https://○○○/phpinfo.php

phpMyAdmin以外は普通に何の問題もなく表示されます。


#####cloudfrontにSSL証明書設定後、apacheですべき設定は何でしょうか?

これを参照してSSL化しました。
https://dev.classmethod.jp/articles/make-amazon-lightsail-instance-https/

以下、apahceの設定ファイルです。

var/www/phpMyAdmin/のユーザーとグループの所有者はapacheに変えました。

######追記 httpd.confの中身 
mod_sslを入れたところ、ssl.confが編集できるようになったのでssl.confを設定した上でhttpd.confを編集しました。

httpd.conf

1 2 3 4# 5# ServerRoot: The top of the directory tree under which the server's 6# configuration, error, and log files are kept. 7 8 9# 10ServerRoot "/etc/httpd" 11 12# 13 14#Listen 12.34.56.78:80 15Listen 80 16 17# 18# Dynamic Shared Object (DSO) Support 19# 20# 21# 22# Example: 23# LoadModule foo_module modules/mod_foo.so 24# 25Include conf.modules.d/*.conf 26 27# 28User apache 29Group apache 30 31# 'Main' server configuration 32# 33 34# 35ServerAdmin root@localhost 36 37# 38 39# 40#ServerName www.example.com:80 41 42# 43 44# 45<Directory /> 46 AllowOverride None 47 Require all granted 48</Directory> 49 50# 51 52# 53DocumentRoot "/var/www/html" 54 55# 56# Relax access to content within /var/www. 57# 58<Directory "/var/www"> 59 AllowOverride None 60 # Allow open access: 61 Require all granted 62</Directory> 63 64# Further relax access to the default document root: 65<Directory "/var/www/html"> 66 # 67 # Possible values for the Options directive are "None", "All", 68 # or any combination of: 69 # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 70 # 71 # Note that "MultiViews" must be named *explicitly* --- "Options All" 72 # doesn't give it to you. 73 # 74 # The Options directive is both complicated and important. Please see 75 # http://httpd.apache.org/docs/2.4/mod/core.html#options 76 # for more information. 77 # 78 Options Indexes FollowSymLinks 79 80 # 81 # AllowOverride controls what directives may be placed in .htaccess files. 82 # It can be "All", "None", or any combination of the keywords: 83 # Options FileInfo AuthConfig Limit 84 # 85 AllowOverride None 86 87 # 88 # Controls who can get stuff from this server. 89 # 90 Require all granted 91</Directory> 92 93# 94# DirectoryIndex: sets the file that Apache will serve if a directory 95# is requested. 96# 97<IfModule dir_module> 98 DirectoryIndex index.html 99</IfModule> 100 101# 102# The following lines prevent .htaccess and .htpasswd files from being 103# viewed by Web clients. 104# 105<Files ".ht*"> 106 Require all denied 107</Files> 108 109# 110 111# 112ErrorLog "logs/error_log" 113 114# 115# LogLevel: Control the number of messages logged to the error_log. 116# Possible values include: debug, info, notice, warn, error, crit, 117# alert, emerg. 118# 119LogLevel warn 120 121<IfModule log_config_module> 122 # 123 # The following directives define some format nicknames for use with 124 # a CustomLog directive (see below). 125 # 126 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 127 LogFormat "%h %l %u %t \"%r\" %>s %b" common 128 129 <IfModule logio_module> 130 # You need to enable mod_logio.c to use %I and %O 131 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio 132 </IfModule> 133 134 # 135 # The location and format of the access logfile (Common Logfile Format). 136 # If you do not define any access logfiles within a <VirtualHost> 137 # container, they will be logged here. Contrariwise, if you *do* 138 # define per-<VirtualHost> access logfiles, transactions will be 139 # logged therein and *not* in this file. 140 # 141 #CustomLog "logs/access_log" common 142 143 # 144 # If you prefer a logfile with access, agent, and referer information 145 # (Combined Logfile Format) you can use the following directive. 146 # 147 CustomLog "logs/access_log" combined 148</IfModule> 149 150<IfModule alias_module> 151 # 152 153 # Example: 154 # Redirect permanent /foo http://www.example.com/bar 155 156 # 157 # Alias: Maps web paths into filesystem paths and is used to 158 # access content that does not live under the DocumentRoot. 159 # Example: 160 # Alias /webpath /full/filesystem/path 161 # 162 163 164 # 165 166 # 167 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" 168 169</IfModule> 170 171# 172# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased 173# CGI directory exists, if you have that configured. 174# 175<Directory "/var/www/cgi-bin"> 176 AllowOverride None 177 Options None 178 Require all granted 179</Directory> 180 181<IfModule mime_module> 182 # 183 # TypesConfig points to the file containing the list of mappings from 184 # filename extension to MIME-type. 185 # 186 TypesConfig /etc/mime.types 187 188 # 189 # AddType allows you to add to or override the MIME configuration 190 # file specified in TypesConfig for specific file types. 191 # 192 #AddType application/x-gzip .tgz 193 # 194 195 # 196 #AddEncoding x-compress .Z 197 #AddEncoding x-gzip .gz .tgz 198 # 199 # If the AddEncoding directives above are commented-out, then you 200 # probably should define those extensions to indicate media types: 201 # 202 AddType application/x-compress .Z 203 AddType application/x-gzip .gz .tgz 204 205 # 206 207 # 208 # To use CGI scripts outside of ScriptAliased directories: 209 # (You will also need to add "ExecCGI" to the "Options" directive.) 210 # 211 #AddHandler cgi-script .cgi 212 213 # For type maps (negotiated resources): 214 #AddHandler type-map var 215 216 # 217 # Filters allow you to process content before it is sent to the client. 218 # 219 # To parse .shtml files for server-side includes (SSI): 220 # (You will also need to add "Includes" to the "Options" directive.) 221 # 222 AddType text/html .shtml 223 AddOutputFilter INCLUDES .shtml 224</IfModule> 225 226# 227 228# 229AddDefaultCharset UTF-8 230 231<IfModule mime_magic_module> 232 # 233 # The mod_mime_magic module allows the server to use various hints from the 234 # contents of the file itself to determine its type. The MIMEMagicFile 235 # directive tells the module where the hint definitions are located. 236 # 237 MIMEMagicFile conf/magic 238</IfModule> 239 240# 241# Customizable error responses come in three flavors: 242# 1) plain text 2) local redirects 3) external redirects 243# 244# Some examples: 245#ErrorDocument 500 "The server made a boo boo." 246#ErrorDocument 404 /missing.html 247#ErrorDocument 404 "/cgi-bin/missing_handler.pl" 248#ErrorDocument 402 http://www.example.com/subscription_info.html 249# 250 251# 252 253# Defaults if commented: EnableMMAP On, EnableSendfile Off 254# 255#EnableMMAP off 256EnableSendfile on 257 258# Enable HTTP/2 by default 259# 260# https://httpd.apache.org/docs/2.4/mod/core.html#protocols 261 262 263<IfModule mod_http2.c> 264 Protocols h2 h2c http/1.1 265</IfModule> 266 267 268# Supplemental configuration 269# 270# Load config files in the "/etc/httpd/conf.d" directory, if any. 271IncludeOptional conf.d/*.conf 272 273 274 275 276 277

ssl.confを設定した上でですが、どこか設定ミスありますでしょうか?

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

AbeTakashi

2021/08/13 03:41

SSL化したときにApacheの設定ファイルが書き換わった(書き換えた?)と思うのですが、その設定ファイルはどうなっているのでしょうか? 基本的にApacheの設定ファイルがどうなっているかを見て、それを調整すれば解決しそうですが。443番ポートを使ってディレクトリを公開しているファイルがどこかに存在するはずです。それを80番ポートを使ってるときと同じように設定してあげればいいだけじゃないでしょうか? 解決が無理そうであればSSL化した手順、現状のApacheの設定ファイルなどを質問文に追加してください。
yukky1201

2021/08/13 04:20

プロトコルとして「http または https」、サイトとして「phpmyadmin または それ以外」があるので4通りの組み合わせが考えられますが、それぞれの結果次第でどこに問題があるか切り分けできると思います。 http で phpmyadmin へアクセス http で phpmyadmin以外 へアクセス https で phpmyadmin へアクセス https で phpmyadmin以外 へアクセス
Athenahack

2021/08/13 06:29

@yukky1201 httpとhttpsでアクセスしたときの違いは既に確認してました。 追記します
AbeTakashi

2021/08/13 10:21

最終行が IncludeOptional conf.d/*.conf となってますのでconf.d以下にssl.confがあるのでしょうか? あと、ssl.confの内容も質問文に追記して頂いた方がいいかもしれません。 あと「Failed to set session cookie. Maybe you are using HTTP instead of HTTPS to access phpMyAdmin.」でgoogleで検索するとphpmyadmin関連でも色々ひっかかりますが、その辺の確認や対応はされたのでしょうか? もしチェックして対応済みのがあれば、そちらの内容も質問文に追記された方がいいでしょう。
Athenahack

2021/08/13 11:12

お答えいただいてありがとうございます。 mod_sslを入れたところinternal server errorが起きてしまったので、一度mod_sslを削除しました。 またcloudfront + lightsailでSSL化するという組み合わせはどうも相性が良くないようなので、lightsailのLBを使ってSSL化を試みます。 また質問文が1万文字のみが上限でssl.confまで入らなかったので載せていません。
guest

回答1

0

自己解決

始めからLAMP環境を構築しなおしました。

そのあとにphpMyAdminを入れてログインできました。

SSL化後になぜか英語表記になる問題でしたが、SSL化後にphpMyAdmin表示してみると日本語でログイン画面表示されました。

ログインすると、phpMyAdminのうホーム画面下部に2つの警告があり一つはmbstringをインストールしてくださいというものと、phpMyAdminディレクトリ配下にあるconfig.sample.inc.phpをコピーしたconfig.inc.phpというファイル内の$cfg['blowfish_secret'] = ''に32文字以上の文字列を入れてくださいという警告文が表示されます。

上記対応すると、問題なくphpMyAdmin使えると思います。
データベースのところにSSlは使用されていませんと表示されますが、ブラウザ上でHTTPS化できているので大丈夫かと思います。

投稿2021/08/17 07:45

Athenahack

総合スコア2

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問