部署 若依前端vue

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

//創建一個文件夾

cd /usr/local mkdir nginx cd nginx

//下載tar包

wget http://nginx.org/download/nginx-1.13.7.tar.gz tar -xvf nginx-1.13.7.tar.gz

//進入nginx目錄

cd /usr/local/nginx //進入目錄

cd nginx-1.13.7

//執行命令 考慮到後續安裝ssl證書 添加兩個模塊

./configure --with-http_stub_status_module --with-http_ssl_module

//執行make命令

make

//執行make install命令

make install

啓動

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

vi /usr/local/nginx/conf/nginx.conf

server {
    listen       80;
    server_name  localhost;

    location / {
            root   /data/dist;
            index  index.html index.htm;
                 try_files $uri $uri/ /index.html;
    }

   location /prod-api/ {
      proxy_pass  http://127.0.0.1:8080/; # 轉發規則
      proxy_set_header Host $proxy_host; # 修改轉發請求頭,讓8080端口的應用可以受到真實的請求
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

重載配置

/usr/local/nginx/sbin/nginx -s reload

查詢nginx

ps -ef | grep nginx

開放80端口:

firewall-cmd --zone=public --add-port=80/tcp --permanent

查詢端口號80 是否開啓:

firewall-cmd --query-port=80/tcp

重啓防火牆:

firewall-cmd --reload

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章