飞嗨,欢迎您的光临,本博所发布之文章皆为作者亲测通过,如有错误,欢迎通过各种方式指正。(本博已于2015.12.6升级到php7,运行环境php7 php-fpm + nginx1.8.0)

最新lnmp docker容器(CentOS7,Nginx1.10.0,MySQL5.7,PHP7.0.2)

Linux lf 13774℃ 0评论

真是心累,前些天mac book pro进水了,现在拿出大学时用的lenovo idepad Y450老本本用,真是欲哭无泪!每当mysq编译到30%左右的时候就发烫自动关机了!就这,还是用的ubuntu系统…我的mac买了半年还没到,拿去apple零售店让我换一块主板4k多+一块电池3k多,共8k多的维修费,没舍得修!太贵了!老本本真是太难用了,mysql编译真的要很久很久很久都编译不完,哎!!!

ubuntu环境 && 安装docker

ubuntu 16.04

ubuntu 16.04

编写Dockerfile生成image

Dockerfile && docker build

Dockerfile && docker build

Dockerfile:

FROM centos:7
MAINTAINER liufee job@feehi.com
RUN yum -y install epel-release && yum -y update
RUN yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel curl curl-devel freetype freetype-devel libmcrypt libmcrypt-devel cmake gcc-c++ ncurses-devel perl-Data-Dumper autoconf wget libicu libicu-devel libmcrypt libmcrypt-devel vim

ADD /nginx-1.10.0 /downloads/nginx-1.10.0
WORKDIR /downloads/nginx-1.10.0
RUN ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/tmp/nginx/client/ --http-proxy-temp-path=/tmp/nginx/proxy/ --http-fastcgi-temp-path=/tmp/nginx/fcgi/ --with-pcre --with-http_dav_module 
RUN make && make install

ADD /php-7.0.6 /downloads/php-7.0.6
WORKDIR /downloads/php-7.0.6
RUN ./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-soap --enable-mbstring=all --enable-sockets --enable-fpm --with-gd --with-freetype-dir=/usr/include/freetype2/freetype --with-jpeg-dir=/usr/lib64 --with-zlib --with-iconv --enable-libxml --enable-xml --with-curl --with-mcrypt --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-intl
RUN make && make install

ADD /mysql-5.7.12 /downloads/mysql-5.7.12
WORKDIR /downloads/mysql-5.7.12
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=/downloads/mysql-5.7.12/boost
RUN make
RUN make install
RUN mkdir -p /data/mysql
RUN useradd mysql
RUN chown -R mysql /data/mysql
RUN /usr/local/mysql/bin/mysqld --initialize --initialize-insecure --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql


ADD /etc /etc
ADD /nginx /etc/init.d/nginx
RUN chmod +x /etc/init.d/nginx
RUN useradd nginx
RUN mkdir -p /tmp/nginx/client
RUN cp /downloads/php-7.0.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm && chmod +x /etc/init.d/php-fpm
RUN cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
RUN cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
RUN cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld && chmod +x /etc/init.d/mysqld

ADD /start.sh /start.sh
RUN chmod +x /start.sh
CMD ["/start.sh"]

运行docker build -t feehi/lnmp:v3 .  (不要省略.,代表Dockerfile所在目录,.代表当前目录

因为使用ADD远程文件的时候格外慢,我下载了最新版的nginx1.10.0 php-7.0.6 mysql-5.7到本地了,下载完后解压/解包放到与Dockerfile同级目录,mysql下载带boost的版本

docker

docker

然后就是等待过程,可怜我的老本本,总是编译mysql到30%多的时候发烫死机!!!

docker build finished

docker build finished

运行docker容器

feehi/lnmp:v3

feehi/lnmp:v3

docker run -t -i feehi/lnmp:v3 /bin/bash进入到交互模式

查看mysql php nginx版本

mysql5.7 php7 nginx1.10

mysql5.7 php7 nginx1.10

在运行容器的时候,已经暴露80端口给外部了,访问http://127.0.0.1/,最新版lnmp环境已经正常了

最新lnmp

最新lnmp

所需文件拷贝>>>http://github.com/liufee/docker

转载请注明:飞嗨 » 最新lnmp docker容器(CentOS7,Nginx1.10.0,MySQL5.7,PHP7.0.2)

喜欢 (9)or分享 (0)

Warning: Use of undefined constant PRC - assumed 'PRC' (this will throw an Error in a future version of PHP) in /www/wwwroot/feehi/blog.feehi.com/wp-content/themes/yusi1.0/comments.php on line 17
发表我的评论
取消评论

表情
(4)个小伙伴在吐槽
  1. 54456546
    匿名2018-09-11 13:12 回复
  2. 【在运行容器的时候,已经暴露80端口给外部了,访问http://127.0.0.1/,最新版lnmp环境已经正常了】请问你这里写的运行容器的时候是指的是运行centos这个镜像 还是指的是运行feehi/lnmp:v3 这个镜像。我运行feehi/lnmp:v3 外界并访问不了
    匿名2017-04-29 22:31 回复
  3. 年中快乐!
    5297284372016-06-17 08:55 回复
    • 一起快乐,哈哈
      lf2016-10-26 16:08 回复
粤ICP备15018643号-1