1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

miseを使って、PHPをインストールする

1
Posted at

必要なパッケージをインストールする

PHPの動作に必要な依存パッケージをインストールします。
以下のコマンドを実行してください。

sudo apt update
sudo apt install -y build-essential libxml2-dev libssl-dev libsqlite3-dev \
libcurl4-openssl-dev libjpeg-dev libpng-dev libwebp-dev libxpm-dev \
libfreetype6-dev libonig-dev libzip-dev unzip pkg-config \
autoconf bison re2c libgd-dev

miseを使って、PHPをインストールする

インストールできるバージョンを確認し、バージョンを指定してインストールします。
以下のコマンドを実行してください。 
(8.5.7は、お好きなバージョンを指定してください。)

mise ls-remote php
mise use php@8.5.7

VSCodeを設定する

以下のコマンドを実行して、mise がインストールしたPHPのフルパス(場所)を確認します。
この出力されたパスをコピーしておきます。
(出力例: /home/username/.local/share/mise/installs/php/8.3.x/bin/php)

mise which php

 
VS Codeの設定を開きます(Ctrl + ,)。
検索窓に php.validate.executablePath と入力します。
「Settings.json で編集」というリンクをクリックし、先ほどコピーしたパスを以下のように貼り付けて保存します。
image.png

動作を確認する

動作確認のためのPHPファイルを作成します。

PHP(index.php)
<?php
phpinfo();
?>

 
以下のコマンドを実行します。

php -S localhost:8000 index.php

 
ブラウザで、localhost:8000を表示してください。
image.png
 
以上です。

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?