Docker for LAMP with multiple virtual hosts

搭建主LAMP服务器

  • 下载alpine-httpd: docker pull httpd:2.4-alpine
  • 交互式运行alpine-httpd: docker run --rm -it -p 80:80 --name apache-main httpd:2.4-alpine bash

    bash-4.3# ls
    bin      build    cgi-bin  conf     error    htdocs   icons
    include  logs     man      manual   modules
    bash-4.3# pwd
    /usr/local/apache2
    bash-4.3# ls conf/
    extra       httpd.conf  magic       mime.types  original
    bash-4.3# ls conf/extra/
    httpd-autoindex.conf           httpd-default.conf
    httpd-languages.conf           httpd-mpm.conf
    httpd-ssl.conf                 httpd-vhosts.conf
    httpd-dav.conf                 httpd-info.conf
    httpd-manual.conf              httpd-multilang-errordoc.conf
    httpd-userdir.conf             proxy-html.conf
    bash-4.3# 
    
  • 拷贝出httpd.conf文件:docker cp apache-main:/usr/local/apache2/conf/httpd.conf .

  • 对http文件做一些修改

    115c115
    < #LoadModule charset_lite_module modules/mod_charset_lite.so
    ---
    > LoadModule charset_lite_module modules/mod_charset_lite.so
    196, 197c196, 197
    < User daemon
    < Group daemon
    ---
    > User apache
    > Group apache
    218c218
    < ServerAdmin you@example.com
    ---
    > ServerAdmin user@domain.com
    227c227
    < #ServerName www.example.com:80
    ---
    > ServerName www.domain.com
    434, 435c434, 435
    <     #AddType text/html .shtml
    <     #AddOutputFilter INCLUDES .shtml
    ---
    >     AddType text/html .shtml
    >     AddOutputFilter INCLUDES .shtml
    501c501
    < #Include conf/extra/httpd-vhosts.conf
    ---
    > Include conf/extra/httpd-vhosts.conf
    528a529, 530
    > AddDefaultCharset UTF-8
    
  • 拷贝出httpd-vhosts.conf文件:`docker cp
  • apache-main:/usr/local/apache2/conf/extra/httpd-vhosts.conf .`

  • CTRL+c中断apache-main的运行

指定Volume运行

  • 从httpd.conf文件中可以看到DocumentRootusr/local/apache2/htdocs/, 挂载本地网站到相应目录。
  • 运行本地主网站 docker run --rm -dit --name apache-main -v /var/wwww/html/:/usr/local/apache2/htdocs/ httpd:2.4-alphine

###

Reference

CHENTONG
版权声明:本文为博主原创文章,转载请注明出处。
alipay.png WeChatPay.png

CHENTONG

CHENTONG
积微,月不胜日,时不胜月,岁不胜时。凡人好敖慢小事,大事至,然后兴之务之。如是,则常不胜夫敦比于小事者矣!何也?小事之至也数,其悬日也博,其为积也大。大事之至也希,其悬日也浅,其为积也小。故善日者王,善时者霸,补漏者危,大荒者亡!故,王者敬日,霸者敬时,仅存之国危而后戚之。亡国至亡而后知亡,至死而后知死,亡国之祸败,不可胜悔也。霸者之善著也,可以时托也。王者之功名,不可胜日志也。财物货宝以大为重,政教功名者反是,能积微者速成。诗曰:德如毛,民鲜能克举之。此之谓也。

生信宝典文章集锦

### 程序学习心得* [生物信息之程序学习](http://mp.weixin.qq.com/s?__biz=MzI5MTcwNjA4NQ==&mid=2247483927&idx=1&sn=23adf2b9d13400f2081f790e674e...… Continue reading

文章用图的修改和排版(2)

Published on September 18, 2017

R语言学习 - 非参数法生存分析

Published on September 17, 2017