尊龙凯时人生就是博

DockerÊÃ÷ÈÕ½£º¿ìËÙ×°ÖÃSymfony²¢ÉèÖÿª·¢ÇéÐÎ

DockerÊÃ÷ÈÕ½£º¿ìËÙ×°ÖÃSymfony²¢ÉèÖÿª·¢ÇéÐÎ

СÐò£º

Ëæ×ÅÔÆÅÌËãºÍÈÝÆ÷»¯ÊÖÒÕµÄѸËÙÉú³¤£¬DockerÒѳÉΪÏÖ´úÓ¦ÓóÌÐò¿ª·¢ºÍ°²ÅŵÄÖ÷Òª¹¤¾ßÖ®Ò»¡£Symfony×÷ΪһÖÖÊ¢ÐеÄPHP¿ò¼Ü£¬Ò²¿ÉÒÔͨ¹ýDocker¿ìËÙ×°ÖúÍÉèÖÿª·¢ÇéÐΡ£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃDocker×°ÖÃSymfony£¬²¢Ïêϸ˵Ã÷¿ª·¢ÇéÐεÄÉèÖð취£¬Í¬Ê±ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£

µÚÒ»²¿·Ö£º×°ÖÃDocker

Òª×îÏÈʹÓÃDocker£¬Ê×ÏÈÐèÒªÔÚ±¾»úÉÏ×°ÖÃDocker¡£Çëƾ֤Docker¹Ù·½ÎĵµÌṩµÄÖ¸ÄÏ£¬ÏÂÔغÍ×°ÖÃÊʺÏÄú²Ù×÷ϵͳµÄDocker°æ±¾¡£ÔÚ×°ÖÃÍê³Éºó£¬Äú¿ÉÒÔͨ¹ýÔÚÖն˻òÏÂÁîÌáÐÑ·ûÏÂÊäÈë¡°docker –version¡±À´ÑéÖ¤DockerÊÇ·ñÒÑÀÖ³É×°Öá£

µÚ¶þ²¿·Ö£ºÊ¹ÓÃDocker×°ÖÃSymfony

½¨ÉèSymfonyÏîÄ¿

·­¿ªÖն˻òÏÂÁîÌáÐÑ·û£¬½øÈëÄúÏëÒª´æ´¢SymfonyÏîÄ¿µÄĿ¼¡£Ê¹ÓÃÏÂÃæµÄÏÂÁÉèÒ»¸öеÄSymfonyÏîÄ¿£º

docker run -it --rm -v $(pwd):/app composer create-project symfony/website-skeleton myproject
cd myproject

µÇ¼ºó¸´ÖÆ

´ËÏÂÁ½¨ÉèÒ»¸öÃûΪ¡°myproject¡±µÄÐÂSymfonyÏîÄ¿£¬²¢½«Æä´æ´¢ÔÚÄ¿½ñĿ¼ÖС£

¹¹½¨Docker¾µÏñ

ÔÚSymfonyÏîÄ¿µÄ¸ùĿ¼Öн¨ÉèÒ»¸öÃûΪ¡°Dockerfile¡±µÄÎļþ£¬²¢Ìí¼ÓÏÂÃæµÄÄÚÈÝ£º

FROM php:7.4.2-apache

RUN apt-get update && apt-get install -y 
    libicu-dev 
    && docker-php-ext-install -j$(nproc) intl

RUN a2enmod rewrite

COPY . /var/www/html/

µÇ¼ºó¸´ÖÆ

Õâ¸öDockerfileʹÓÃPHP 7.4.2ºÍApache×÷Ϊ»ù´¡¾µÏñ£¬²¢×°ÖÃÁËSymfonyËùÐèµÄIntlÀ©Õ¹¡£±ðµÄ£¬ÎÒÃÇ»¹ÆôÓÃÁËApacheµÄrewriteÄ £¿é£¬²¢½«SymfonyÏîÄ¿µÄËùÓÐÎļþ¸´ÖƵ½ÈÝÆ÷µÄ/var/www/html/Ŀ¼ÖС£

¹¹½¨Docker¾µÏñ

ÔÚSymfonyÏîÄ¿µÄ¸ùĿ¼ÖÐÔËÐÐÒÔÏÂÏÂÁʹÓÃÉÏÊöDockerfile¹¹½¨Ò»¸öеÄDocker¾µÏñ£º

docker build -t symfony-app .

µÇ¼ºó¸´ÖÆ

´ËÏÂÁƾ֤Ŀ½ñĿ¼µÄDockerfile¹¹½¨Ò»¸öÃûΪ¡°symfony-app¡±µÄоµÏñ¡£

ÔËÐÐSymfonyÓ¦ÓóÌÐò

ÔËÐÐÒÔÏÂÏÂÁîÒÔÆô¶¯SymfonyÓ¦ÓóÌÐò£º

docker run -d -p 8000:80 --name symfony-app symfony-app

µÇ¼ºó¸´ÖÆ

´ËÏÂÁÆô¶¯Ò»¸öÃûΪ¡°symfony-app¡±µÄÈÝÆ÷£¬²¢½«ÆäÓ³Éäµ½Ö÷»úµÄ8000¶Ë¿ÚÉÏ¡£

