尊龙凯时人生就是搏

DockerÔõÑù×°ÖÃSymfony¿ò¼Ü

DockerÔõÑù×°ÖÃSymfony¿ò¼Ü

СÐò£º

SymfonyÊÇÒ»¸öÊ¢ÐеÄPHP¿ò¼Ü£¬Í¨¹ýÌṩ¸»ºñµÄ¹¦Ð§ºÍ±ã½ÝµÄ¿ª·¢·½·¨£¬Ê¹µÃ¿ª·¢ÕßÄܹ»¿ìËÙ¹¹½¨¿ÉÀ©Õ¹µÄWebÓ¦ÓóÌÐò¡£ÔÚʹÓÃSymfony¿ò¼Ü¿ª·¢ÏîĿʱ£¬½èÖúDockerÈÝÆ÷»¯ÊÖÒÕ¿ÉÒÔÌṩһ¸öÇå½à¡¢Ò»ÖµĿª·¢ÇéÐΣ¬×ÊÖúÎÒÃǸü¸ßЧµØ¾ÙÐпª·¢ºÍ°²ÅÅ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃDocker×°ÖúÍÉèÖÃSymfony¿ò¼Ü£¬²¢¸½ÓÐÏêϸµÄ´úÂëʾÀý¡£

°ì·¨1£º×°ÖÃDockerºÍDocker Compose

ÔÚ×îÏÈ֮ǰ£¬ÎÒÃÇÐèÒªÏÈ×°ÖÃDockerºÍDocker Compose¡£Docker¹Ù·½ÍøÕ¾ÌṩÁËÏêϸµÄ×°Öý̳Ì£¬¿ÉÒÔƾ֤×Ô¼ºµÄ²Ù×÷ϵͳѡÔñÏìÓ¦µÄ×°Ö÷½·¨¡£

°ì·¨2£º½¨ÉèSymfonyÏîÄ¿

ÔÚ×°ÖÃÍêDockerºÍDocker Composeºó£¬ÎÒÃÇ¿ÉÒÔ×îÏȽ¨ÉèSymfonyÏîÄ¿¡£Ê×ÏÈ£¬½¨ÉèÒ»¸öеÄĿ¼À´´æ·ÅSymfonyÏîÄ¿Ïà¹ØÎļþ£¬È»ºóÔÚÖÕ¶ËÖнøÈë¸ÃĿ¼£¬Ö´ÐÐÒÔÏÂÏÂÁ

docker run --rm --interactive --tty 
    --volume $PWD:/app 
    composer:latest create-project symfony/skeleton my_project_name

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁîÖУ¬$PWD´ú±íÄ¿½ñĿ¼£¬my_project_nameÊÇÄãµÄÏîÄ¿Ãû³Æ¡£

Ö´ÐÐÀֳɺó£¬SymfonyÓ¦ÓóÌÐòµÄ»ù±¾½á¹¹½«»á±»½¨ÉèÔÚÄ¿½ñĿ¼ÏµÄmy_project_nameÎļþ¼ÐÖС£

°ì·¨3£ºÉèÖÃDocker ComposeÎļþ

½ÓÏÂÀ´£¬ÎÒÃÇÐèÒªÉèÖÃDocker ComposeÎļþÒÔ½¨ÉèÒ»¸ö°üÀ¨ApacheºÍPHPÈÝÆ÷µÄ¿ª·¢ÇéÐΡ£ÔÚSymfonyÏîÄ¿µÄ¸ùĿ¼ÖУ¬½¨ÉèÒ»¸öÃûΪdocker-compose.ymlµÄÎļþ£¬²¢ÔÚÆäÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£º

version: '3'
services:
  php:
    image: php:7.4-apache
    volumes:
      - './my_project_name:/var/www/html'
    ports:
      - '80:80'
    depends_on:
      - db
  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: my_project_name
      MYSQL_USER: my_project_name_user
      MYSQL_PASSWORD: my_project_name_password

µÇ¼ºó¸´ÖÆ

ÉÏÊöÉèÖÃÎļþÖУ¬ÎÒÃÇʹÓÃÁËPHP 7.4ºÍApache¾µÏñ×÷ΪÎÒÃǵĿª·¢ÇéÐΣ¬Í¬Ê±ÉèÖÃÁËMySQL 5.7×÷ΪÎÒÃǵÄÊý¾Ý¿âЧÀÍ¡£Í¨¹ývolumesÖ¸Á½«SymfonyÏîĿĿ¼¹ÒÔص½ÈÝÆ÷µÄ/var/www/html·¾¶ÉÏ£¬ÕâÑùÎÒÃǾÍÄÜÔÚÈÝÆ÷ÄÚ²¿»á¼ûµ½ÏîÄ¿µÄ´úÂë¡£

°ì·¨4£ºÆô¶¯DockerÈÝÆ÷

ÔÚÉèÖúÃdocker-compose.ymlÎļþºó£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÆô¶¯DockerÈÝÆ÷£º

docker-compose up -d

µÇ¼ºó¸´ÖÆ

¸ÃÏÂÁî»áÔÚºǫ́Æô¶¯ºÍÔËÐÐSymfonyÓ¦ÓóÌÐòËùÐèµÄËùÓÐÈÝÆ÷¡£

°ì·¨5£º¼ì²éSymfony¿ò¼Ü×°ÖÃ

ÔÚËùÓÐÈÝÆ÷Æô¶¯²¢Õý³£ÔËÐкó£¬ÎÒÃÇ¿ÉÒÔͨ¹ýä¯ÀÀÆ÷»á¼ûSymfonyµÄ½Ó´ýÒ³Ã棬ÒÔÈ·±£Symfony¿ò¼ÜÀÖ³É×°Öá£ÔÚä¯ÀÀÆ÷µØµãÀ¸ÊäÈëhttp://localhost£¬ÈôÊÇÄܹ»¿´µ½SymfonyµÄ½Ó´ýÒ³Ã棬ÄÇôÌåÏÖ×°ÖÃÀֳɡ£

ÈôÊÇ×°ÖÃÀú³ÌÖÐÓöµ½ÈκÎÎÊÌ⣬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÉó²éÈÝÆ÷µÄÈÕÖ¾ÐÅÏ¢£º

docker-compose logs

µÇ¼ºó¸´ÖÆ

×ܽ᣺

ͨ¹ýDockerÈÝÆ÷»¯ÊÖÒÕ×°ÖÃSymfony¿ò¼Ü¿ÉÒÔ¼ò»¯ÏîÄ¿µÄ°²ÅźÍά»¤£¬Í¬Ê±ÌṩÁËÒ»¸öͳһµÄ¿ª·¢ÇéÐΡ£Í¨¹ý±¾ÎÄÌṩµÄ°ì·¨ºÍ´úÂëʾÀý£¬Äú¿ÉÒÔ¿ìËٵشSymfonyµÄ¿ª·¢ÇéÐΣ¬²¢×îÏÈʹÓÃSymfony¿ò¼Ü¾ÙÐпª·¢ÊÂÇ顣ϣÍûÕâƪÎÄÕ¶ÔÄúÓÐËù×ÊÖú£¡

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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