Mac M1 Nginx 配置多站點的實現(xiàn)
說明: 通過 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 默認配置文件中引入站點配置
# 終端
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)文章希望大家以后多多支持腳本之家!
相關(guān)文章
nginx+lua+redis實現(xiàn)降級的示例代碼
隨著用戶訪問量的激增,網(wǎng)站或電商平臺可能會面臨系統(tǒng)超負載的問題,導致注冊、下單、支付等功能出現(xiàn)問題,為保障核心服務(wù)的高可用性,可以采用降級策略,本文就來介紹一下nginx+lua+redis降級,感興趣的可以了解學習2024-10-10
Nginx配置同一個域名同時支持http與https兩種方式訪問實現(xiàn)
這篇文章主要介紹了Nginx配置同一個域名同時支持http與https兩種方式訪問實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-08-08

