尊龙凯时人生就是博

Docker×°ÖÃSymfony£ºÒ»¼ü°²ÅÅÖ¸ÄÏ

Docker×°ÖÃSymfony£ºÒ»¼ü°²ÅÅÖ¸ÄÏ

СÐò£º

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

µÚÒ»²¿·Ö£º×¼±¸ÊÂÇé

ÔÚ×îÏÈ°²ÅÅSymfony֮ǰ£¬ÎÒÃÇÐèÒªÏÈÈ·±£ÎÒÃǵĿª·¢ÇéÐÎÖÐÒѾ­×°ÖúÃÁËDockerºÍDocker Compose¡ £¿ÉÒÔÔÚDocker¹ÙÍøÉÏÕÒµ½ÏìÓ¦µÄ×°Öý̳Ì¡£

µÚ¶þ²¿·Ö£º½¨ÉèSymfonyÓ¦ÓÃ

Ê×ÏÈ£¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸öSymfonyÓ¦Ó᣷­¿ªÖն˲¢½øÈëÒ»¸öÓÃÓÚ´æ·ÅÓ¦ÓõÄĿ¼£¬Ö´ÐÐÒÔÏÂÏÂÁ

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

µÇ¼ºó¸´ÖÆ

Õâ¸öÏÂÁî»áÔÚÄ¿½ñĿ¼Öн¨ÉèÒ»¸öÃûΪmy_appµÄSymfonyÓ¦Óá£

µÚÈý²¿·Ö£ºÉèÖÃDocker ComposeÎļþ

ÔÚÏîÄ¿¸ùĿ¼Ï½¨ÉèÒ»¸öÃûΪdocker-compose.ymlµÄÎļþ£¬²¢Ð´ÈëÒÔÏÂÄÚÈÝ£º

version: '3'
services:
  php:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    volumes:
      - .:/var/www/html
  nginx:
    image: nginx:latest
    ports:
      - 80:80
    volumes:
      - .:/var/www/html
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
  mysql:
    image: mysql:latest
    environment:
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - db_data:/var/lib/mysql
volumes:
  db_data:

µÇ¼ºó¸´ÖÆ

Õâ¸öÉèÖÃÎļþ½ç˵ÁËÈý¸öЧÀÍ£ºphp¡¢nginxºÍmysql¡£phpЧÀÍʹÓÃÁËÒ»¸öDockerfileÎļþÀ´¹¹½¨£¬ÎÒÃÇÐèÒªÔÚÏîÄ¿¸ùĿ¼Ï½¨ÉèÒ»¸öÃûΪdocker/phpµÄĿ¼£¬²¢ÔÚ¸ÃĿ¼Ï½¨ÉèÒ»¸öDockerfileÎļþ£¬Ð´ÈëÒÔÏÂÄÚÈÝ£º

FROM php:7.4-fpm-alpine

RUN docker-php-ext-install pdo_mysql

WORKDIR /var/www/html

µÇ¼ºó¸´ÖÆ

Õâ¸öDockerfileÎļþ½ç˵ÁË»ùÓÚphp:7.4-fpm-alpine¾µÏñµÄDockerÈÝÆ÷£¬×°ÖÃÁËpdo_mysqlÀ©Õ¹£¬²¢½«ÊÂÇéĿ¼ÉèÖÃΪ/var/www/html¡£

ÔÚdocker/nginxĿ¼Ï½¨ÉèÒ»¸öÃûΪdefault.confµÄÎļþ£¬Ð´ÈëÒÔÏÂÄÚÈÝ£º

server {
    listen 80;
    server_name localhost;

    root /var/www/html/public;

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index.php(/|$) {
        fastcgi_pass php:9000;
        fastcgi_split_path_info ^(.+.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

µÇ¼ºó¸´ÖÆ

Õâ¸öÉèÖÃÎļþ½ç˵ÁËNginxµÄÐéÄâÖ÷»ú£¬½«ÇëÇóת·¢µ½phpЧÀÍ¡£

µÚËIJ¿·Ö£ºÆô¶¯Ó¦ÓóÌÐò

ÔÚÏîÄ¿¸ùĿ¼ÏÂÖ´ÐÐÒÔÏÂÏÂÁîÆô¶¯Ó¦ÓóÌÐò£º

$ docker-compose up -d

µÇ¼ºó¸´ÖÆ

Õâ¸öÏÂÁî»áÆô¶¯Èý¸öÈÝÆ÷£ºphp¡¢nginxºÍmysql£¬²¢ÔÚºǫ́ÔËÐС£

µÚÎ岿·Ö£º»á¼ûÓ¦ÓóÌÐò

ÔÚä¯ÀÀÆ÷Öлá¼ûhttp://localhost£¬¼´¿É¿´µ½SymfonyÓ¦ÓóÌÐòµÄ½Ó´ýÒ³Ãæ¡£

½áÂÛ£º

ͨ¹ýʹÓÃDocker£¬ÎÒÃÇ¿ÉÒÔ¿ìËÙ¡¢Àû±ãµØ°²ÅÅSymfonyÓ¦ÓóÌÐò¡£Ö»Ðè¼òÆÓ¼¸¸ö°ì·¨£¬¼´¿ÉÇáËɴһ¸öSymfony¿ª·¢ÇéÐΡ£DockerµÄÈÝÆ÷»¯ÊÖÒÕʹµÃÓ¦Óõİ²ÅźÍÖÎÀíÔ½·¢¼òÆӺͿɿ¿£¬¼«´óµØÌá¸ßÁË¿ª·¢Ð§ÂʺÍÓ¦ÓõĿÉÉìËõÐÔ¡£Ï£Íû±¾ÎĶԸ÷ÈËÓÐËù×ÊÖú£¬×£Óä¿ìµÄSymfony¿ª·¢Ö®Âã¡

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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