Mac M1 Nginx 配置多站點(diǎn)的實(shí)現(xiàn)
說(shuō)明:通過(guò) brew 安裝的 nginx
網(wǎng)站根目錄:/opt/homebrew/var/www
nginx 配置目錄:/opt/homebrew/etc/nginx/
假設(shè):有項(xiàng)目名稱(chēng)為 TestProject ,域名為 bd.testproject.com
第一步 : 設(shè)置 IP 與 域名 映射 (也就是增加 hosts)
# 終端 vim /etc/hosts # 增加保存 127.0.0.1 bd.testproject.com
第二步: 新建站點(diǎn)配置文件目錄
# 終端 mkdir /opt/homebrew/etc/nginx/vhosts
第三步 : 新建站點(diǎn)配置文件
在/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)配置文件中引入站點(diǎn)配置
# 終端
vim /opt/homebrew/etc/nginx/nginx.conf
# 在文件內(nèi) http{} 中新增
server_names_hash_bucket_size 64; # 修改服務(wù)器名稱(chēng)長(zhǎng)度,只能為 32 的倍數(shù)
include /opt/homebrew/etc/nginx/vhosts/*; # 引入站點(diǎn)配置
第五步 : 重啟 nginx
# 終端 nginx -s reload
請(qǐng)忽略我, 啟動(dòng)fastcgi
/usr/local/php/bin/php-cgi -b 9000
到此這篇關(guān)于Mac M1 Nginx 配置多站點(diǎn)的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Mac M1 Nginx多站點(diǎn)內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信