×ðÁú¿­Ê±

ÔõÑùʹÓÃDockerÔÚLinuxÉÏ¿ìËÙ°²ÅÅ¿ª·¢ÇéÐΣ¿

ÔõÑùʹÓÃdockerÔÚlinuxÉÏ¿ìËÙ°²ÅÅ¿ª·¢ÇéÐÎ

Ëæ×ÅÈí¼þ¿ª·¢µÄ¿ìËÙÉú³¤ £¬¿ª·¢ÇéÐεݲÅųÉΪÁËÒ»¸öÖ÷ÒªµÄÎÊÌâ¡£¹Å°åµÄ·½·¨ÍùÍùÐèÒªÊÖ¶¯×°ÖúÍÉèÖÃÖÖÖÖÒÀÀµ £¬ãýÃðʱ¼äºÍ¾«Éñ¡£¶øʹÓÃDocker¿ÉÒÔ¼«´óµØ¼ò»¯¿ª·¢ÇéÐεݲÅÅÀú³Ì £¬Ìá¸ß¿ª·¢Ð§ÂÊ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃDockerÀ´¿ìËÙ°²ÅÅ¿ª·¢ÇéÐÎ £¬ÒÔLinuxϵͳΪÀý¡£

×°ÖÃDocker

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚLinuxϵͳÉÏ×°ÖÃDocker¡£DockerÓжàÖÖ×°Ö÷½·¨ £¬ÕâÀïÎÒÃÇʹÓÃ×î³£¼ûµÄapt°ü¹ÜÀíÆ÷¾ÙÐÐ×°Ö᣷­¿ªÖÕ¶Ë £¬ÔËÐÐÒÔÏÂÏÂÁ

$ sudo apt update
$ sudo apt install docker.io

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó £¬¿ÉÒÔÔËÐÐdocker –versionÏÂÁîÀ´ÑéÖ¤DockerÊÇ·ñ×°ÖÃÀֳɡ£

»ñÈ¡¾µÏñ

DockerʹÓþµÏñÀ´½¨ÉèÈÝÆ÷ £¬ÎÒÃÇÐèÒªÏÈ»ñÈ¡ËùÐèµÄ¾µÏñ¡£ÒÔPHP¿ª·¢ÇéÐÎΪÀý £¬ÎÒÃÇ¿ÉÒÔʹÓùٷ½ÌṩµÄPHP¾µÏñ¡£·­¿ªÖÕ¶Ë £¬ÔËÐÐÒÔÏÂÏÂÁî»ñÈ¡¾µÏñ£º

$ sudo docker pull php:latest

µÇ¼ºó¸´ÖÆ

Õ⽫´ÓDocker HubÉÏÏÂÔØ×îа汾µÄPHP¾µÏñ¡£

½¨ÉèÈÝÆ÷

»ñÈ¡¾µÏñºó £¬ÎÒÃÇ¿ÉÒÔʹÓøþµÏñ½¨ÉèÈÝÆ÷¡£·­¿ªÖÕ¶Ë £¬ÔËÐÐÒÔÏÂÏÂÁ

$ sudo docker run -it --name myphpcontainer -v /path/to/project:/var/www/html php:latest

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁîÖÐ £¬ÎÒÃÇʹÓÃdocker runÏÂÁÉèÁËÒ»¸öÃûΪmyphpcontainerµÄÈÝÆ÷¡£-it²ÎÊýÓÃÓÚÖ¸¶¨½»»¥Ê½ÔËÐÐ £¬–name²ÎÊýÓÃÓÚÖ¸¶¨ÈÝÆ÷µÄÃû³Æ £¬-v²ÎÊýÓÃÓÚ½«ËÞÖ÷»úÉϵÄÏîĿ·¾¶¹ÒÔص½ÈÝÆ÷ÄÚ²¿µÄ/var/www/html·¾¶ £¬ÒÔʵÏÖÎļþ¹²Ïí¡£php:latestÌåÏÖʹÓÃ×îа汾µÄPHP¾µÏñ¡£

ÉèÖÿª·¢ÇéÐÎ

ÈÝÆ÷½¨ÉèÍê³Éºó £¬ÎÒÃÇÐèÒª½øÈëÈÝÆ÷ÄÚ²¿ÉèÖÿª·¢ÇéÐΡ£ÔËÐÐÒÔÏÂÏÂÁ

