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

More than 5 years have passed since last update.

【Apache】localhost接続方法

Posted at

Apacheって何?

サーバーソフト。
PHPなどの言語はサーバーがあって初めて成り立つもの。

でも、サーバーにはお金がかかります。
なのに、開発フェーズからサーバー代にお金はかけられない。

そこで活躍するのがApacheと呼ばれれるサーバーソフトです。
自分が使ってるPCをサーバー代わりにできます。

そのソフトがMacには最初から入っているので早速起動してみましょう。

Apacheバージョン確認

https -v 

するとこんな感じの文字が出ます

Server version: Apache/2.4.34 (Unix)
Server built:   Feb 22 2019 19:30:04

バージョンを確認したら起動してみます。

Apache起動

sudo apachectl start

sudo・・・Super User Doの略。パーミッション(権限)を無視して実行できます。なお実行する前にパスワードが求められます。Macを立ち上げる時のパスワードです。タイプしてもターミナルに文字は出ませんがちゃんとに認識されています。
apachectl・・・Apache Control。アパッチをコントロールする。

Apache停止

sudo apachectl stop

Apache再起動

sudo apachectl restart

以上がApacheに関するコマンドです。

次はPHPのバージョンを確認しましょう。

php

php -v・・・バージョン確認

localhostを起動させてみる

これで
・Apacheが起動すること
・PHPがインストールされていることを確認しました。

次は実際にlocalhostを起動させます。
まず、apacheを停止させて再起動しましょう。

その後ブラウザのアドレスバーにこちらのURLを入力してみてください。

http://locahost

画面に「It works!」と表示されていれば接続ができています。

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