PHP - Laravel - Apache - プロジェクト作成

 クラウディア
1. 概要
2. 作成
3. 所有権の設定

1. 概要

 プロジェクト作成方法は、前章で記述しているのですが、試行錯誤部分も書いているので、少しわかりにくい部分もありますし、ここで「apache」と連動させる部分について記述するうえで、改めて、プロジェクトの作成について書いておきます。  以下、「FreeBSD 13.1 RELEASE」「PHP 8.0.23」「Laravel Framework 9.28.0」での操作です。

2. 作成

 ログインユーザで、カレントディレクトリを作成するプロジェクトの上位ディレクトリにして。

composer create-project laravel/laravel プロジェクト名 --prefer-dist
 そうしますと、およそ下記のようにコンソールに出力されまして。

Creating a "laravel/laravel" project at "./プロジェクト名"
Info from https://repo.packagist.org: #StandWithUkraine
Installing laravel/laravel (v9.3.7)
  - Downloading laravel/laravel (v9.3.7)
  - Installing laravel/laravel (v9.3.7): Extracting archive
Created project in /パス/プロジェクト名
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 105 installs, 0 updates, 0 removals
  - Locking brick/math (0.10.2)
  - Locking dflydev/dot-access-data (v3.0.1)

・・・	略	・・・

  - Locking voku/portable-ascii (2.0.1)
  - Locking webmozart/assert (1.11.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 105 installs, 0 updates, 0 removals
  - Downloading doctrine/inflector (2.0.5)
  - Downloading doctrine/lexer (1.2.3)

・・・	略	・・・

  - Downloading spatie/ignition (1.4.1)
  - Downloading spatie/laravel-ignition (1.4.1)
  - Installing doctrine/inflector (2.0.5): Extracting archive
  - Installing doctrine/lexer (1.2.3): Extracting archive

・・・	略	・・・

  - Installing spatie/ignition (1.4.1): Extracting archive
  - Installing spatie/laravel-ignition (1.4.1): Extracting archive
61 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.

  laravel/sail ............................................................................................. DONE
  laravel/sanctum .......................................................................................... DONE
  laravel/tinker ........................................................................................... DONE
  nesbot/carbon ............................................................................................ DONE
  nunomaduro/collision ..................................................................................... DONE
  nunomaduro/termwind ...................................................................................... DONE
  spatie/laravel-ignition .................................................................................. DONE

79 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force

   INFO  No publishable resources for tag [laravel-assets].

No security vulnerability advisories found
> @php artisan key:generate --ansi

   INFO  Application key set successfully.
 「successfully」ちゅうことなので、プロジェクトは、無事作成できております。

3. 所有権の設定

 「Laravel」を動作させる上で、ログやキャッシュのフォルダは、「www」の所有権にしておかないと権限エラーになるものがあります。  「root」ユーザ権限で、下記の設定を行います。

chown -R www:www /プロジェクトパス/bootstrap/cache
chown -R www:www プロジェクトパス/storage/framework
chown -R www:www プロジェクトパス/storage/logs
earthcar(アースカー)