日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

nginx mac 服务器 html,Mac上搭建 nginx 服务器

發布時間:2024/9/15 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nginx mac 服务器 html,Mac上搭建 nginx 服务器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

因為需要做一個自己的內測分發平臺,所以需要搭建一臺自己的服務器,于是我選擇了使用它 nginx 來搭建服務器,很方便,很簡單.

本文主要講一下如何在 mac 上搭建 nginx 服務器,已經一些簡單的開啟,關閉指令.

1.首先需要安裝 homebrew

ruby -e "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install](https://raw.githubusercontent.com/Homebrew/install/master/install))"

2.安裝 nginx(這里需要一點時間)

brew install nginx

3.啟動 nginx

nginx

敲完回車什么也沒發生,但是確實啟動了,不信可以檢查一下,直接在瀏覽器中訪問以下地址localhost:8080,如果頁面上大大的"Welcome to nginx!",表示已經啟動成功了.

4.配置文件

使用Finder 的"前往文件夾"功能訪問該地址:/usr/local/Cellar/nginx/

里面應該只有一個文件夾,叫做1.15.5. 打開該文件夾,然后打開 html 文件夾,這里應該有兩個文件"50x.html"和"index.html".此時你隨便在這個文件夾中放一個txt格式的文檔,內容啥的都無所謂,然后給它起個名字.例如: bin.txt.

5.配置 nginx

訪問"/usr/local/etc/"文件夾,打開"nginx"文件夾,找到"nginx.conf.default"文件,用文本編輯器打開它,在最下方粘貼以下代碼

server {

listen 8080;

server_name localhost;

#access_log logs/host.access.log main;

location ~* {

add_header Content-Type "application/json";

root html;

if (!-f $request_filename) {

rewrite ^/(.*) /$1.json last;

}

index index.php index.html index.htm;

}

error_page 405 =200 http://$host$request_uri;

}

6.展現成果

訪問"localhost:8080/bin.txt",應該就能看到你剛才創建的文本里面的內容了

7.簡單的指令

開啟 nginx

$ nginx

關閉 nginx

$ ps -ef | grep nginx #查看 nginx 的進程號, master 為主進程號

$ sudo kill -QUIT 36500 #36500是上一步查看到的主進程號,請自行替換

總結

以上是生活随笔為你收集整理的nginx mac 服务器 html,Mac上搭建 nginx 服务器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。