»á¼ûSymfonyÓ¦ÓóÌÐò

ÔÚä¯ÀÀÆ÷Öлá¼û¡°http£º//localhost£º8000¡±¼´¿ÉÉó²éÔËÐÐÖеÄSymfonyÓ¦ÓóÌÐò¡£

µÚÈý²¿·Ö£ºÉèÖÃSymfony¿ª·¢ÇéÐÎ

SymfonyÓ¦ÓóÌÐòÒѾ­ÔÚDockerÈÝÆ÷ÖÐÀÖ³ÉÔËÐУ¬ÏÖÔÚÎÒÃÇÐèҪΪ¿ª·¢ÇéÐξÙÐÐһЩ³£¼ûµÄÉèÖá£

ÉèÖÃÊý¾Ý¿âÅþÁ¬

·­¿ªSymfonyÏîÄ¿µÄ¸ùĿ¼Öеġ°.env¡±Îļþ£¬ÕÒµ½ÒÔÏÂÐУ¬²¢½«ÆäÐÞ¸ÄΪÊʺÏÄúµÄÊý¾Ý¿âÉèÖãº

DATABASE_URL=mysql://db_user:db_password@database_host:database_port/db_name

µÇ¼ºó¸´ÖÆ

½«¡°db_user¡±Ì滻ΪÄúµÄÊý¾Ý¿âÓû§Ãû£¬¡°db_password¡±Ì滻ΪÄúµÄÊý¾Ý¿âÃÜÂ룬¡°database_host¡±Ì滻ΪÄúµÄÊý¾Ý¿âÖ÷»ú£¬¡°database_port¡±Ì滻ΪÄúµÄÊý¾Ý¿â¶Ë¿Ú£¬¡°db_name¡±Ì滻ΪÄúµÄÊý¾Ý¿âÃû¡£

ÔËÐÐÊý¾Ý¿âǨáã

ÔÚÖն˻òÏÂÁîÌáÐÑ·ûϽøÈëSymfonyÏîÄ¿µÄ¸ùĿ¼£¬²¢ÔËÐÐÒÔÏÂÏÂÁîÀ´ÔËÐÐÊý¾Ý¿âǨá㣺

docker exec -it symfony-app bin/console doctrine:migrations:migrate

µÇ¼ºó¸´ÖÆ

´ËÏÂÁӦÓÃÈκδý´¦ÀíµÄÊý¾Ý¿âǨáã¡£

×°ÖÃSymfonyÔËÐÐʱ×é¼þ

ÔÚÖն˻òÏÂÁîÌáÐÑ·ûϽøÈëSymfonyÏîÄ¿µÄ¸ùĿ¼£¬²¢ÔËÐÐÒÔÏÂÏÂÁîÀ´×°ÖÃSymfonyÔËÐÐʱ×é¼þ£º

docker exec -it symfony-app composer install

µÇ¼ºó¸´ÖÆ

´ËÏÂÁװÖÃËùÐèµÄËùÓÐSymfonyÔËÐÐʱ×é¼þ¡£

ÉèÖÿª·¢¹¤¾ß

ÈôÊÇÄúÏëʹÓÿª·¢¹¤¾ß£¬ÈçPHPStorm£¬ÅþÁ¬µ½SymfonyÈÝÆ÷£¬ÇëʹÓÃÒÔÏÂÉèÖãº

ÈÝÆ÷Ãû³Æ£¨ÈÝÆ÷ID£©£ºsymfony-app

ЧÀÍÆ÷£ºlocalhost

¶Ë¿Ú£º8000

Ó³Éäµ½´úÂëÖеÄĿ¼£º/var/www/html

ÕâÑù£¬Äú¾Í¿ÉÒÔͨ¹ý¿ª·¢¹¤¾ßÖ±½ÓÔÚSymfonyÈÝÆ÷ÖоÙÐдúÂë±à¼­ºÍµ÷ÊÔ¡£

½áÂÛ£º

ͨ¹ýDocker£¬ÎÒÃÇ¿ÉÒÔ¿ìËÙÀû±ãµØ×°ÖúÍÉèÖÃSymfony¿ª·¢ÇéÐΡ£±¾ÎÄÌṩÁËÏêϸµÄ°ì·¨ºÍ´úÂëʾÀý£¬×ÊÖú¶ÁÕß¿ìËÙÉÏÊÖ²¢×îÏÈʹÓÃSymfony¾ÙÐпª·¢¡£Ê¹ÓÃDocker£¬ÎÒÃÇ¿ÉÒÔÇáËɵشºÍÇл»¿ª·¢ÇéÐΣ¬Ìá¸ß¿ª·¢Ð§ÂʺʹúÂëÖÊÁ¿¡£×£ÄúÔÚSymfony¿ª·¢Ö®ÂÃÖÐÈ¡µÃÀֳɣ¡

£¨×¢£ºÒÔÉÏ´úÂëʾÀý½ö¹©²Î¿¼£¬Çëƾ֤ÏÖÕæÏàÐξÙÐе÷½âºÍÐ޸ġ££©

ÒÔÉϾÍÊÇDockerÊÃ÷ÈÕ½£º¿ìËÙ×°ÖÃSymfony²¢ÉèÖÿª·¢ÇéÐεÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

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

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

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