蘋果M1芯片安裝nginx 并且部署vue項目步驟詳解
brew安裝nginx
蘋果mac安裝使用 brew 安裝,如果brew沒有安裝的話,請到搜索其他地方。
執(zhí)行命令
第一步當然是更新我們的brew庫,可以認為這個玩意就是個軟件倉庫,類似于安卓市場,蘋果appStore
brew update
第二步直接查找我們的brew庫中有沒有nginx這個玩意兒
brew search nginx

如果出現(xiàn),證明庫中已經(jīng)有了,直接進行安裝命令
brew install nginx
安裝完 只要沒有報錯,你的nginx就是已經(jīng)安裝成功了。。。
mac環(huán)境下的nginx對應路徑
首先肯定是要知道我們的nginx常用的路徑,我已經(jīng)列出來了
| 說明 | 路徑 |
|---|---|
| nginx配置路徑(conf等文件) | /usr/local/etc/nginx |
| nginx上面部署的項目放包地址 | /usr/local/etc/nginx/servers |
| nginx中的日志 | /usr/local/var/log/nginx |
| nginx中訪問默認首頁地址 | /usr/local/var/www |
編輯nginx對應的nginx.conf文件,對應我們上面說到的配置路徑
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
client_body_buffer_size 10m;
client_max_body_size 20m;
#gzip on;
server {
listen 80;
server_name localhost;
location / {
root /usr/local/etc/nginx/servers/html;
index index.html;
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://localhost:18080/api;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set $Real $http_x_forwarded_for;
if ( $Real ~ (\d+)\.(\d+)\.(\d+)\.(\d+),(.*) ){
set $Real $1.$2.$3.$4;
}
proxy_set_header X-Real-Ip $Real;
}
}
有個細節(jié)特別需要注意,如果你的root不是絕對路徑的話,可能訪問不到

網(wǎng)上大部分都是相對路徑,我不知道是什么問題,我本地不行,要用絕對路徑,上面路徑的那個servers/html 的那個東西就是你的vue項目npm run build 命令后的dist包,解壓后放到這個路徑就行了,名字一定要和你nginx配置文件的路徑對應
最后大結局
最終就是啟動nginx了,直接終端命令輸入
nginx
如果要指定你啟動的nginx.conf文件
nginx -c /跟路徑
停止nginx
nginx -s stop
重啟nginx
nginx -s reload
到此這篇關于蘋果M1芯片安裝nginx 并且部署vue項目的文章就介紹到這了,更多相關蘋果M1芯片安裝nginx 并且部署vue項目內容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持本站!
版權聲明:本站文章來源標注為YINGSOO的內容版權均為本站所有,歡迎引用、轉載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。
關注官方微信