PHP - Laravel - インストール - PHP 8.2 - インストール

クラウディア 
1. 概要
2. インストール
3. プロジェクト作成
4. 所有権の設定

1. 概要

 前回は、他のサイトを参考にしましたが、今回は、本サイトの前回分を参考にやってみます。

2. インストール

 「Laravel」をインストールします。  ログインユーザで(ホームディレクトリ上で)。

composer global require laravel/installer
 ログが、ずらずらと表示されますが、すぐに終わりました。

Changed current directory to /home/hogehoge/.composer
Info from https://repo.packagist.org: #StandWithUkraine
./composer.json has been created
Running composer update laravel/installer
Loading composer repositories with package information
Updating dependencies
Lock file operations: 11 installs, 0 updates, 0 removals
  - Locking laravel/installer (v4.5.0)
  - Locking psr/container (2.0.2)
  - Locking symfony/console (v6.3.0)
  - Locking symfony/deprecation-contracts (v3.3.0)
  - Locking symfony/polyfill-ctype (v1.27.0)
  - Locking symfony/polyfill-intl-grapheme (v1.27.0)
  - Locking symfony/polyfill-intl-normalizer (v1.27.0)
  - Locking symfony/polyfill-mbstring (v1.27.0)
  - Locking symfony/process (v6.3.0)
  - Locking symfony/service-contracts (v3.3.0)
  - Locking symfony/string (v6.3.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 11 installs, 0 updates, 0 removals
  - Downloading symfony/process (v6.3.0)
  - Downloading symfony/polyfill-mbstring (v1.27.0)
  - Downloading symfony/polyfill-intl-normalizer (v1.27.0)
  - Downloading symfony/polyfill-intl-grapheme (v1.27.0)
  - Downloading symfony/polyfill-ctype (v1.27.0)
  - Downloading symfony/string (v6.3.0)
  - Downloading psr/container (2.0.2)
  - Downloading symfony/service-contracts (v3.3.0)
  - Downloading symfony/deprecation-contracts (v3.3.0)
  - Downloading symfony/console (v6.3.0)
  - Downloading laravel/installer (v4.5.0)
  - Installing symfony/process (v6.3.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.27.0): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.27.0): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.27.0): Extracting archive
  - Installing symfony/polyfill-ctype (v1.27.0): Extracting archive
  - Installing symfony/string (v6.3.0): Extracting archive
  - Installing psr/container (2.0.2): Extracting archive
  - Installing symfony/service-contracts (v3.3.0): Extracting archive
  - Installing symfony/deprecation-contracts (v3.3.0): Extracting archive
  - Installing symfony/console (v6.3.0): Extracting archive
  - Installing laravel/installer (v4.5.0): Extracting archive
Generating autoload files
9 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found
Using version ^4.5 for laravel/installer
 実際には、もっとカラフルな表示です。  (2行目の「StandWithUkraine」の末尾は、あのウクライナかしら?)  パスを通しておきます(「~/.cshrc」や「~/.bashrc」に記述すべき)。  ここでは、「tcsh」で

set path = ($path ~/.composer/vendor/bin )

3. プロジェクト作成

 次に、ユーザに書き込み権限のあるディレクトリでプロジェクトを作成します。  プロジェクト名を「lara」として。  ログインユーザで

laravel new lara
 すると

  _                               _
  | |                             | |
  | |     __ _ _ __ __ ___   _____| |
  | |    / _` | '__/ _` \ \ / / _ \ |
  | |___| (_| | | | (_| |\ V /  __/ |
  |______\__,_|_|  \__,_| \_/ \___|_|

Creating a "laravel/laravel" project at "./lara"
Info from https://repo.packagist.org: #StandWithUkraine
Installing laravel/laravel (v10.2.4)
  - Downloading laravel/laravel (v10.2.4)
  - Installing laravel/laravel (v10.2.4): Extracting archive
Created project in /usr/local/www/lara
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 108 installs, 0 updates, 0 removals
  - Locking brick/math (0.11.0)
  - Locking dflydev/dot-access-data (v3.0.2)
  - Locking doctrine/inflector (2.0.8)

・・・	略	・・・

  - Locking vlucas/phpdotenv (v5.5.0)
  - 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: 108 installs, 0 updates, 0 removals
  - Downloading doctrine/inflector (2.0.8)
  - Downloading doctrine/lexer (3.0.0)
  - Downloading webmozart/assert (1.11.0)

・・・	略	・・・

  - Downloading spatie/flare-client-php (1.4.0)
  - Downloading spatie/ignition (1.9.0)
  - Downloading spatie/laravel-ignition (2.2.0)
  - Installing doctrine/inflector (2.0.8): Extracting archive
  - Installing doctrine/lexer (3.0.0): Extracting archive
  - Installing symfony/polyfill-ctype (v1.27.0): Extracting archive

・・・	略	・・・

  - Installing spatie/flare-client-php (1.4.0): Extracting archive
  - Installing spatie/ignition (1.9.0): Extracting archive
  - Installing spatie/laravel-ignition (2.2.0): Extracting archive
52 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

82 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.

   INFO  Application ready! Build something amazing.
 「successfully」になっています。  うまくインストールできたようです。

4. 所有権の設定

 これ、実は、後ろの方にも書いちゃったので、重複しますが、いずれやる必要があるので・・・。  「Laravel」を動作させる上で、ログやキャッシュのフォルダは、「www」の所有権にしておかないと権限エラーになるものがあります。  このあたり、「smarty」あたりと同様ですな。  「root」ユーザ権限で、下記の設定を行います。  今回、プロジェクトパスを

/usr/local/www/lara
 にしていますので

chown -R www:www /usr/local/www/lara/bootstrap/cache
chown -R www:www /usr/local/www/lara/storage/framework
chown -R www:www /usr/local/www/lara/storage/logs
earthcar(アースカー)