尊龙凯时人生就是搏

Symfony¿ò¼ÜµÄDocker°²ÅÅÓë×°ÖÃÖ¸ÄÏ

Symfony¿ò¼ÜµÄDocker°²ÅÅÓë×°ÖÃÖ¸ÄÏ

ͻ񻣼

Symfony¿ò¼ÜÊÇÒ»¸ö¹¦Ð§Ç¿Ê¢ÇÒÊ¢ÐеÄPHP¿ª·¢¿ò¼Ü£¬ËüÌṩÁËÐí¶à±ãµ±µÄ¹¦Ð§ºÍ¹¤¾ßÀ´¼ÓËÙ¿ª·¢Àú³Ì¡£¶øDockerÔòÊÇÒ»ÖÖÆÕ±éʹÓõÄÈÝÆ÷»¯Æ½Ì¨£¬Í¨¹ý½«Ó¦ÓóÌÐòÓëÆäÒÀÀµÏî´ò°üµ½ÈÝÆ÷ÖУ¬¿ÉÒÔ¼ò»¯°²ÅźÍÔËάÀú³Ì¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚDockerÇéÐÎÖа²ÅÅÓë×°ÖÃSymfony¿ò¼Ü£¬²¢ÌṩÏà¹ØµÄ´úÂëʾÀý¡£

Ò»¡¢×°ÖÃDocker

ÔÚLinuxϵͳÖУ¬·­¿ªÖն˲¢ÊäÈëÒÔÏÂÏÂÁîÀ´×°ÖÃDocker£º

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

µÇ¼ºó¸´ÖÆ

ÔÚWindowsϵͳÖУ¬¿ÉÒÔ´ÓDocker¹ÙÍø https://www.docker.com/products/docker-desktop ÏÂÔØDocker Desktop²¢Æ¾Ö¤×°ÖÃÏòµ¼¾ÙÐÐ×°Öá£

¶þ¡¢½¨ÉèSymfonyÏîÄ¿

ʹÓÃComposer½¨ÉèÒ»¸öеÄSymfonyÏîÄ¿£º

composer create-project symfony/skeleton myproject

µÇ¼ºó¸´ÖÆ

½øÈëÏîĿĿ¼£º

cd myproject

µÇ¼ºó¸´ÖÆ

Æô¶¯Symfony¿ª·¢Ð§ÀÍÆ÷£º

bin/console server:start

µÇ¼ºó¸´ÖÆ

Èý¡¢¹¹½¨Docker¾µÏñ

ÔÚÏîÄ¿¸ùĿ¼Öн¨ÉèÒ»¸öÃûΪDockerfileµÄÎļþ£¬ÓÃÓÚ½ç˵Docker¾µÏñµÄ¹¹½¨¹æÔò£º

FROM php:7.4-apache
WORKDIR /var/www/html
COPY . /var/www/html
RUN apt-get update && apt-get install -y 
 libzip-dev 
 unzip 
 && docker-php-ext-install pdo_mysql zip 
 && a2enmod rewrite
EXPOSE 80

µÇ¼ºó¸´ÖÆ

ÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁîÀ´¹¹½¨Docker¾µÏñ£º

docker build -t myproject .

µÇ¼ºó¸´ÖÆ

ËÄ¡¢Æô¶¯SymfonyÏîÄ¿

ÊäÈëÒÔÏÂÏÂÁîÀ´½¨ÉèÒ»¸öÃûΪmyprojectµÄÈÝÆ÷²¢Æô¶¯SymfonyÏîÄ¿£º

docker run -d -p 8080:80 --name myproject_container myproject

µÇ¼ºó¸´ÖÆ

ÏÖÔÚ£¬Äú¿ÉÒÔÔÚä¯ÀÀÆ÷Öлá¼û http://localhost:8080 À´Éó²éÔËÐÐÖеÄSymfonyÓ¦ÓóÌÐò¡£

Î塢ʹÓÃDocker Compose¾ÙÐа²ÅÅ

ÔÚÏîÄ¿¸ùĿ¼Öн¨ÉèÒ»¸öÃûΪdocker-compose.ymlµÄÎļþ£º

version: '3'
services:
  myproject:
 build:
   context: .
   dockerfile: Dockerfile
 ports:
   - 8080:80
 volumes:
   - .:/var/www/html

µÇ¼ºó¸´ÖÆ

ÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁîÀ´Ê¹ÓÃDocker ComposeÆô¶¯SymfonyÏîÄ¿£º

docker-compose up -d

µÇ¼ºó¸´ÖÆ

Áù¡¢¿¢ÊÂÓëÕûÀí

ÊäÈëÒÔÏÂÏÂÁîÀ´×èÖ¹²¢É¾³ýÈÝÆ÷£º

docker stop myproject_container
docker rm myproject_container

µÇ¼ºó¸´ÖÆ

ÈôÊDz»ÔÙÐèÒª£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´É¾³ýDocker¾µÏñ£º

docker rmi myproject

µÇ¼ºó¸´ÖÆ

½áÂÛ£º

ͨ¹ýʹÓÃDockerÀ´°²ÅźÍÔËÐÐSymfony¿ò¼Ü£¬ÎÒÃÇ¿ÉÒÔʵÏÖ´úÂëµÄ¿ÉÒÆÖ²ÐÔ¡¢ÇéÐεÄÒ»ÖÂÐԺͿìËÙ°²ÅÅ¡£±¾ÎÄÌṩÁË×°ÖÃDocker¡¢½¨ÉèSymfonyÏîÄ¿¡¢¹¹½¨Docker¾µÏñ¡¢Æô¶¯SymfonyÏîÄ¿ÒÔ¼°Ê¹ÓÃDocker Compose¾ÙÐа²ÅŵȰ취µÄÖ¸ÄϺʹúÂëʾÀý£¬Ï£Íû¶ÔÄúÔÚSymfonyÏîÄ¿µÄDocker°²ÅźÍ×°ÖÃÀú³ÌÖÐÓÐËù×ÊÖú¡£

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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