📢 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
# Apache2の場合
sudo vi /etc/apache2/vhosts.d/vhost-laravel01.conf
<br>
<br>
  <syntaxhighlight lang="nginx">
  <syntaxhighlight lang="nginx">
160行目: 166行目:
   
   
     location / {
     location / {
         root   /home/<ユーザ名>/htdocs/laravel01/public;
         root       /home/<ユーザ名>/htdocs/laravel01/public;
         index index.php index.html index.htm;
         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 $document_root$fastcgi_script_name;
         fastcgi_param  SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        # proxy_pass  http://127.0.0.1;
     }
     }
   
   
    # 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>
==== NginXを使用している場合 ====
Laravelでは、全てのリクエストをindex.phpにルーティングする。<br>
<br>
NginXでLaravelを使用する場合、<code>location /</code>ディレクティブに<code>try_files</code>ディレクティブが含まれている必要がある。<br>
これにより、Laravelのルーティングが正しく機能する。<br>
<br>
<syntaxhighlight lang="nginx">
# 例: NginXの設定例
# 1. リクエストは最初に rootディレクティブに指定されたディレクトリの同名ファイルを探す。
# 2. 見つからない場合は、index.phpにフォールバックして、Laravelのルーティングが処理する。
location / {
    root        /home/suse/Program/htdocs/laravel9_02/public;
    index      index.php index.html index.htm;
    try_files  $uri $uri/ /index.php?$query_string;
}
location ~ \.php$
{
    fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index  index.php;
    include        fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
}
</syntaxhighlight>
<br><br>
== エラー関連 ==
== エラー関連 ==
==== swiftmailer/swiftmailerライブラリ ====
==== swiftmailer/swiftmailerライブラリ ====