濮阳杆衣贸易有限公司

主頁 > 知識庫 > Docker部署Laravel應(yīng)用的實現(xiàn)示例

Docker部署Laravel應(yīng)用的實現(xiàn)示例

熱門標簽:虛假地圖標注 濮陽好的聯(lián)通400電話申請 地圖標注如何改成微信號 靈圖uu電子寵物店地圖標注 百度地圖標注公司位置要多少錢 承德地圖標注公司 400電話號碼辦理多少錢 地圖標注黃河的位置 山東企業(yè)外呼系統(tǒng)公司
  • 本文 PHP 基礎(chǔ)鏡像使用:php:7.3-apache
  • 本文 Laravel 版本為:laravel:5.8.*
  • 隊列和任務(wù)調(diào)度我們在下一篇寫

一、 準備我們的 Laravel 應(yīng)用

# 運行 mix 命令,打包 js、css、img 文件,如果沒有用到 mix 這一步可以省略
npm install
npm run production
# 安裝 composer.lock 中的依賴
composer install --ignore-platform-reqs --optimize-autoloader --no-dev

二、 準備 Apache 配置文件 docker/000-default.conf

<VirtualHost *:80>
 # The ServerName directive sets the request scheme, hostname and port that
 # the server uses to identify itself. This is used when creating
 # redirection URLs. In the context of virtual hosts, the ServerName
 # specifies what hostname must appear in the request's Host: header to
 # match this virtual host. For the default virtual host (this file) this
 # value is not decisive as it is used as a last resort host regardless.
 # However, you must set it for any further virtual host explicitly.
 #ServerName www.example.com

 ServerAdmin liuzhaowei55@gmail.com
 DocumentRoot /var/www/html/public

 # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
 # error, crit, alert, emerg.
 # It is also possible to configure the loglevel for particular
 # modules, e.g.
 #LogLevel info ssl:warn

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

 # For most configuration files from conf-available/, which are
 # enabled or disabled at a global level, it is possible to
 # include a line for only one particular virtual host. For example the
 # following line enables the CGI configuration for this host only
 # after it has been globally disabled with "a2disconf".
 #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

三、 準備 Dockerfile 文件

FROM php:7.3-apache

LABEL maintainer="liuzhaowei55@gmail.com"

# 設(shè)置時區(qū)
ARG TZ=Asia/Shanghai
ENV TZ ${TZ}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# 安裝軟件 cron
RUN set -eux \

 && apt-get update \

 && apt-get install -y --no-install-recommends cron \

 && apt-get autoremove \

 && apt-get autoclean \

 && apt-get clean \

 && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 
# 安裝拓展
ENV PHP_EXTENSION \

 pdo_mysql \

 bcmath
ENV PECL_EXTENSION \

 redis
RUN docker-php-ext-install $PHP_EXTENSION \

 && pecl install $PECL_EXTENSION \

 && docker-php-ext-enable $PECL_EXTENSION \

    opcache \

 && a2enmod rewrite
 
# 訪問端口
EXPOSE 80

ARG APP_ENV=development
ENV APP_ENV ${APP_ENV}

COPY --chown=www-data:www-data . /var/www/html
COPY docker/000-default.conf /etc/apache2/sites-available/000-default.conf
WORKDIR /var/www/html

四、準備 Dockerignore 文件:.dockerignore(非必需)

/node_modules
/.dockerignore
/Dockerfile

五、準備鏡像入口文件:docker-entrypoint.sh(非必需)

注意一下,此文件需要執(zhí)行權(quán)限,不過此入口文件不是必須的,只是為了在應(yīng)用運行前執(zhí)行一些緩存命令,具體可以點這里去文檔了解一下。

#!/usr/bin/env bash

php artisan cache:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache

apache2-foreground

六、運行鏡像

docker run -p 80:80 .

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

標簽:泰安 鷹潭 淮安 德宏 上海 福州 安康 樂山

巨人網(wǎng)絡(luò)通訊聲明:本文標題《Docker部署Laravel應(yīng)用的實現(xiàn)示例》,本文關(guān)鍵詞  Docker,部署,Laravel,應(yīng),用的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Docker部署Laravel應(yīng)用的實現(xiàn)示例》相關(guān)的同類信息!
  • 本頁收集關(guān)于Docker部署Laravel應(yīng)用的實現(xiàn)示例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    措美县| 手游| 宜昌市| 德钦县| 绍兴市| 宝应县| 香河县| 甘洛县| 甘南县| 清流县| 汶川县| 淳安县| 沈丘县| 鸡西市| 礼泉县| 万荣县| 上高县| 沅江市| 永清县| 高唐县| 太康县| 上杭县| 芮城县| 玉山县| 依兰县| 吕梁市| 大名县| 石泉县| 化州市| 栾川县| 秭归县| 海淀区| 松潘县| 厦门市| 灵丘县| 江门市| 东光县| 沈丘县| 潢川县| 晴隆县| 精河县|