- 1. 概要
- 2. composer インストール
- 3. モジュールインストール
- 4. ディレクトリ作成
- 5. 所有権の設定
1. 概要
「Laravel」のモジュールインストールに関して述べます。
「Laravel」は、「PHP」のフレームワークですので、この時点で「PHP」のインストールと基本的な設定は、終わっているものとします。
終わっていない場合は、前の方の節をご参照ください。
2. composer インストール
「laravel」のモジュールは、「PHP」の「composer」を通して、インストールします。
なので、まずは、「composer」のインストールから・・・。
ただし、「composer」の「ports」は存在しておるのですが、「composer2」を使わないと怒られちゃいますので、「composer2」をインストールします。
「root」ユーザ権限で。
cd /usr/ports/devel/php-composer2
make config

オプションはデフォルトのままで、一気にインストールします。
cd /usr/ports/devel/php-composer2
make
make install clean
この時点の「composer」のバージョンは、下記のとおりです。
ログインユーザで。
$ composer --version
Composer version 2.4.4 2022-10-27 14:39:29
3. モジュールインストール
「Laravel」のモジュールをインストールします。
これは、「root」ユーザ権限でやると怒られますので、ログインユーザ権限で実行します。
composer global require laravel/installer
下記のようなログが出力され、すんなり、インストールできました。
Changed current directory to /home/hogehoge/.composer
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^4.2 for laravel/installer
./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.2.17)
- Locking psr/container (2.0.2)
- Locking symfony/console (v6.2.2)
・・・ 略 ・・・
- Locking symfony/process (v6.2.0)
- Locking symfony/service-contracts (v3.2.0)
- Locking symfony/string (v6.2.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 11 installs, 0 updates, 0 removals
- Downloading symfony/process (v6.2.0)
- Downloading symfony/polyfill-mbstring (v1.27.0)
- Downloading symfony/polyfill-intl-normalizer (v1.27.0)
・・・ 略 ・・・
- Installing symfony/deprecation-contracts (v3.2.0): Extracting archive
- Installing symfony/console (v6.2.2): Extracting archive
- Installing laravel/installer (v4.2.17): Extracting archive
4 package suggestions were added by new dependencies, use `composer suggest` to see details.
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
すぐ終わったけど、ちゃんと動くかしら、かえって心配。
「Laravel」のモジュールのパスを通しておきます。
わたしは、「tcsh」を使用していますので、「tcsh」を例にとりますが・・・。
vi ~/.cshrc
下記の1行を適切な位置に挿入します。
set path = ($path ~/.composer/vendor/bin )
編集したら、即時反映。
source ~/.cshrc
この時点の「Laravel」のバージョンは、下記のとおりです。
(「FreeBSD 12.3 RELEASE」時は、ここの記述、間違えていました)
$ laravel --version
Laravel Installer 4.2.17
4. ディレクトリ作成
「Laravel」を展開するディレクトリを作成します。
/usr/local/www/mine
の下に「Laravel」ディレクトリを作成するものとして。
グループID「hogehoge」、ユーザID「hogehoge」として
「root」ユーザ権限で。
mkdir -pv /usr/local/www/mine
chown -R hogehoge:hogehoge /usr/local/www/mine
次に、ログインユーザで(ここの例だと「hogehoge」)。
cd /usr/local/www/mine
composer create-project laravel/laravel laravel --prefer-dist
Creating a "laravel/laravel" project at "./laravel"
Info from https://repo.packagist.org: #StandWithUkraine
Installing laravel/laravel (v9.4.1)
- Downloading laravel/laravel (v9.4.1)
- Installing laravel/laravel (v9.4.1): Extracting archive
Created project in /usr/local/www/mine/laravel
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework[v9.36.4, ..., 9.x-dev] require league/flysystem ^3.8.0 -> satisfiable by league/flysystem[3.8.0, ..., 3.x-dev].
- laravel/framework[v9.19.0, ..., v9.36.3] require league/flysystem ^3.0.16 -> satisfiable by league/flysystem[3.0.16, ..., 3.x-dev].
- league/flysystem[3.0.16, ..., 3.x-dev] require league/mime-type-detection ^1.0.0 -> satisfiable by league/mime-type-detection[1.0.0, ..., 1.11.0].
- league/mime-type-detection[1.0.0, ..., 1.3.0] require php ^7.2 -> your php version (8.2.0RC7) does not satisfy that requirement.
- league/mime-type-detection[1.4.0, ..., 1.11.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
- Root composer.json requires laravel/framework ^9.19 -> satisfiable by laravel/framework[v9.19.0, ..., 9.x-dev].
To enable extensions, verify that they are enabled in your .ini files:
- /usr/local/etc/php.ini
- /usr/local/etc/php/ext-10-opcache.ini
- /usr/local/etc/php/ext-18-session.ini
- /usr/local/etc/php/ext-20-ctype.ini
- /usr/local/etc/php/ext-20-curl.ini
- /usr/local/etc/php/ext-20-dom.ini
- /usr/local/etc/php/ext-20-filter.ini
- /usr/local/etc/php/ext-20-gd.ini
- /usr/local/etc/php/ext-20-gettext.ini
- /usr/local/etc/php/ext-20-iconv.ini
- /usr/local/etc/php/ext-20-intl.ini
- /usr/local/etc/php/ext-20-mbstring.ini
- /usr/local/etc/php/ext-20-mysqli.ini
- /usr/local/etc/php/ext-20-pdo.ini
- /usr/local/etc/php/ext-20-pgsql.ini
- /usr/local/etc/php/ext-20-phar.ini
- /usr/local/etc/php/ext-20-posix.ini
- /usr/local/etc/php/ext-20-simplexml.ini
- /usr/local/etc/php/ext-20-sqlite3.ini
- /usr/local/etc/php/ext-20-tokenizer.ini
- /usr/local/etc/php/ext-20-xml.ini
- /usr/local/etc/php/ext-20-xmlwriter.ini
- /usr/local/etc/php/ext-20-zlib.ini
- /usr/local/etc/php/ext-30-pdo_sqlite.ini
- /usr/local/etc/php/ext-30-xmlreader.ini
You can also run 'php --ini' in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with '--ignore-platform-req=ext-fileinfo' to temporarily ignore these required extensions.
ありゃ、失敗。
「php」インストール時のオプションが足りなかったようです。
cd /usr/ports/lang/php82
make config
で、上記足りないものにチェックをいれなおして。
・・・やっぱりだめ。
ここで、どうも「PHP 8.2」では、まだ「FreeBSD」で、「Laravel」の環境をつくることができないらしいことがわかってきました。
いったん、「PHP 8.2」をご破算にして、「PHP 8.0」インストールから、もう一度、やりなおして、ここまでやったところで、ログが
Creating a "laravel/laravel" project at "./laravel"
Installing laravel/laravel (v9.4.1)
- Downloading laravel/laravel (v9.4.1)
- Installing laravel/laravel (v9.4.1): Extracting archive
Created project in /usr/local/www/mine/laravel
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 107 installs, 0 updates, 0 removals
- Locking brick/math (0.10.2)
- Locking dflydev/dot-access-data (v3.0.2)
- Locking doctrine/inflector (2.0.6)
・・・ 略 ・・・
- 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: 107 installs, 0 updates, 0 removals
- Downloading doctrine/inflector (2.0.6)
- Downloading doctrine/lexer (1.2.3)
- Downloading webmozart/assert (1.11.0)
・・・ 略 ・・・
- Installing spatie/flare-client-php (1.3.1): Extracting archive
- Installing spatie/ignition (1.4.1): Extracting archive
- Installing spatie/laravel-ignition (1.6.2): Extracting archive
63 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
81 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.
「PHP 8.2」と「PHP 8.0」とで、ここまでの手順に相違はなかったので、今んとこ、「Laravel」を使用するには「FreeBSD」では、「PHP 8.0」を使うべしと結論が出ました。
これで、元となるものは展開できました。
5. 所有権の設定
「Laravel」を動作させる上で、ログやキャッシュのフォルダは、「www」の所有権にしておかないと権限エラーになるものがあります。
「root」ユーザ権限で、下記の設定を行います。
chown -R www:www /usr/local/www/mine/laravel/bootstrap/cache
chown -R www:www /usr/local/www/mine/laravel/storage/framework
chown -R www:www /usr/local/www/mine/laravel/storage/logs
|