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

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

新規登録して質問してみよう
ただいま回答率
85.50%
AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

2回答

4341閲覧

AWSで自動デプロイしたいが、エラーコードScriptFailedになりデプロイできない。

SETO22

総合スコア3

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2021/04/08 14:28

編集2021/04/09 09:07

前提・実現したいこと

codedeploy,codepipelineを用いた自動デプロイを実装したい。

発生している問題・エラーメッセージ

イベントログ(aws codeDeproyのイベントログページ)

イベントの詳細 エラーコード ScriptFailed スクリプト名 scripts/start_server メッセージ Script at specified location: scripts/start_server run as user root failed with exit code 1

ログ

LifecycleEvent - BeforeInstall Script - scripts/install_dependencies [stdout]Loaded plugins: extras_suggestions, langpacks, priorities, update-motd [stdout]39 packages excluded due to repository priority protections [stdout]Package httpd-2.4.46-1.amzn2.x86_64 already installed and latest version [stdout]Nothing to do Script - scripts/start_server [stderr]Redirecting to /bin/systemctl start httpd.service [stderr]Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

試したこと

codeDeploy agentを再起動。
The AWS CodeDeploy agent is running as PID 6314となった。
何が原因かは不明ですが、もしご存知の方がいらっしゃったらご教授していただけると幸いです。
状態が分かり次第、追記していきます。

