php_modが非推奨になったのね

昔のバージョンのphp環境でphpバージョンを上げるという対応中。 apache + PHP8のインスタンスを構築してドキュメントルートまで到達を確認。 対応する人にドキュメントルートまで到達するからプロジェクトのファイルを置いてバージョンアップのエラーを確認してもらうため依頼しましたが HTTP 503 Service Unavailable のエラーが出ているとのこと。 HTMLファイルはアクセスできているからPHPの実行ができていないと思い調べると Apache HTTP サーバーで使用するために PHP に提供されている mod_php モジュールが非推奨になりました。 php-fpmをインストールして起動し、リクエストを流してphp-fmpでphpを実行するようにして解決。 しばらくPHPを触っていなかったのでモジュールが非推奨になったことに気づかずでした。

今更ながらLaravelを試してみる③

レイアウト崩れで挫折したところから。。

※こちらの記事は以前の2021年前半に書いて下書きだったものを公開しています。自分のメモのために公開しました。


はじめになんですが公式サイト見てたら

sailコマンド

なる記載がありました。
デフォルトのdocker環境を操作するコマンドとあるんで、こっち使おっかななんて考えていますが、通常通りLaravelのプロジェクト作成し他場合のレイアウトの問題も気になるので今回はここを解決しようかと思います。

まずはcss/jsがないことがわかります



前回は気づきませんでしたがこのメッセージが出ているんですね

# php artisan ui vue --auth
Vue scaffolding installed successfully.
Please run "npm install && npm run dev" to compile your fresh scaffolding.
Authentication scaffolding generated successfully.

npm install && npm run dev
を実行してねというので実行
# npm install && npm run dev
bash: npm: command not found
npmをインストールしていないんですね。。。。

npmをインストールします。
# apt-get install npm

するとnodejs/npmがインストールされています。
# npm --version
5.8.0
# node --version
v10.24.0
インストールされたところで先程のコマンドを再度実行してみます。
# npm install && npm run dev

そうするとエラーがでます。。。
Error: You are using an unsupported version of Node. Please update to at least Node v12.14
    at assertSupportedNodeVersion (/var/www/html/laravel/node_modules/laravel-mix/src/Engine.js:6:15)
    at executeScript (/var/www/html/laravel/node_modules/laravel-mix/bin/cli.js:61:5)
    at Command.program.command.description.option.action.cmd (/var/www/html/laravel/node_modules/laravel-mix/bin/cli.js:47:13)
    at Command.listener [as _actionHandler] (/var/www/html/laravel/node_modules/commander/index.js:426:31)
    at Command._parseCommand (/var/www/html/laravel/node_modules/commander/index.js:1002:14)
    at Command._dispatchSubcommand (/var/www/html/laravel/node_modules/commander/index.js:953:18)
    at Command._parseCommand (/var/www/html/laravel/node_modules/commander/index.js:979:12)
    at Command.parse (/var/www/html/laravel/node_modules/commander/index.js:801:10)
    at Command.parseAsync (/var/www/html/laravel/node_modules/commander/index.js:828:10)
    at run (/var/www/html/laravel/node_modules/laravel-mix/bin/cli.js:50:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `mix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-02-25T09_41_14_710Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-02-25T09_41_14_729Z-debug.log
つらつらと長いメッセージですが、要は一番上の部分
You are using an unsupported version of Node. Please update to at least Node v12.14
最低でもv12.14にアップデートしろとな。。。。

デフォルトのパッケージリポジトリ以外で取得するよりnコマンド使えるようにしてバージョン切り替える方が楽な気がするのでそちらを選択

nコマンドでnodeのバージョンを切り替えられるようにする
# npm install n -g

※TODO:後でnコマンドインストール時の-gを調べる


利用できるバージョンを調べる
root@0588ffae6cd4:/var/www/html/laravel# n ls-remote
Listing remote... Displaying 20 matches (use --all to see all).
15.10.0
以下省略・・・
14.16.0
以下省略・・・

https://nodejs.org/ja/
公式サイトにて推奨版は14.16.0なのでこれを利用
後ほどこれを知る
n ls-remote lts


root@0588ffae6cd4:/var/www/html/laravel# n 14.16.0
  installing : node-v14.16.0
       mkdir : /usr/local/n/versions/node/14.16.0
       fetch : https://nodejs.org/dist/v14.16.0/node-v14.16.0-linux-x64.tar.xz
   installed : v14.16.0 (with npm 6.14.11)

Note: the node command changed location and the old location may be remembered in your current shell.
         old : /usr/bin/node
         new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"

シェルのパスが古いかもよ?シェルにログインし直すかPATH="$PATH"を実行してねってことなので
ログインし直す

root@0588ffae6cd4:/var/www/html/laravel# node --version
v14.16.0

でけたよ。

再び
npm install && npm run dev
を実行してみるよ


なんかまたエラーでた。。。

root@0588ffae6cd4:/var/www/html/laravel# npm install && npm run dev
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 1201 packages in 7.074s

93 packages are looking for funding
  run `npm fund` for details

found 1 high severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

> @ dev /var/www/html/laravel
> npm run development


> @ development /var/www/html/laravel
> mix

  Additional dependencies must be installed. This will only take a moment.

  Running: npm install vue-loader@^15.9.5 --save-dev --legacy-peer-deps

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

  Finished. Please run Mix again.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `mix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-02-25T10_01_31_603Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-02-25T10_01_31_618Z-debug.log



ちょっとログは確認したんですがわからず
root@0588ffae6cd4:/var/www/html/laravel# cat /root/.npm/_logs/2021-02-25T10_01_31_618Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'dev' ]
2 info using npm@6.14.11
3 info using node@v14.16.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 info lifecycle @~dev: @
7 verbose lifecycle @~dev: unsafe-perm in lifecycle true
8 verbose lifecycle @~dev: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/html/laravel/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle @~dev: CWD: /var/www/html/laravel
10 silly lifecycle @~dev: Args: [ '-c', 'npm run development' ]
11 silly lifecycle @~dev: Returned: code: 1  signal: null
12 info lifecycle @~dev: Failed to exec dev script
13 verbose stack Error: @ dev: `npm run development`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid @
15 verbose cwd /var/www/html/laravel
16 verbose Linux 4.19.121-linuxkit
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
18 verbose node v14.16.0
19 verbose npm  v6.14.11
20 error code ELIFECYCLE
21 error errno 1
22 error @ dev: `npm run development`
22 error Exit status 1
23 error Failed at the @ dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]




npm install
npm run dev




それぞれを実行したらできました!!

コメント

このブログの人気の投稿

nginxで画像が表示されない。。

AWSのS3バケットをマウントするs3fsでマウントが外れた件

CakePHP3でHTTPSにする