×ðÁú¿­Ê±¹ÙÍøµÇ¼

Symfony¿ò¼ÜµÄDocker×°ÖÃÓëÉèÖý̳Ì

Symfony¿ò¼ÜµÄDocker×°ÖÃÓëÉèÖý̳Ì

СÐò£º

DockerÊÇÒ»ÖÖÇáÁ¿¼¶µÄÐéÄ⻯ÊÖÒÕ£¬ËüÄܹ»ÉÁ¿ª·¢Ö°Ô±½«Ó¦ÓóÌÐòÓëÆäÒÀÀµµÄÇéÐÎÒ»Æð´ò°ü³ÉÒ»¸ö¿ÉÒÆÖ²µÄÈÝÆ÷¡£Symfony¿ò¼ÜÊÇÒ»¿îÊ¢ÐеÄPHP¿ò¼Ü£¬ÓÃÓÚ¿ª·¢¸ßÖÊÁ¿µÄWebÓ¦ÓóÌÐò¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃDocker×°ÖúÍÉèÖÃSymfony¿ò¼Ü£¬²¢ÌṩÏêϸ´úÂëʾÀý¡£

Ò»¡¢×°ÖÃDocker

Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃDocker¡£Çëƾ֤ÒÔÏ°취¾ÙÐвÙ×÷£º

ÔÚÄúµÄ²Ù×÷ϵͳÉÏ×°ÖÃDocker¡£Äú¿ÉÒÔÔÚDocker¹ÙÍøÉÏÕÒµ½ÊÊÓÃÓÚÄúϵͳµÄ×°Öðü£¬²¢Æ¾Ìý˵Ã÷¾ÙÐÐ×°Öá£

×°Öú󣬷­¿ªÖն˻òÏÂÁîÐнçÃ棬ÊäÈëÒÔÏÂÏÂÁȷÈÏDockerÒѾ­×¼È·×°Öãº

docker –version

ÈôÊÇÏÔʾ³öDockerµÄ°æ±¾ÐÅÏ¢£¬ÔòÅú×¢×°ÖÃÀֳɡ£

¶þ¡¢½¨ÉèSymfonyÓ¦ÓóÌÐòµÄDocker¾µÏñ

ÏÖÔÚ£¬ÎÒÃǽ«½¨ÉèÒ»¸ö°üÀ¨Symfony¿ò¼ÜËùÐèÇéÐεÄDocker¾µÏñ¡£Çëƾ֤ÒÔÏ°취²Ù×÷£º

Ê×ÏÈ£¬½¨ÉèÒ»¸öеÄÄ¿ÈÎÃüÓÚ´æ·ÅSymfonyÓ¦ÓóÌÐò¡£ÔÚÖÕ¶ËÖУ¬ÊäÈëÒÔÏÂÏÂÁ

mkdir symfony-app

cd symfony-app

½¨ÉèÒ»¸öÃûΪ”Dockerfile”µÄÎļþ£¬²¢Ê¹ÓÃÎı¾±à¼­Æ÷·­¿ªËü¡£ÔÚ¸ÃÎļþÖУ¬Ìí¼ÓÒÔÏÂÄÚÈÝ£º

FROM php:7.4-apache

RUN apt-get update && apt-get install -y git zip

RUN curl -sS https://getcomposer.org/installer | php — –install-dir=/usr/local/bin –filename=composer

WORKDIR /var/www/html

COPY . .

RUN composer install

EXPOSE 80

CMD [“apache2-foreground”]

ÉúÑIJ¢¹Ø±ÕÎļþ¡£

½ÓÏÂÀ´£¬Ê¹ÓÃÖÕ¶ËÖ´ÐÐÒÔÏÂÏÂÁ½«Docker¾µÏñ¹¹½¨ÆðÀ´£º

docker build -t symfony-app .

ÏÖÔÚ£¬ÎÒÃÇÒѾ­Àֳɽ¨ÉèÁËÒ»¸ö°üÀ¨SymfonyËùÐèÇéÐεÄDocker¾µÏñ¡£

Èý¡¢Ê¹ÓÃDockerÈÝÆ÷ÔËÐÐSymfonyÓ¦ÓóÌÐò

ÏÖÔÚ£¬ÎÒÃǽ«Ê¹ÓÃDockerÈÝÆ÷ÔËÐÐSymfonyÓ¦ÓóÌÐò¡£Çëƾ֤ÒÔÏ°취¾ÙÐвÙ×÷£º

ÔÚÖÕ¶ËÖУ¬ÊäÈëÒÔÏÂÏÂÁÔËÐÐÎÒÃǸս¨ÉèµÄDocker¾µÏñ£º

docker run -p 8080:80 -v $(pwd):/var/www/html symfony-app

¸ÃÏÂÁ»áÆô¶¯Ò»¸öÈÝÆ÷£¬½«ÈÝÆ÷ÖеÄ80¶Ë¿ÚÓ³Éäµ½Ö÷»úµÄ8080¶Ë¿Ú£¬²¢½«Ä¿½ñĿ¼¹ÒÔص½ÈÝÆ÷ÖеÄ/var/www/htmlĿ¼¡£

·­¿ªä¯ÀÀÆ÷£¬²¢ÔڵصãÀ¸ÖÐÊäÈë”http://localhost:8080″£¬ÈôÊÇÒ»ÇÐÕý³££¬Äú½«¿´µ½SymfonyµÄ½Ó´ýÒ³Ãæ¡£

ËÄ¡¢½áÓï

ͨ¹ýʹÓÃDocker£¬ÎÒÃÇ¿ÉÒÔÀû±ãµØ´î½¨SymfonyÓ¦ÓóÌÐòµÄ¿ª·¢ÇéÐΣ¬²¢ÇÒ°ü¹ÜÁËÇéÐεÄÒ»ÖÂÐÔ¡£±¾ÎļòÒªÏÈÈÝÁËÔõÑùʹÓÃDocker×°ÖúÍÉèÖÃSymfony¿ò¼Ü£¬²¢ÌṩÁËÏêϸµÄ´úÂëʾÀý£¬Ï£Íû¶ÔÄúÓÐËù×ÊÖú¡£ÔÚÏÖʵ¿ª·¢ÖУ¬Äú¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇó½øÒ»²½ÉèÖúͶ¨ÖÆDocker¾µÏñ£¬ÒÔÖª×ãÏîÄ¿ÐèÒª¡£

ÒÔÉϾÍÊÇSymfony¿ò¼ÜµÄDocker×°ÖÃÓëÉèÖý̵̳ÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