LoginSignup
0
0

More than 1 year has passed since last update.

エックスサーバーでLaravelのartisanコマンドが使えない

Posted at

現象

エックスサーバーにLaravelプロジェクトをアップロード後、SSH接続して「php artisan ~~~」を実行すると、以下のようなエラーが出る。

PHP Parse error:  syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/rgblog/reallygood-kaitori.com/reallygood-kaitori/artisan on line 33

解決方法

1. 「whereis php」コマンドを実行

下記のようなPHPコマンド一覧が表示される。

image.png

適当なコマンドを選択して「artisan」コマンドを実行

「whereis php」で出てきたPHPコマンド一覧から、現在の環境にあったコマンドを選択
→「artisan」コマンド実行で、上手く機能します。

image.png

なぜエラーが起きたのか

「php -v」コマンドを実行してみましょう。

エックスサーバーのデフォルトのPHPバージョンが古すぎる(下記画像では「5.4.16」)のが原因です。

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0