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?

Macにhomebrewでnginxインストールした

Posted at

はじめに

今までAWSにnginxをインストールしていましたが、
Macに入れたいなと思いしてみたものの結構苦戦しました。
手順をまとめておこうと思います。

Xcode Command Line Tools

Xcodeのコマンドラインツールをインストールします。これにより、Homebrewのようなツールを使うための基本的な開発ツールがインストールされます。

$ xcode-select --install

Homebrew

Homebrewは、macOS用のパッケージマネージャーで、ソフトウェアのインストールや管理を簡単にしてくれます。インストールされると、brewコマンドが使用できるようになります。

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
$ brew --version

nginx

Homebrewを使ってnginxをインストールします。以下のコマンドを実行します。

$ brew install nginx

⚠️注意点

Homebrewを使ってnginxをインストールした場合の設定ファイルパスに注意してください!

/usr/local/etc

ここではなく、、

/opt/homebrew/etc/

ここにあります!

nginx起動

$ sudo brew services start nginx
http://localhost:8080

上記URLで起動の確認ができます。
"Welcome to nginx!" という画面が表示されれば、インストールと設定が成功しています。

設定編集

$ sudo nginx -s stop
$ sudo vim /opt/homebrew/etc/nginx/nginx.conf

ポート番号がデフォルトで8080になっているので、上記コマンドで設定ファイルを開きlistenを8080から80に修正します。

nginx.conf
server {
listen       80;
server_name  localhost;

修正が完了したら、nginxを再起動します

$ sudo brew services restart nginx

localhostで接続できるようになります。

http://localhost

さいごに

検索かけてもことごとくパスが違うのでめんどくさかったです、、

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?