📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)
| (同じ利用者による、間の3版が非表示) | |||
| 131行目: | 131行目: | ||
<u>※注意</u><br> | <u>※注意</u><br> | ||
<u>Laravelのプロジェクトディレクトリにあるpublicディレクトリがドキュメントルートであるため、このディレクトリをアクセスするように設定する。</u><br> | <u>Laravelのプロジェクトディレクトリにあるpublicディレクトリがドキュメントルートであるため、このディレクトリをアクセスするように設定する。</u><br> | ||
<br> | |||
Laravelでは、全てのリクエストをindex.phpにルーティングする。<br> | |||
<br> | |||
NginXでLaravelを使用する場合、<code>location /</code>ディレクティブに<code>try_files</code>ディレクティブが含まれている必要がある。<br> | |||
これにより、Laravelのルーティングが正しく機能する。<br> | |||
<br> | |||
# リクエストは、まず、rootディレクティブに指定されたディレクトリの同名ファイルを探す。 | |||
# 見つからない場合は、index.phpにフォールバックして、Laravelのルーティングが処理する。 | |||
<br> | |||
# NginXの場合 | # NginXの場合 | ||
sudo vi /etc/nginx/vhosts.d/vhost-laravel01.conf | sudo vi /etc/nginx/vhosts.d/vhost-laravel01.conf | ||
<br> | <br> | ||
<syntaxhighlight lang="nginx"> | <syntaxhighlight lang="nginx"> | ||
| 160行目: | 166行目: | ||
location / { | location / { | ||
root | root /home/<ユーザ名>/htdocs/laravel01/public; | ||
index | index index.php index.html index.htm; | ||
try_files $uri $uri/ /index.php?$query_string; | |||
} | } | ||
| 171行目: | 178行目: | ||
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; | fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; | ||
#fastcgi_pass 127.0.0.1:9000; | #fastcgi_pass 127.0.0.1:9000; | ||
#proxy_pass http://127.0.0.1; | |||
fastcgi_index index.php; | fastcgi_index index.php; | ||
include fastcgi_params; | include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | ||
} | } | ||
# mp3ファイルを設定する場合 | |||
location /mp3 { | location /mp3 { | ||
# sendfile関数の使用の有効化 / 無効化 | # sendfile関数の使用の有効化 / 無効化 | ||
| 191行目: | 197行目: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<br> | |||
# Apache2の場合 | |||
sudo vi /etc/apache2/vhosts.d/vhost-laravel01.conf | |||
<br> | <br> | ||
<syntaxhighlight lang="apache"> | <syntaxhighlight lang="apache"> | ||
| 406行目: | 415行目: | ||
* MCrypt PHP拡張モジュールは動作可能かどうか確認する。 | * MCrypt PHP拡張モジュールは動作可能かどうか確認する。 | ||
<br> | <br> | ||
== エラー関連 == | == エラー関連 == | ||
==== swiftmailer/swiftmailerライブラリ ==== | ==== swiftmailer/swiftmailerライブラリ ==== | ||