尊龙凯时人生就是搏

½ÌÄãÔõÑùÔÚDockerÈÝÆ÷ÖÐ×°ÖÃSymfony¿ò¼Ü

½ÌÄãÔõÑùÔÚDockerÈÝÆ÷ÖÐ×°ÖÃSymfony¿ò¼Ü

ÔÚÄ¿½ñµÄ¿ª·¢ÇéÐÎÖУ¬ÈÝÆ÷»¯ÊÖÒÕµÄÓ¦ÓÃÔ½À´Ô½Æձ飬Docker×÷ΪÆäÖÐ×î¾ß´ú±íÐÔµÄÊÖÒÕÖ®Ò»£¬ÔÚÓ¦Óð²ÅźͿª·¢·½ÃæÊ©Õ¹ÁËÖ÷Òª×÷Óᣱ¾ÎĽ«½ÌÄãÔõÑùÔÚDockerÈÝÆ÷ÖÐ×°ÖÃSymfony¿ò¼Ü£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£

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

ÒªÔÚÍâµØÇéÐÎÖÐʹÓÃDocker£¬Ê×ÏÈÐèҪװÖÃDockerÒýÇæ¡£Äã¿ÉÒÔ´ÓDocker¹Ù·½ÍøÕ¾ÉÏÏÂÔز¢×°ÖÃÊÊÓÃÓÚÄãµÄ²Ù×÷ϵͳµÄ°æ±¾¡£×°ÖÃÍê³Éºó£¬ÔËÐÐdocker –versionÏÂÁîÀ´ÑéÖ¤DockerÊÇ·ñÒѾ­×¼È·×°Öá£

µÚ¶þ²½£º×¼±¸SymfonyÏîÄ¿

ÔÚ×îÏÈ֮ǰ£¬ÄãÐèҪ׼±¸Ò»¸öSymfonyÏîÄ¿¡£Äã¿ÉÒÔÔÚSymfony¹Ù·½ÍøÕ¾£¨https://symfony.com/£©ÉÏÕÒµ½½¨ÉèÏîÄ¿µÄÏêϸ°ì·¨¡£ÔÚ½¨ÉèÏîĿʱ£¬ÇëÈ·±£ÏîÄ¿Äܹ»ÔÚÍâµØÕý³£ÔËÐС£

µÚÈý²½£º½¨ÉèDockerfile

ÔÚÏîÄ¿¸ùĿ¼Ï½¨ÉèÒ»¸öÃûΪDockerfileµÄÎļþ£¬ÓÃÓÚ½ç˵Docker¾µÏñµÄ¹¹½¨Àú³Ì¡£ÒÔÏÂÊÇÒ»¸öʾÀýµÄDockerfileÎļþÄÚÈÝ£º

FROM php:7.4-apache

# ×°ÖÃÐëÒªµÄÀ©Õ¹
RUN docker-php-ext-install pdo_mysql

# ÉèÖÃApacheµÄDocumentRoot
ENV APACHE_DOCUMENT_ROOT /var/www/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

# ½«SymfonyÏîÄ¿¸´ÖƵ½¾µÏñÖÐ
COPY . /var/www

# ÉèÖÃÏîÄ¿ÒÀÀµ
RUN cd /var/www && 
    curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && 
    composer install --no-scripts --no-autoloader

# ÉèÖÃApacheµÄrewriteÄ£¿é
RUN a2enmod rewrite

# ̻¶ÈÝÆ÷µÄ80¶Ë¿Ú
EXPOSE 80

# Æô¶¯ApacheЧÀÍÆ÷
CMD ["apache2-foreground"]

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öʾÀýµÄDockerfileÖУ¬ÎÒÃÇÑ¡ÔñÁËPHP 7.4ºÍApache×÷Ϊ»ù´¡¾µÏñ£¬×°ÖÃÁËSymfonyËùÐèµÄpdo_mysqlÀ©Õ¹£¬²¢ÉèÖÃÁËApacheµÄDocumentRootΪSymfonyÏîÄ¿µÄpublicĿ¼¡£È»ºó£¬ÎÒÃǽ«SymfonyÏîÄ¿µÄÎļþ¸´ÖƵ½ÈÝÆ÷µÄ/var/wwwĿ¼Ï£¬²¢Ê¹ÓÃComposer×°ÖÃÏîÄ¿µÄÒÀÀµ¡£×îºó£¬ÎÒÃÇÆôÓÃÁËApacheµÄrewriteÄ£¿é£¬²¢Ì»Â¶ÁËÈÝÆ÷µÄ80¶Ë¿Ú¡£

µÚËIJ½£º¹¹½¨Docker¾µÏñ

ÔÚÏîĿĿ¼Ï£¬·­¿ªÖնˣ¬ÔËÐÐÒÔÏÂÏÂÁîÀ´¹¹½¨Docker¾µÏñ£º

docker build -t symfony-app .

µÇ¼ºó¸´ÖÆ

Õâ¸öÏÂÁ»áƾ֤DockerfileÎļþÀ´¹¹½¨Ò»¸öÃûΪsymfony-appµÄ¾µÏñ¡£ÇëÈ·±£ÔÚÏÂÁîµÄ×îºóÓÐÒ»¸ö¾äµã£¬ÌåÏÖ¸ÃÏÂÁîÔÚÄ¿½ñĿ¼Ï²éÕÒDockerfileÎļþ¡£

µÚÎå²½£ºÔËÐÐDockerÈÝÆ÷

¹¹½¨Íê³Éºó£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÔËÐÐÒÔÏÂÏÂÁîÀ´Æô¶¯SymfonyÓ¦ÓõÄDockerÈÝÆ÷£º

docker run -p 8080:80 symfony-app

µÇ¼ºó¸´ÖÆ

Õâ¸öÏÂÁ»áÔÚÍâµØµÄ8080¶Ë¿ÚÉÏÆô¶¯SymfonyÓ¦ÓõÄDockerÈÝÆ÷¡£Äã¿ÉÒÔͨ¹ý»á¼ûhttp://localhost:8080À´Éó²éSymfonyÓ¦ÓÃÊÇ·ñÀÖ³ÉÔËÐС£

×ܽá

ͨ¹ýÒÔÉÏ°ì·¨£¬ÄãÒѾ­ÀֳɵØÔÚDockerÈÝÆ÷ÖÐ×°ÖÃÁËSymfony¿ò¼Ü¡£ÕâʹµÃÄãÄܹ»Ô½·¢ÎÞаµØ°²ÅźͿª·¢SymfonyÓ¦Óã¬Í¬Ê±Ò²Äܹ»¸üºÃµØ¸ôÀëºÍÖÎÀíÔËÐÐÇéÐΡ£Ï£Íû±¾ÎÄÄܹ»×ÊÖúµ½Ä㣬ףÄãʹÓÃDockerºÍSymfony¿ò¼ÜµÄÓä¿ì¿ª·¢£¡

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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