$ sudo docker exec -it myphpcontainer bash

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁîÖÐ £¬ÎÒÃÇʹÓÃdocker execÏÂÁî½øÈëÈÝÆ÷ÄÚ²¿ £¬²¢Æô¶¯Ò»¸öеÄÖն˻Ự¡£-it²ÎÊýÓÃÓÚÖ¸¶¨½»»¥Ê½ÔËÐÐ £¬myphpcontainerÌåÏÖÈÝÆ÷µÄÃû³Æ £¬bashÌåÏÖʹÓÃBash×÷ΪĬÈϵÄShell¡£

ÔÚÈÝÆ÷ÄÚ²¿ £¬ÎÒÃÇ¿ÉÒÔ×°ÖÃËùÐèµÄÈí¼þ°üºÍÒÀÀµ¡£ÒÔ×°ÖÃComposerΪÀý £¬ÔËÐÐÒÔÏÂÏÂÁ

$ apt update
$ apt install curl php-cli php-zip unzip
$ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁîÖÐ £¬ÎÒÃÇʹÓÃaptÏÂÁî×°ÖÃÁËËùÐèµÄÒÀÀµ £¬È»ºóʹÓÃcurlÏÂÁîÏÂÔØComposer×°Öþ籾 £¬²¢Í¨¹ýphpÏÂÁîÖ´Ðо籾¾ÙÐÐ×°Öá£

Æô¶¯¿ª·¢ÇéÐÎ

Íê³É¿ª·¢ÇéÐεÄÉèÖúó £¬ÎÒÃÇ¿ÉÒÔÆô¶¯WebЧÀÍÆ÷ £¬ÒÔ±ã¾ÙÐпª·¢ºÍ²âÊÔ¡£¿ÉÒÔʹÓÃApache»òNginx×÷ΪWebЧÀÍÆ÷ £¬ÕâÀïÎÒÃÇÒÔApacheΪÀý¡£ÔÚÈÝÆ÷ÄÚÔËÐÐÒÔÏÂÏÂÁ

$ apt install apache2
$ cd /etc/apache2/sites-available
$ cp 000-default.conf mysite.conf
$ a2ensite mysite.conf
$ service apache2 restart

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁîÖÐ £¬ÎÒÃÇʹÓÃaptÏÂÁî×°ÖÃÁËApache2 £¬È»ºóÉèÖÃÁËÒ»¸öеÄÐéÄâÖ÷»ú¡£×îºó £¬Í¨¹ýserviceÏÂÁîÖØÆôApacheЧÀÍ¡£

ÖÁ´Ë £¬ÎÒÃÇÒѾ­ÀֳɵØʹÓÃDockerÔÚLinuxϵͳÉÏ¿ìËÙ°²ÅÅÁË¿ª·¢ÇéÐΡ£¿ÉÒÔͨ¹ýä¯ÀÀÆ÷»á¼ûhttp://localhostÀ´Éó²éÏîÄ¿ÔËÐÐÇéÐΡ£

×ܽ᣺

DockerÊÇÒ»¸öÇ¿Ê¢µÄ¹¤¾ß £¬¿ÉÒÔʹ¿ª·¢ÇéÐεݲÅűäµÃ¼òÆÓ¶ø¸ßЧ¡£Í¨¹ýʹÓÃDocker £¬ÎÒÃÇ¿ÉÒÔ¿ìËÙ»ñÈ¡¡¢ÉèÖúÍÆô¶¯¿ª·¢ÇéÐÎ £¬Ìá¸ß¿ª·¢Ð§ÂÊ £¬²¢ïÔÌ­ÓÉÓÚÇéÐη×ÆçÖµ¼ÖµÄÎÊÌ⡣ϣÍû±¾ÎĶÔÄúÏàʶÔõÑùʹÓÃdockerÔÚlinuxÉÏ¿ìËÙ°²ÅÅ¿ª·¢ÇéÐÎÓÐËù×ÊÖú¡£

²Î¿¼×ÊÁÏ£º

Docker¹Ù·½Îĵµ£ºhttps://docs.docker.com/

PHP¹Ù·½¾µÏñ£ºhttps://hub.docker.com/_/php

ÒÔÉϾÍÊÇÔõÑùʹÓÃDockerÔÚLinuxÉÏ¿ìËÙ°²ÅÅ¿ª·¢ÇéÐΣ¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