当前位置: 首页 > news >正文

网络工程毕设做网站linux网站建设技术指南 pdf

网络工程毕设做网站,linux网站建设技术指南 pdf,网站建设大作业电子版,墨子学院网站建设vip课程为 Laravel 提供生产模式下的容器化环境#xff1a;打造现代开发环境的终极指南 在现代开发中#xff0c;容器化已经成为一种趋势。使用 Docker 可以让我们轻松地管理和部署应用程序。本文将带你一步步构建一个高效的 Laravel 容器化环境#xff0c;确保你的应用程序在开发…为 Laravel 提供生产模式下的容器化环境打造现代开发环境的终极指南 在现代开发中容器化已经成为一种趋势。使用 Docker 可以让我们轻松地管理和部署应用程序。本文将带你一步步构建一个高效的 Laravel 容器化环境确保你的应用程序在开发和生产环境中都能顺畅运行。 功能: 拆分队列运行容器和web服务容器开发环境和生产环境分离日志监控方便升级可推送K8s环境实现弹性伸缩. 最终文件结构laravel 源代码在 src中. 一、Docker Compose 文件配置 首先我们需要创建一个 docker-compose.yml 文件这个文件定义了我们的服务及其配置。 version: 3 services: app:build:context: .dockerfile: Dockerfileenvironment:- COMPOSER_PROCESS_TIMEOUT6000 ports:- 8290:80volumes:- /etc/hosts:/etc/hosts - ../src:/var/www/htmllogging: # 可以使用loki将log采集并在grafana中设置监控和告警 driver: lokioptions:loki-url: http://localhost:3100/loki/api/v1/pushloki-retries: 5loki-batch-size: 100no-file: truecommand: bash -c chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache service nginx start php-fpmworker:build:context: .dockerfile: Dockerfileenvironment:- COMPOSER_PROCESS_TIMEOUT6000 command: php artisan horizonvolumes:- /etc/hosts:/etc/hosts - ../src:/var/www/html# laravel 的源代码我们可以放在上层文件夹中logging:driver: lokioptions:loki-url: http://localhost:3100/loki/api/v1/pushloki-retries: 5loki-batch-size: 100no-file: true links:- app二、Dockerfile 配置 接下来我们需要编写 Dockerfile 文件定义应用程序的运行环境。这样可以很容易的拆分开开发和生产环境 # Use the base PHP image with the specified version FROM php:8.2.14-fpm# Set the working directory inside the container WORKDIR /var/www/html# Update package lists and install necessary dependencies RUN apt-get update apt-get install -y \curl \libpng-dev \libonig-dev \libxml2-dev \zip \unzip \libzip-dev \libjpeg-dev \libfreetype6-dev \libssl-dev \libcurl4-openssl-dev # Install Nginx RUN apt-get install -y nginx# Install PHP extensions required by your application RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip RUN docker-php-ext-install soap RUN docker-php-ext-install ctype RUN docker-php-ext-install curl RUN docker-php-ext-install dom RUN docker-php-ext-install fileinfo RUN docker-php-ext-install filter RUN docker-php-ext-install session RUN docker-php-ext-install xml RUN docker-php-ext-install ftp# Install and enable the Redis extension RUN pecl install redis docker-php-ext-enable redis# Install Xdebug extension # RUN pecl install xdebug docker-php-ext-enable xdebug# Copy the application files into the container # COPY . .# Change ownership of directories used by the application # RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cacheRUN curl -sS https://getcomposer.org/installer | php -- --install-dir/usr/local/bin --filenamecomposer# RUN composer install --optimize-autoloader --no-devCOPY nginx.conf /etc/nginx/sites-available/defaultRUN rm /var/www/html/index.nginx-debian.html# Expose ports 80 and 443 to the outside world EXPOSE 80 EXPOSE 443# Set the default command to run when the container starts CMD service nginx start php-fpm三、Nginx 配置 创建一个 nginx.conf 文件配置 Nginx 以服务我们的 Laravel 应用程序。 server {listen 80;server_name localhost;root /var/www/html/public;index index.php index.html index.htm;location / {try_files $uri $uri/ /index.php?$query_string;}location ~ \.php$ {include fastcgi_params;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_read_timeout 3000;fastcgi_connect_timeout 3000;fastcgi_send_timeout 3000;}location ~ /\.ht {deny all;} }四、Makefile 配置 为了更方便地管理 Docker 容器我们可以使用 Makefile 定义常用的命令。 install: build docker compose run --rm app composer install docker compose run --rm app cp -f .env.prod .envupdate:docker compose run --rm app composer updatecache:docker compose run --rm app php artisan route:cachedocker compose run --rm app php artisan config:cachedocker compose run --rm app composer dump-autoload -obuild: build-app build-work build-app:docker compose -f docker-compose.yml build appbuild-work:docker compose -f docker-compose.yml build workerstart:docker compose -f docker-compose.yml up -dstop:docker compose -f docker-compose.yml downrestart: docker compose -f docker-compose.yml restartexec:docker compose exec app /bin/bashinfo:docker compose run --rm app php -i通过以上配置我们可以轻松地为 Laravel 应用提供一个容器化环境。这不仅提高了开发效率还确保了生产环境的稳定性。赶快试试吧喜欢这篇文章的话不要忘了点赞、收藏和分享哦 希望这篇文章对你有帮助如果有任何疑问或建议欢迎在评论区留言。你的支持是我继续创作的动力
http://www.dnsts.com.cn/news/60028.html

相关文章:

  • 网站开发自学资料我想做京东网站淘宝怎么做
  • 桂林市住房和城乡建设局网站wordpress网页教程百度云
  • 锐旗网站建设网站建设 用什么语言
  • 开源网站 做镜像 如何做学校网站设计论文
  • 如何将图片生成网址东莞百度seo在哪里
  • 视觉差的网站北京装饰公司名称
  • 网站有多少个做外贸的网站有哪些
  • dw做的静态网站怎么分享链接Checkout v1.4.1 WordPress主题
  • 浙江华纳建设有限公司网站百度查一下
  • 网站开发项目税率雄安网建 网站建设
  • 专业摄影网站移动论坛网站模板
  • 汽车集团网站建设网页简单模板下载
  • 盐城中瑞做网站公司模板网站
  • 网站建设佰金手指科杰十一wordpress 500错误
  • 企业自助建站百度网页版网址链接
  • 网站制作公司获取客户w7自己做网站
  • 网站系统分析关键词优化公司哪家推广
  • 一个网站同时做百度和360 百度商桥都可以接收客户信息吗html5从入门到精通
  • 经营地址怎么在国税网站做更改做百度推广去些网站加客户
  • 哪个网站专门做政策解读做爰全过程免费视频网站
  • 365建站器网站如何选择服务器
  • 义县城乡建设局网站高端品牌网站建设网站开发注意什么
  • 做网站范本青岛百度网站排名
  • 京东网站是哪个公司做的罗湖商城网站设计公司
  • 网站开发分前台后台中企动力为什么一直招人
  • 个人做网站开工作室做公众好号的网站吗
  • 网站建设与维护工作各大网站官网的导航栏怎么做
  • 工会教工之家网站建设网站悬浮
  • 网站的构成wordpress查询数据库乱码
  • 网站登录模版 下载wordpress设置ip