補足情報(FW/ツールのバージョンなど

Rails 6.0.3.4
ruby 2.6.5p114
nginx 1.12.2
unicorn 5.8.0

###追記
conf/httpd.confの中身です。※字数制限のため、コメントアウト部を一部添削しています。

ServerRoot "/etc/httpd" Listen 80 Include conf.modules.d/*.conf User apache Group apache ServerAdmin root@localhost <Directory /> AllowOverride none Require all denied </Directory> # # Note that from this point forward you must specifically allow # particular features to be enabled - so if something's not working as # you might expect, make sure that you have specifically enabled it # below. # # # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "/var/www/html" # # Relax access to content within /var/www. # <Directory "/var/www"> AllowOverride None # Allow open access: Require all granted </Directory> # Further relax access to the default document root: <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None </Directory> # # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.html </IfModule> # # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # <Files ".ht*"> Require all denied </Files> # # ErrorLog: The location of the error log file. # If you do not specify an ErrorLog directive within a <VirtualHost> # container, error messages relating to that virtual host will be # logged here. If you *do* define an error logfile for a <VirtualHost> # container, that host's errors will be logged there and not here. # ErrorLog "logs/error_log" # # LogLevel: Control the number of messages logged to the error_log. # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. # LogLevel warn <IfModule log_config_module> # # The following directives define some format nicknames for use with # a CustomLog directive (see below). # LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> # You need to enable mod_logio.c to use %I and %O LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "logs/access_log" combined </IfModule> <IfModule alias_module> # # Redirect: Allows you to tell clients about documents that used to # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location. # Example: # Redirect permanent /foo http://www.example.com/bar # # Alias: Maps web paths into filesystem paths and is used to # access content that does not live under the DocumentRoot. # Example: # Alias /webpath /full/filesystem/path # # If you include a trailing / on /webpath then the server will # require it to be present in the URL. You will also likely # need to provide a <Directory> section to allow access to # the filesystem path. # # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias # directives as to Alias. # ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" </IfModule> # # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists, if you have that configured. # <Directory "/var/www/cgi-bin"> AllowOverride None Options None Require all granted </Directory> <IfModule mime_module> # # TypesConfig points to the file containing the list of mappings from # filename extension to MIME-type. # TypesConfig /etc/mime.types # # AddType allows you to add to or override the MIME configuration # file specified in TypesConfig for specific file types. # #AddType application/x-gzip .tgz # # AddEncoding allows you to have certain browsers uncompress # information on the fly. Note: Not all browsers support this. # #AddEncoding x-compress .Z #AddEncoding x-gzip .gz .tgz # # If the AddEncoding directives above are commented-out, then you # probably should define those extensions to indicate media types: # AddType application/x-compress .Z AddType application/x-gzip .gz .tgz # # AddHandler allows you to map certain file extensions to "handlers": # actions unrelated to filetype. These can be either built into the server # or added with the Action directive (see below) # # To use CGI scripts outside of ScriptAliased directories: # (You will also need to add "ExecCGI" to the "Options" directive.) # #AddHandler cgi-script .cgi # For type maps (negotiated resources): #AddHandler type-map var # # Filters allow you to process content before it is sent to the client. # # To parse .shtml files for server-side includes (SSI): # (You will also need to add "Includes" to the "Options" directive.) # AddType text/html .shtml AddOutputFilter INCLUDES .shtml </IfModule> # # Specify a default charset for all content served; this enables # interpretation of all content as UTF-8 by default. To use the # default browser choice (ISO-8859-1), or to allow the META tags # in HTML content to override this choice, comment out this # directive: # AddDefaultCharset UTF-8 <IfModule mime_magic_module> # # The mod_mime_magic module allows the server to use various hints from the # contents of the file itself to determine its type. The MIMEMagicFile # directive tells the module where the hint definitions are located. # MIMEMagicFile conf/magic </IfModule> # # Customizable error responses come in three flavors: # 1) plain text 2) local redirects 3) external redirects # # Some examples: #ErrorDocument 500 "The server made a boo boo." #ErrorDocument 404 /missing.html #ErrorDocument 404 "/cgi-bin/missing_handler.pl" #ErrorDocument 402 http://www.example.com/subscription_info.html # # # EnableMMAP and EnableSendfile: On systems that support it, # memory-mapping or the sendfile syscall may be used to deliver # files. This usually improves server performance, but must # be turned off when serving from networked-mounted # filesystems or if support for these functions is otherwise # broken on your system. # Defaults if commented: EnableMMAP On, EnableSendfile Off # #EnableMMAP off EnableSendfile on # Enable HTTP/2 by default # # https://httpd.apache.org/docs/2.4/mod/core.html#protocols <IfModule mod_http2.c> Protocols h2 h2c http/1.1 </IfModule> # Supplemental configuration # # Load config files in the "/etc/httpd/conf.d" directory, if any. IncludeOptional conf.d/*.conf

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

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

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

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

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

guest

回答2

0

ベストアンサー

よくよく考えたらnginxを使っているのにも関わらずapacheを起動しようとしているのでおそらくポートがバッティングしてapacheの起動がエラーになっています。
そもそもnginxを使っているのにapacheを起動する理由がないのでscripts/start_serverを修正してください。
この構成でApacheは不要でしょう。

とりあえず、httpdを指定しているところをnginxに直すだけであれば

bash

1#!/bin/bash 2systemctl restart nginx 3

※serviceコマンドは古いコマンドなのでsystemctlに直しています。

…ただ、unicorn周りのことを何もしていないように見えるので本当にこれだけでいいのかは疑問です。

投稿2021/04/09 10:00

yu_1985

総合スコア7427

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

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

SETO22

2021/04/10 04:41 編集

新たなご回答ありがとうございます。 yu_1985様の仰る通り、systemctl restart nginxにしたらエラーが解決。 デプロイが成功いたしました。 度重なるご指摘をいただき、本当にありがとうございます。
guest

0

単純にスクリプトの実行時にエラーになってるんじゃないですかね。
実行しているスクリプトの中身はどうなってますか?

また、おそらくApacheの起動周りでエラーになってます。
Apacheのconfigはどうなってますか?

投稿2021/04/08 14:52

yu_1985

総合スコア7427

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

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

SETO22

2021/04/08 16:36

ご指摘いただきありがとうございます。 以下、回答になります。 ->また、おそらくApacheの起動周りでエラーになってます。 Apacheのconfigはどうなってますか? A.syntax OKと出力されました。 ->実行しているスクリプトの中身はどうなってますか? A.実行しているスクリプトの中身を出力するコマンドがわかりません。 もしよろしければお教えできますでしょうか? よろしくお願いいたします。
yu_1985

2021/04/09 01:26

configtestの結果ではなく中身を貼ってください。 コマンドもなにも、CodeDeployで動かすスクリプトは自分で作って使用しているのではないでしょうか…? start_serverの中身を貼ってください。
SETO22

2021/04/09 09:10

ご返信ありがとうございます。 以下、回答になります。 -> start_serverの中身を貼ってください。 location: scripts/start_server timeout: 300 runas: root appspec.ymlに記述してあるものです。 -> configtestの結果ではなく中身を貼ってください。 追記いたしました。しかし、字数制限のためコメントアウト部を一部添削しています。 よろしくお願いいたします。
yu_1985

2021/04/09 09:13 編集

appspecの記載ではなくて、そこで実行しているscripts/start_serverの中身を貼ってください。 その記載通りならscriptsディレクトリの中にありますよね? httpd.confではなくて、Includeしている/etc/httpd/conf.d/内にあるファイルのほうを貼ってください。 このhttpd.confはおそらくデフォルトのままです。
SETO22

2021/04/09 09:45

ご返信ありがとうございます。 以下、回答になります。 -> httpd.confではなくて、Includeしている/etc/httpd/conf.d/内にあるファイルのほうを貼ってください。 README autoindex.conf userdir.conf welcome.conf 上記4つのファイルがありましたが、どのファイルでしょうか? ご指摘願います。 -> appspecの記載ではなくて、そこで実行しているscripts/start_serverの中身を貼ってください。 #!/bin/bash service httpd start よろしくお願いいたします。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問