国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

如何在 Windows10 環境下部署配置一鍵啟動的 Homestead + Laravel +vu

graf / 2214人閱讀

摘要:如何在環境下部署配置一鍵啟動的項目我在內要啟動寫的項目,我使用的是去運行和管理項目。所以運行會報沒有權限的錯誤。不過有問題每次啟動的時候都要到虛擬機里面啟動還是很麻煩還好有相關的解決方案,在目錄下有個的腳本就是用來啟動后執行相關操作的。

如何在 windows10 環境下部署配置一鍵啟動的 Homestead + Laravel +vue + PM2 項目

我在homestead 內要啟動node寫的項目,我使用的是pm2 去運行和管理node 項目。使用pm2 的好處是方便調試和部署項目。不過homestead 里面并沒有內置 pm2 功能,我只能自己安裝.

進入homestead 虛擬機(用 vagrant ssh 或者 使用shell工具 我推薦使用 finalshell 是一個很強大的免費工具)

安裝pm2

npm install pm2@latest -g

這個時候會有個報錯

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/pm2
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/pm2/node_modules
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules/pm2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access "/usr/local/lib/node_modules/pm2"
npm ERR!  { [Error: EACCES: permission denied, access "/usr/local/lib/node_modules/pm2"]
npm ERR!   stack:
npm ERR!    "Error: EACCES: permission denied, access "/usr/local/lib/node_modules/pm2"",
npm ERR!   errno: -13,
npm ERR!   code: "EACCES",
npm ERR!   syscall: "access",
npm ERR!   path: "/usr/local/lib/node_modules/pm2" }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2018-08-30T01_48_01_688Z-debug.log

因為homestead 默認登陸的是 vagrant 用戶 。所以運行npm install pm2@latest -g 會報沒有權限的錯誤。

要切換到 root 用戶 或者 使用

sudo npm install pm2@latest

安裝。

我采用的是切換root 用戶,但是homestead沒有給root設置密碼,所以我們要先設置下root 用戶的密碼

sudo passwd root 

然后用新設置的密碼登陸 root 用戶,安裝PM2.

安裝完成后, 初始化pm2

pm2 init 

會生成配置文件 ecosystem.config.js ,設置好項目配置文件.

啟動項目

pm2 start ecosystem.config.js

到這時候就可以訪問node項目了。

不過有問題每次啟動homestead的時候都要到虛擬機里面啟動pm2 還是很麻煩還好 homestead 有相關的解決方案,在 homestead 目錄下有個 after.sh 的 shell 腳本就是用來啟動 homestead 后執行相關 shell 操作的。

我在里面加內容

#!/usr/bin/env bash
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.

# 切換到root 用戶
su root -c "root"

# 啟動微課堂后臺前端項目
npm install pm2@latest -g

# 啟動微課堂后臺前端項目
pm2 start ~/onlineducation.config.js

重啟 homestead 會報錯

homestead: su: must be run from a terminal
    homestead: npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/pm2
    homestead: npm WARN
    homestead: checkPermissions Missing write access to /usr/local/lib/node_modules/pm2/node_modules
    homestead: npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
    homestead: npm ERR! path /usr/local/lib/node_modules/pm2
    homestead: npm ERR! code EACCES
    homestead: npm ERR! errno
    homestead:  -13
    homestead: npm
    homestead: ERR!
    homestead:  syscall
    homestead:  access
    homestead: npm ERR! Error: EACCES: permission denied, access "/usr/local/lib/node_modules/pm2"
    homestead: npm ERR!
    homestead:   { [Error: EACCES: permission denied, access "/usr/local/lib/node_modules/pm2"]
    homestead: npm ERR!
    homestead:    stack:
    homestead: npm
    homestead: ERR!    "Error: EACCES: permission denied, access "/usr/local/lib/node_modules/pm2"",
    homestead: npm
    homestead:  ERR!
    homestead:    errno: -13,
    homestead: npm ERR!
    homestead:    code: "EACCES",
    homestead: npm ERR!   syscall: "access",
    homestead: npm ERR!   path: "/usr/local/lib/node_modules/pm2" }
    homestead: npm
    homestead: ERR!
    homestead:
    homestead: npm ERR! The operation was rejected by your operating system.
    homestead: npm ERR! It is likely you do not have the permissions to access this file as the current user
    homestead: npm ERR!
    homestead: npm ERR!
    homestead:  If you believe this might be a permissions issue, please double-check the
    homestead: npm ERR! permissions of the file and its containing directories, or try running
    homestead: npm
    homestead: ERR!
    homestead:  the command again as root/Administrator (though this is not recommended).
    homestead: npm
    homestead: ERR! A complete log of this run can be found in:
    homestead: npm ERR!     /home/vagrant/.npm/_logs/2018-08-30T01_35_38_735Z-debug.log
    homestead: [PM2] Spawning PM2 daemon with pm2_home=/home/vagrant/.pm2

su 命令只能在終端運行,看來只能用其他方法切換用戶了。

修改 after.sh 腳本 使用 expect改成可遠程執行的腳本

#!/usr/bin/env bash
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.

# 安裝 expect
sudo snap install expect

# 安裝 pm2
sudo npm install pm2@latest -g

# 切換到root 用戶
expect -c "
spawn su - root
expect ":"
send "root
"
expect ":"
send "cd /home/vagrant
"
expect ":"
send "pm2 start onlineducation.config.js
"
expect ":"
interact
"

如果 expect 不能安裝,可以進入虛擬機先安裝好,再重啟 homestead 就可以了。

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/40100.html

相關文章

  • 如何在 Windows10 環境下部署配置一鍵啟動的 Homestead + Laravel +vu

    摘要:如何在環境下部署配置一鍵啟動的項目我在內要啟動寫的項目,我使用的是去運行和管理項目。所以運行會報沒有權限的錯誤。不過有問題每次啟動的時候都要到虛擬機里面啟動還是很麻煩還好有相關的解決方案,在目錄下有個的腳本就是用來啟動后執行相關操作的。 如何在 windows10 環境下部署配置一鍵啟動的 Homestead + Laravel +vue + PM2 項目 我在homestead 內要...

    Lavender 評論0 收藏0
  • 如何將FPGA資源平民化?阿里工程師有了新突破

    摘要:阿里云服務器平臺在云端提供統一硬件平臺與中間件,可大大降低加速器的開發與部署成本。我們相信,通過即開即用的硬件資源統一的軟硬件邏輯開發接口和市場,阿里云能夠真正兌現計算資源平民化的承諾。 阿里云ECS的異構計算團隊和高性能計算團隊一直致力于將計算資源平民化;高性能計算團隊在做的E-HPC就是要讓所有云上用戶都能夠瞬間擁有一個小型的超算集群,使得超算不再僅僅是一些超算中心和高校的特權;而...

    liujs 評論0 收藏0
  • Vue.js學習

    摘要:一基礎學習模式下圖不僅概括了模式,還描述了在中是如何和以及進行交互的。關于這一點我們將在后續反應系統中討論。父組件通過向下傳遞數據給子組件,子組件通過給父組件發送消息。這個對象必須是普通對象原生對象,及原型屬性會被忽略。 Vue.js 是用于構建交互式的 Web 界面的庫。Vue.js 提供了 MVVM 數據綁定和一個可組合的組件系統,具有簡單、靈活的 API。 其實和Jquery一樣...

    TIGERB 評論0 收藏0

發表評論

0條評論

最新活動
閱讀需要支付1元查看
<