webman打包成二進(jìn)制,也就是將webman項(xiàng)目代碼與PHP環(huán)境打包成一個(gè)二進(jìn)制文件,無(wú)需部署php環(huán)境,也可以讓webman在linux系統(tǒng)里運(yùn)行起來(lái)。
composer require webman/console ^1.2.24
php webman build:bin
將生成的build/webman.bin
拷貝到linux系統(tǒng),執(zhí)行
./webman.bin start
更多webman打包二進(jìn)制說(shuō)明參考 webman手冊(cè)打包成二進(jìn)制
如果只是下載可獨(dú)立運(yùn)行的PHP文件,參見(jiàn) 下載靜態(tài)PHP
https://github.com/crazywhalecc/static-php-cli
https://github.com/dixyes/phpmicro
https://github.com/easysoft/phpmicro
https://github.com/walkor/static-php-cli
感謝 easysoft dixyes crazywhalecc 為php社區(qū)做出的貢獻(xiàn)
千呼萬(wàn)喚始出來(lái) ,
建議加個(gè)選項(xiàng):打包后是否自動(dòng)刪除phar 以及 打包前把 bin 給刪除一下
各位注意下,如果環(huán)境是用webman的二進(jìn)制php運(yùn)行的話,打包的時(shí)候會(huì)這樣
lighthouse@VM-4-7-debian:~/project/webman/webman$ php webman build:bin
In BuildPharCommand.php line 142:
The 'phar.readonly' is 'On', build phar must setting it 'Off' or exec with 'php -d phar.readon
ly=0 ./webman build:bin'
build:bin [<version>]
lighthouse@VM-4-7-debian:~/project/webman/webman$ php -d phar.readonly=0 ./webman build:bin
Phar packing...
請(qǐng)問(wèn)執(zhí)行在Arm架構(gòu)的代碼是不是只能在Arm架構(gòu)環(huán)境下打包?
還是說(shuō),在x86環(huán)境下打包,在Arm環(huán)境下也能執(zhí)行?
二進(jìn)制打包發(fā)布到Linux系統(tǒng)運(yùn)行報(bào)錯(cuò),不知道哪里出錯(cuò)了,希望各個(gè)大佬幫忙看看
我的疑問(wèn)是,當(dāng)業(yè)務(wù)的代碼發(fā)生變化后,重新打包應(yīng)該如何平滑的更新?是直接把老版本的覆蓋掉然后 執(zhí)行restart命令?還是先把服務(wù)停掉然后再上傳覆蓋掉老文件,然后再用start啟動(dòng)一遍呢?這樣的話,在上傳和覆蓋這個(gè)時(shí)間段服務(wù)器就無(wú)法服務(wù)了。
我是定義了一個(gè) 初始化進(jìn)程,啟動(dòng)后 curl 鏈接遠(yuǎn)程判斷:發(fā)現(xiàn)新版本1.2 是否更新(y/n)
按y 就下載二進(jìn)制包覆蓋并 kill webman 進(jìn)程并重新啟動(dòng)webman (腳本操作)
添加php配置項(xiàng),請(qǐng)參考:https://github.com/easysoft/phpmicro/wiki/INI-settings 或者是,可以修改vendor/webman/console/src/Commands/BuildBinCommand.php文件,用于自動(dòng)生成類(lèi)似ini.bin文件。
// 生成二進(jìn)制文件
file_put_contents($binFile, file_get_contents($sfxFile));
file_put_contents($binFile, file_get_contents("$this->buildDir/ini_header.bin"), FILE_APPEND);
file_put_contents($binFile, file_get_contents($pharFile), FILE_APPEND);
上傳成功后,在文件目錄執(zhí)行 ./webman.bin start
提示 bash: webman.bin : commsnf not found
項(xiàng)目比較大,二進(jìn)制打包后超過(guò)128M了咋整。啟動(dòng)直接報(bào)錯(cuò): Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 138781738 bytes) in Unknown on line 0
有一個(gè)疑問(wèn),webman打包二進(jìn)制運(yùn)行,從遠(yuǎn)程下載的micro.sfx是怎么做到與項(xiàng)目文件結(jié)合后運(yùn)行,PHP_SAPI等于cli的;我自己打包出的micro.sfx的PHP_SAPI的值等于micro。