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

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

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

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

AWS(Amazon Web Services)

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

Laravel 5

Laravel 5は、PHPフレームワークLaravelの最新バージョンで、2014年11月に発表予定です。ディレクトリ構造がが現行版より大幅に変更されるほか、メソッドインジェクションやFormRequestの利用が可能になります。

Q&A

1回答

3451閲覧

Laravel5をApache2.4.23の環境で動作させたい

kra8

総合スコア79

Apache

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

AWS(Amazon Web Services)

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

Laravel 5

Laravel 5は、PHPフレームワークLaravelの最新バージョンで、2014年11月に発表予定です。ディレクトリ構造がが現行版より大幅に変更されるほか、メソッドインジェクションやFormRequestの利用が可能になります。

0グッド

0クリップ

投稿2016/12/14 08:53

編集2016/12/16 11:57

他サイトを参考に、Laravelを導入しApacheの設定を行なっていきましたが、Apatch2.2系を入れてしまったため、一度アンイストールを行なって、Apach2.4.23を導入しました。
Apatch2.2時には正常に動作していたのですが、アップデート後に「Amazon Linux AMI Test Page」というページが表示されてしまいます。

/etc/httpd/conf/httpd.confファイルを編集したのですが、正しく編集できていないかもしれません。

原因は、DocumentRootが見つかっていないか、.htaccessが読み込まれていないかだと思うのですが、解決方法がわかりません。

・httpd.conf

## 略 ## # # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # ServerName www.subdomain.example.com # # Deny access to the entirety of your server's filesystem. You must # explicitly permit access to web content directories in other # <Directory> blocks below. # <Directory /> AllowOverride All Require all denied </Directory> # # 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/laravel/public" # # Relax access to content within /var/www. # <Directory "/var/www"> AllowOverride All # Allow open access: Require all granted </Directory> # Further relax access to the default document root: <Directory "/var/www"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks #Options FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All # # Controls who can get stuff from this server. # Require all granted </Directory> # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.html </IfModule> ## 略 ##

・各ソフトウェアのバージョン

$ cat /proc/version Linux version 4.4.30-32.54.amzn1.x86_64 (mockbuild@gobi-build-60008) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 10 15:52:05 UTC 2016 $ php -v PHP 7.0.13 (cli) (built: Nov 8 2016 20:28:51) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.13, Copyright (c) 1999-2016, by Zend Technologies $ httpd -v Server version: Apache/2.4.23 (Amazon) Server built: Jul 29 2016 21:42:17 $ php artisan -V Laravel Framework version 5.3.18

追記

ディレクトクリ構成は
/var/www/laravel/public/となっています。
laravelではプロジェクトフォルダ内のpublicにドキュメントルートを合わせることで、動作する予定で、apatche2.2系では動作していました。


追記2
/etc/httpd/conf/conf.d/*.confに該当するファイルは以下の4つです。

・notrace.conf

# This directive overrides the behavior of TRACE for both the core server and # mod_proxy. The default TraceEnable on permits TRACE requests per RFC 2616, # which disallows any request body to accompany the request. TraceEnable off # causes the core server and mod_proxy to return a 405 (Method not allowed) # error to the client. TraceEnable off

・welcome.conf
Amazon Linux AMIを作成したときに自動生成されるファイルと思います。
ドキュメントルートが見つからない場合、
/var/www/noindex/index.htmlが表示されます。
このページ内容が「Amazon Linux AMI Test Page」にあたります。

# # This configuration file enables the default "Welcome" page if there # is no default index page present for the root URL. To disable the # Welcome page, comment out all the lines below. # # NOTE: if this file is removed, it will be restored on upgrades. # <LocationMatch "^/+$"> Options -Indexes ErrorDocument 403 /.noindex.html </LocationMatch> <Directory /var/www/noindex> AllowOverride None Require all granted </Directory> Alias /.noindex.html /var/www/noindex/index.html

・autoindex.conf

# # Directives controlling the display of server-generated directory listings. # # Required modules: mod_authz_core, mod_authz_host, # mod_autoindex, mod_alias # # To see the listing of a directory, the Options directive for the # directory must include "Indexes", and the directory must not contain # a file matching those listed in the DirectoryIndex directive. # # # IndexOptions: Controls the appearance of server-generated directory # listings. # IndexOptions FancyIndexing HTMLTable VersionSort # We include the /icons/ alias for FancyIndexed directory listings. If # you do not use FancyIndexing, you may comment this out. # Alias /icons/ "/var/www/icons/" <Directory "/var/www/icons"> Options Indexes MultiViews FollowSymlinks AllowOverride None Require all granted </Directory> # # AddIcon* directives tell the server which icon to show for different # files or filename extensions. These are only displayed for # FancyIndexed directories. # AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip AddIconByType (TXT,/icons/text.gif) text/* AddIconByType (IMG,/icons/image2.gif) image/* AddIconByType (SND,/icons/sound2.gif) audio/* AddIconByType (VID,/icons/movie.gif) video/* AddIcon /icons/binary.gif .bin .exe AddIcon /icons/binhex.gif .hqx AddIcon /icons/tar.gif .tar AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip AddIcon /icons/a.gif .ps .ai .eps AddIcon /icons/layout.gif .html .shtml .htm .pdf AddIcon /icons/text.gif .txt AddIcon /icons/c.gif .c AddIcon /icons/p.gif .pl .py AddIcon /icons/f.gif .for AddIcon /icons/dvi.gif .dvi AddIcon /icons/uuencoded.gif .uu AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl AddIcon /icons/tex.gif .tex AddIcon /icons/bomb.gif core. AddIcon /icons/back.gif .. AddIcon /icons/hand.right.gif README AddIcon /icons/folder.gif ^^DIRECTORY^^ AddIcon /icons/blank.gif ^^BLANKICON^^ # # DefaultIcon is which icon to show for files which do not have an icon # explicitly set. # DefaultIcon /icons/unknown.gif # # AddDescription allows you to place a short description after a file in # server-generated indexes. These are only displayed for FancyIndexed # directories. # Format: AddDescription "description" filename # #AddDescription "GZIP compressed document" .gz #AddDescription "tar archive" .tar #AddDescription "GZIP compressed tar archive" .tgz # # ReadmeName is the name of the README file the server will look for by # default, and append to directory listings. # # HeaderName is the name of a file which should be prepended to # directory indexes. ReadmeName README.html HeaderName HEADER.html # # IndexIgnore is a set of filenames which directory indexing should ignore # and not include in the listing. Shell-style wildcarding is permitted. # IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

・userdir.conf

# # UserDir: The name of the directory that is appended onto a user's home # directory if a ~user request is received. # # The path to the end user account 'public_html' directory must be # accessible to the webserver userid. This usually means that ~userid # must have permissions of 711, ~userid/public_html must have permissions # of 755, and documents contained therein must be world-readable. # Otherwise, the client will only receive a "403 Forbidden" message. # <IfModule mod_userdir.c> # # UserDir is disabled by default since it can confirm the presence # of a username on the system (depending on home directory # permissions). # UserDir disabled # # To enable requests to /~user/ to serve the user's public_html # directory, remove the "UserDir disabled" line above, and uncomment # the following line instead: # #UserDir public_html </IfModule> # # Control access to UserDir directories. The following is an example # for a site where these directories are restricted to read-only. # <Directory "/home/*/public_html"> AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS </Directory>

