LoginSignup
3
2

More than 5 years have passed since last update.

一番簡単にPHPでローカル開発サーバーを立てるコマンド

Posted at

index.phpのある場所でこのコマンド一発

php -S localhost:8000
http://localhost:8000
にアクセスしたら見れます。

もうちょっと詳細に

command
//cdコマンドでプロジェクト直下に入る。
cd Desktop
cd project

//PHPビルトインサーバーを立てる。どれでもいい。
php -S localhost:8000

//もしうごかなければ下記で試す
php -S 0.0.0.0:8000
php -S 127.0.0.1:8000


//サーバーが立つとこんなメッセージが出る。

MacBook-Air:project user$ php -S localhost:8000
PHP 5.6.22 Development Server started at Thu Nov 17 16:23:42 2016
Listening on http://localhost:8000
Document root is /Users/user/Desktop/project
Press Ctrl-C to quit.

//下記URLにアクセスして表示されたら成功。
http://localhost:8000

プロジェクト直下、もしくはindex.phpを置いてる場所で起動します。

簡単にサーバーを立てれるので重宝しますが、たしかhtaccessとかは動かないはずなので簡易的なものであるという点は一応注意する。だがほとんどの場合はこれで問題ない。
ワードプレスとかはほとんどこれでいける。

3
2
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
3
2