Linux Deploy CLIã¯ãchrootã³ã³ãããŒå ã®GNU / Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã®ã€ã³ã¹ããŒã«ãæ§æãããã³èµ·åãèªååããããã«èšèšãããã³ãã³ãã©ã€ã³ã¢ããªã±ãŒã·ã§ã³ã§ãã ã¢ããªã±ãŒã·ã§ã³ã¯ãéåžžã®ãã¹ã¯ãããLinuxãã£ã¹ããªãã¥ãŒã·ã§ã³ãšãLinuxã«ãŒãã«ã«åºã¥ããã¢ãã€ã«ãã©ãããã©ãŒã ã®äž¡æ¹ã§åäœã§ããŸãããã ããå¿ èŠãªäŸåé¢ä¿ã確èªãããŠããã°ïŒãã¹ãŠã®äŸåé¢ä¿ãéçã«æ§ç¯ã§ããŸãïŒã Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã®ã¢ããªã±ãŒã·ã§ã³ã¯ãchrootç°å¢ã§å®è¡ãããã¡ã€ã³ã·ã¹ãã ãšäžŠè¡ããŠåäœããé床ã«å¹æµããŸãã Linux Deployã®æäœã¯Linuxã«ãŒãã«ã®ã·ã¹ãã ã³ãŒã«ã«åºã¥ããŠãããããLinuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã®ã¿ããã²ã¹ããã·ã¹ãã ãšããŠæ©èœã§ããŸãã
ã¢ããªã±ãŒã·ã§ã³ã¯ãã¹ãŒããŒãŠãŒã¶ãŒæš©éããïŒchrootïŒãšã¹ãŒããŒãŠãŒã¶ãŒæš©éãªãïŒprootïŒã®2ã€ã®ã¢ãŒãã§åäœã§ããŸãã éåžžã¢ãŒãã§ã¯ããã¡ã€ã«ããã£ã¹ã¯ããŒãã£ã·ã§ã³ïŒè«çãã©ã€ãïŒãPOSIXäºæãã£ã¬ã¯ããªãããã³RAMïŒtmpfsïŒãžã®ã€ã³ã¹ããŒã«ããµããŒããããŠããŸãã prootã¢ãŒãã§ã¯ãã€ã³ã¹ããŒã«ã¯ãã£ã¬ã¯ããªã§ã®ã¿äœ¿çšã§ããããã€ãã®å¶éã衚瀺ãããŸãã
- ã³ã³ããå ã®ãã¹ãŠã®ãŠãŒã¶ãŒã¯ãã³ã³ããã®ãã¡ã€ã«ã·ã¹ãã å šäœãžã®ãã«ã¢ã¯ã»ã¹æš©ãæã¡ãçŸåšã®ãŠãŒã¶ãŒã¯ãã¹ãŠã®ãã¡ã€ã«ãšãã£ã¬ã¯ããªã®ææè ã§ãã
- ã·ã¹ãã ã§ã®ç¹æš©æäœãžã®ã¢ã¯ã»ã¹ã¯ãããŸãããããšãã°ãpingãulimitãªã©ã¯æ©èœããŸããã
- ã¢ããªã±ãŒã·ã§ã³ã¯ã1024ãè¶ ãããããã¯ãŒã¯ããŒãçªå·ã§ã®ã¿æ©èœããŸãã
- ã¢ããªã±ãŒã·ã§ã³ãäœæ¥ã§chrootã·ã¹ãã ã³ãŒã«ã䜿çšããå Žåãç¹å¥ãªfakechrootãŠãŒãã£ãªãã£ãããšãã°fakechroot / usr / sbin / sshd -p 2222ã䜿çšããŠèµ·åããå¿ èŠããããŸãã
ã¢ããªã±ãŒã·ã§ã³ã¯ãDebianãUbuntuãKali LinuxãArch LinuxãFedoraãCentOSãGentooãopenSUSEãSlackwareã®ãã£ã¹ããªãã¥ãŒã·ã§ã³ã®ïŒåºæ¬ã·ã¹ãã ã®ïŒèªåã€ã³ã¹ããŒã«ãšåææ§æããµããŒãããŠããŸãã Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã®ã€ã³ã¹ããŒã«ã¯ãå ¬åŒã®ã€ã³ã¿ãŒããããã©ãŒãããããã¯ãŒã¯çµç±ã§è¡ãããŸãã ãŸããtar.gzãtar.bz2ããŸãã¯tar.xzã®åœ¢åŒã§äºåã«æºåãããrootfs-archiveããã®ä»ã®ã·ã¹ãã ã®ã€ã³ããŒãããµããŒãããŠããŸãã ãã®ã¢ããªã±ãŒã·ã§ã³ã䜿çšãããšãã€ã³ã¹ããŒã«ãããã·ã¹ãã ïŒã³ã³ãããŒïŒã®ã³ã³ãœãŒã«ã«æ¥ç¶ããããã³ã³ãããŒå ã®ã¢ããªã±ãŒã·ã§ã³ãèµ·åããã³åæ¢ãããã§ããŸãïŒããŸããŸãªåæåã·ã¹ãã ãšç¬èªã®èªåå®è¡ã¹ã¯ãªããããµããŒããããŸãïŒã åã€ã³ã¹ããŒã«ãªãã·ã§ã³ã¯åå¥ã®èšå®ãã¡ã€ã«ã«ä¿åãããåã³ã³ããã®èšå®ãè¡ããŸãã å¿ èŠã«å¿ããŠãã³ã³ããã䞊è¡ããŠèµ·åã§ããŸãã åã€ã³ã¹ããŒã«ããã³æ§æããã«ããã®ã³ã³ãããŒã®åŸç¶ã®å±éã®ããã«ãæ§æããã³ã³ã³ãããŒèªäœãrootfsã¢ãŒã«ã€ããšããŠãšã¯ã¹ããŒãã§ããŸãã
äžè¬ã«ãLinux Deployã®ã¢ã€ãã¢ã¯ãéçºããã¹ãããŸãã¯ãã¬ãŒãã³ã°ã«äœ¿çšã§ããLinuxãã£ã¹ããªãã¥ãŒã·ã§ã³ãè¿ éã«ãããã€ããã¡ã€ã³ïŒãã¹ãïŒLinuxã·ã¹ãã ã«å€æŽãå ããã«ããã«åé€ã§ããç°¡åã§äŸ¿å©ãªããŒã«ãæã«å ¥ããããšããèŠæããçãŸããŸããããããŠãã®å®å šæ§ãå±éºã«ãããããšãªãã PRootããã°ã©ã ã®ãããã§ãã«ãŒãç¹æš©ãªãã§Linuxã¢ããªã±ãŒã·ã§ã³ãå®è¡ããããã®ã³ã³ãããŒãäœæã§ããããã«ãªããŸããããŸãã QEMUãœãããŠã§ã¢ãšãã¥ã¬ãŒã·ã§ã³ã䜿çšããŠã ã«ãŒãã«ã¬ãã«ã®binfmt_miscã¢ãžã¥ãŒã«ããµããŒãããã«ãã¹ããšã¯ç°ãªãã¢ãŒããã¯ãã£ã®ã¢ããªã±ãŒã·ã§ã³ãå®è¡ã§ããããã«ãªããŸããã
2011幎以éã®ç§ã®äž»èŠãªä»äºä»¥æ¥ãDebianãæèŒããã³ã³ãã¥ãŒã¿ãŒã䜿çšãããŠããŸããã ããŒã«ã«éçºè ã¯ãWebã¢ããªã±ãŒã·ã§ã³ïŒäž»ã«JavaãPHPãPythonïŒãå®è¡ããã³ãã¹ãããããã®ã·ã¹ãã ãå®æçã«å¿ èŠãšããŸãã ãããã®ç®çã®ããã«ãä»®æ³ã·ã¹ãã ã¯éåžžãVirtualBoxã«åºã¥ããŠããŸãã¯ããŒã«ã«ã®Proxmoxã®ãã¯ã©ãŠãããŸãã¯Dockerã§äœ¿çšãããŸããã VirtualBoxã®äž»ãªæ¬ ç¹ã¯ãã³ã³ãã¥ãŒã¿ãŒãªãœãŒã¹ã®å³å¯ããVDIãã£ã¹ã¯ã€ã¡ãŒãžã®ãµã€ãºã倧ããããšãæ¯èŒçäœéã§ããããšãããã³ã·ã¹ãã ã誀ã£ãŠã·ã£ããããŠã³ãããšãã«VMã€ã¡ãŒãžãã¯ã©ãã·ã¥ããå¯èœæ§ãããããšã§ãã ãã¯ã©ãŠããã䜿çšããããšã®äžå©ãªç¹ã¯ã管çè èªèº«ããã®ãããªã·ã¹ãã ã®äœæã®ããã®ãŠãŒã¶ãŒãªã¯ãšã¹ããåŠçããå¿ èŠãããããšãšãã»ã«ã³ããªã¿ã¹ã¯ã§ã®ãã¯ã©ãŠãããªãœãŒã¹ã®æ¶è²»ã§ãã Dockerã䜿çšããã«ã¯ãã¹ãŒããŒãŠãŒã¶ãŒæš©éãå¿ èŠã§ãã
ä»æãå®éšãè¡ãããŸãã; PHPéçºè ã¯ãä»®æ³ãµãŒããŒãLDã³ã³ãããŒã«çœ®ãæããŸããã DebianããŒã¹ã®ã³ã³ããã2ã€çšæãããŸããïŒApache + PHP + OCI8ããã³Apache + PHP + MySQL + PhpMyAdminã ã³ã³ããã¯ããŒã«ã«ãããã¯ãŒã¯äžã®å ±æãããã¯ãŒã¯ãã©ã€ãã«é 眮ãããåã³ã³ããã®ãµã€ãºã¯çŽ150 MBã§ããã
管çè ãããããåãåã£ããã®ïŒ
- æºåãããã³ã³ããã¯ã管çè ã®åå ãªãã§1ã€ã®ããŒã ã§éçºè ã®ã³ââã³ãã¥ãŒã¿ãŒã«å±éã§ããŸãã
- ã³ã³ããã§ã®äœæ¥ã«ã¯ã¹ãŒããŒãŠãŒã¶ãŒæš©éã¯å¿ èŠãªããããã¡ã€ã³ã·ã¹ãã ãæ éããå±éºæ§ã¯ãããŸããã
éçºè ãåŸããã®ïŒ
- ã³ã³ããå ã®ã·ã¹ãã ã®å±éãèµ·åãããã³ç®¡çã¯ãåäžã®ããŒã ãšããŠç®¡çè ãåå ããããšãªãå®è¡ãããŸãã
- äºåã«æºåãããã¢ãŒã«ã€ãããã®ã³ã³ããã®å±éã¯ããããã¯ãŒã¯äžã§1å以å ã«è¡ãããŸãã
- ã³ã³ããã®èµ·åãšåæ¢ïŒWebãµãŒããŒ+ããŒã¿ããŒã¹ïŒã¯å³åº§ã«çºçãããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®èµ·åãåŸ ã€å¿ èŠã¯ãããŸããã
- ã³ã³ãã¥ãŒã¿ã®é»æºãåã£ããšãã«é»æºãåãã®ãå¿ããŠããã³ã³ãããç Žæããå±éºã¯ãããŸããã ã·ã¹ãã ã€ã¡ãŒãžã¯ãç¬èªã®ãã¡ã€ã«ã·ã¹ãã ã®ãªãéåžžã®ãã£ã¬ã¯ããªã§ãã
- ã³ã³ãã¥ãŒã¿ãŒã¯é«éã§ã ãªãœãŒã¹ã¯ããªãã¬ãŒãã£ã³ã°ã·ã¹ãã å šäœã§ã¯ãªããã³ã³ããå ã®ãœãããŠã§ã¢ã®å®è¡ã«ã®ã¿äœ¿çšãããŸãïŒãã®å Žåãããã¯VirtualBoxã®500 MBã§ã¯ãªããçŽ50 MBã§ãïŒã
- ãµãŒããŒã«ã¢ããããŒãããå¿ èŠãªããIDEãã£ã¬ã¯ããªãããœãããŠã§ã¢ã®æ©èœãçŽæ¥ãã§ãã¯ããŸããããã¯ãã¡ã€ã³ã·ã¹ãã ã®å¿ èŠãªãã£ã¬ã¯ããªãã³ã³ããã«æ¥ç¶ããã ãã§ååã§ãã
ãããŠããããå®çŸããæ¹æ³ã«ã€ããŠããã«è©³ãã説æããŸãã 次ã«ãLDã³ã³ããã®æºåãšå±éã«é¢ããæ瀺ãæäŸãããŸãã
ã¹ãŒããŒãŠãŒã¶ãŒæš©éãªãã§ã³ã³ãããå®è¡ããã«ã¯ãPRootãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã
mkdir ~/bin wget http://portable.proot.me/proot-x86_64 -O ~/bin/proot chmod 755 ~/bin/proot
Linux Deploy CLIãããŠã³ããŒãããŠã€ã³ã¹ããŒã«ããŸãã
wget -O cli.zip https://github.com/meefik/linuxdeploy-cli/archive/master.zip unzip cli.zip rm cli.zip ln -sf ~/linuxdeploy-cli/cli.sh ~/bin/linuxdeploy
Debian WheezyããŒã¹ã·ã¹ãã ïŒ64ãããïŒããããã€ããããã®ãlinuxããšããèšå®ãäœæããŸãã
linuxdeploy -p linux conf --method='proot' --source-path='http://mirror.yandex.ru/debian/' \ --distrib='debian' --arch='amd64' --suite='wheezy' --target-path='$ENV_DIR/rootfs/linux' \ --chroot-dir='$TARGET_PATH' --target-type='directory' --username='webmaster' --include='bootstrap'
ä¿åãããæ§æã衚瀺ïŒ
linuxdeploy -p linux conf -x
æ°ããã·ã¹ãã ã®å±éã®éå§ïŒ
linuxdeploy -p linux deploy
rootãŠãŒã¶ãŒã§ã³ã³ãããŒã³ã³ãœãŒã«ã«æ¥ç¶ããïŒexitã³ãã³ããçµäºããïŒïŒ
linuxdeploy -p linux shell -u root
次ã«ãå¿ èŠãªãœãããŠã§ã¢ãã³ã³ããã«ã€ã³ã¹ããŒã«ããŠæ§æã§ããŸãããåè¿°ã®æ©èœãèæ ®ããå¿ èŠããããŸãã ããšãã°ãApacheãèµ·åããã«ã¯ãããŒãïŒãã¡ã€ã«/etc/apache2/ports.confïŒã8000ã«å€æŽãã空ã®ãã©ã¡ãŒã¿ãŒAPACHE_ULIMIT_MAX_FILES = ""ïŒãã¡ã€ã«/ etc / apache2 / envvarsïŒãèšå®ããéåžžã®ãŠãŒã¶ãŒã®äžããapachectlãå®è¡ããå¿ èŠããããŸãïŒã«ãŒãã§ã¯ãããŸããïŒã
SysVåæåã·ã¹ãã ã«åºã¥ããèªåå®è¡ã®æ§æïŒ
linuxdeploy -p linux conf --include='$INCLUDE init' --init='sysv' --init-level='3' --init-user='$USER_NAME' --init-async
ãã©ã¡ãŒã¿ïŒINIT_LEVEL-åæåã¬ãã«SysVãINIT_USER-ãµãŒãã¹ãéå§ãããŠãŒã¶ãŒïŒããã©ã«ãã§ã¯ã«ãŒãïŒãINIT_ASYNC-ãµãŒãã¹ã䞊è¡ããŠéå§ããŸãã
æ§æã®æºåãæ§æã®ãšã¯ã¹ããŒããããã³ã³ã³ãããŒã®rootfsã¢ãŒã«ã€ããžã®ãšã¯ã¹ããŒãïŒtar.gzãtar.bz2ãããã³tar.xzã¢ãŒã«ã€ãããµããŒããããŠããŸãïŒïŒ
linuxdeploy -p linux conf --source-path='linux.tgz' --target-path='\$ENV_DIR/rootfs/linux' --chroot-dir='\$TARGET_PATH' linuxdeploy -p linux conf -x > /path/to/linux.conf linuxdeploy -p linux export /path/to/linux.tgz
ã\ $ãããšã¹ã±ãŒããããšãå€æ°ã®å€ã§ã¯ãªããæ§æå ã®å€æ°ã®ååãä¿åã§ããŸãã ãããã£ãŠãæ§æãã€ã³ããŒããããšããããã®å€æ°ã¯å¯Ÿå¿ããå€ã«èªåçã«çœ®ãæããããçŸåšã®å€ãšã¯ç°ãªãå ŽåããããŸãã å¥ã®ã³ã³ãã¥ãŒã¿ãŒã«ã³ã³ãããŒãã€ã³ããŒããããšãã«äœ¿çšã§ãã2ã€ã®ãã¡ã€ã«ïŒlinux.confãšlinux.tgzïŒããããŸãã
cd /path/to linuxdeploy -p linux conf -i ./linux.conf linuxdeploy -p linux deploy
ã¡ã€ã³ã·ã¹ãã ã®ãã£ã¬ã¯ããªãã³ã³ããã«æ¥ç¶ããŸãïŒã³ã³ããã®ã/ wwwãã£ã¬ã¯ããªã/ var / wwwã«æ¥ç¶ããŸãïŒïŒ
linuxdeploy -p linux conf --mounts='$HOME/www:/var/www'
ã³ã³ããã®èµ·åïŒSysVã®å Žåãã¹ã¯ãªãã/etc/rcN.d/SXXname startãå®è¡ãããŸãïŒïŒ
linuxdeploy -p linux start
ãªãœãŒã¹ã解æŸããŠã³ã³ãããåæ¢ããïŒSysVã®å Žåãã¹ã¯ãªãã/etc/rc6.d/KXXname stopãå®è¡ãããŸãïŒïŒ
linuxdeploy -p linux stop -u
ãã®çµæãéçºè ãšç®¡çè ã®äž¡æ¹ã®ããŒãºãæºãããœãªã¥ãŒã·ã§ã³ãåŸãããŸãã Linux Deployã¢ããªã±ãŒã·ã§ã³ã®ãœãŒã¹ã³ãŒãã¯ãGPLããŒãžã§ã³3ã©ã€ã»ã³ã¹ã§å©çšã§ããŸãã