主頁 > 知識庫 > Mac M1 Nginx 配置多站點的實現(xiàn)

Mac M1 Nginx 配置多站點的實現(xiàn)

熱門標(biāo)簽:美圖手機 硅谷的囚徒呼叫中心 阿里云 智能手機 網(wǎng)站建設(shè) 使用U盤裝系統(tǒng) 百度競價點擊價格的計算公式 檢查注冊表項

說明: 通過 brew 安裝的 nginx

網(wǎng)站根目錄: /opt/homebrew/var/www

nginx 配置目錄: /opt/homebrew/etc/nginx/

假設(shè): 有項目名稱為 TestProject , 域名為 bd.testproject.com

第一步 : 設(shè)置 IP 與 域名 映射 (也就是增加 hosts)

# 終端
vim /etc/hosts 
 
# 增加保存
127.0.0.1  bd.testproject.com

 第二步 : 新建站點配置文件目錄

# 終端
mkdir /opt/homebrew/etc/nginx/vhosts

第三步 : 新建站點配置文件

在 /opt/homebrew/etc/nginx/vhosts 目錄中新建名為 bd.testproject.com_80.conf 配置文件 , 配置文件內(nèi)容為(可根據(jù)自需更改配置內(nèi)容):

server {
    listen    80;
    server_name bd.testproject.com;
    root  "/opt/homebrew/var/www/bd.testproject.com";
    location / {
      index index.php index.html error/index.html;
 
      autoindex off;
    }
    location ~ \.php(.*)$ {
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
      fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
      include    fastcgi_params;
    }
}

第四步 : 在 nginx 默認(rèn)配置文件中引入站點配置

# 終端
vim /opt/homebrew/etc/nginx/nginx.conf
 
# 在文件內(nèi) http{} 中新增
server_names_hash_bucket_size 64; # 修改服務(wù)器名稱長度,只能為 32 的倍數(shù)
include /opt/homebrew/etc/nginx/vhosts/*; # 引入站點配置

第五步 : 重啟 nginx

# 終端
nginx -s reload

請忽略我, 啟動 fastcgi

/usr/local/php/bin/php-cgi -b 9000

到此這篇關(guān)于Mac M1 Nginx 配置多站點的實現(xiàn)的文章就介紹到這了,更多相關(guān)Mac M1 Nginx多站點內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

標(biāo)簽:煙臺 通遼 山南 懷化 湘潭 湖北 黃山 賀州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Mac M1 Nginx 配置多站點的實現(xiàn)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266