追記
色々調べた結果、どうやらphp7が動作していませんでした。
ただ、サーバでphp -vは実行できるため、
apatche上でphpが動いていないように思います。
何かphpが使えるようにする設定があるのでしょうか?

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

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

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

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

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

moonphase

2016/12/15 00:34

ディレクトリ構成はどうなっていますか?
moonphase

2016/12/16 06:17

/etc/httpd/conf/conf.d/*.conf に該当するファイルがあれば、それも載せてください
guest

回答1

0

環境が違うので的外れかもしれませんが、Laravelが稼働している私の.htaccessの内容は下記の通りです。

xml

1<IfModule mod_rewrite.c> 2 <IfModule mod_negotiation.c> 3 Options -MultiViews 4 </IfModule> 5 6 RewriteEngine On 7 8 # Redirect Trailing Slashes If Not A Folder... 9 RewriteCond %{REQUEST_FILENAME} !-d 10 RewriteRule ^(.*)/$ /$1 [L,R=301] 11 12 # Handle Front Controller... 13 RewriteCond %{REQUEST_FILENAME} !-d 14 RewriteCond %{REQUEST_FILENAME} !-f 15 RewriteRule ^ index.php [L] 16 17 # Handle Authorization Header 18 RewriteCond %{HTTP:Authorization} . 19 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 20</IfModule>

どこかに違いがあったりしませんか?

投稿2016/12/14 09:21

編集2016/12/15 00:21
motuo

総合スコア3027

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

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

kra8

2016/12/14 09:28 編集

回答ありがとうございます。 Rewrite機能は使ったことがないため、判断できませんでした。 Laravelを稼働させるためにRewrite機能はあったほうがよいでしょうか?
motuo

2016/12/15 00:23

上記の回答内容に誤りがあった為に修正しました。(別のコードのソースを貼っていました。。。)本当に申し訳ございません。 上記のコードはLaravelを初期インストールした時に自動で生成される様で、私の環境ですとこれが無いとLaravelの最初のページを開くことができませんでした。
kra8

2016/12/15 01:27

いえいえ、回答ありがとうございます。 確認したところ、. htaccessのファイル内容は全く同じでした。
motuo

2016/12/15 02:38

「IfModule dir_module」の記述をindex.htmlではなく、index.phpに変えてみては如何でしょうか?
kra8

2016/12/16 09:04

index.phpに変えてみましたが、変わらずでした。
motuo

2016/12/19 04:18

centosですと、「/usr/lib64/httpd/modules」に「libphp7.so 」があるはずなのですが、そちらの環境にその様なファイルはありますでしょうか。合ったとしたら、httpd.confの「Dynamic Shared Object (DSO) Support」に下記の設定を追加してみては如何でしょうか。 # ApacheにPHP7のモジュールを読み込ませる記述 LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問