dockerfile 内容
文件名:Dockerfile
FROM yansongwei/contos7.6
RUN yum -y install vim
RUN yum -y install wget
RUN yum -y install epel-release pcre-devel zlib-devel gcc
ADD nginx-1.25.1.tar.gz /usr/src
ADD php-7.3.32.tar.gz /usr/src
EXPOSE 80
RUN useradd -M -s /sbin/nologin nginx
WORKDIR /usr/src/nginx-1.125.1
RUN ./configure --prefix=/usr/local/nginx --user=nginx --with-http_stub_status_module && make && make install
ENV PATH /usr/local/nginx/sbin:$PATH
CMD ["nginx"]
运行dockerfile文件
docker build -t nginxcontos7:v1.0 .
启动nginx
#启动nginx
nginx
#重启nginx
nginx -s reload
#停止nginx
nginx -s stop
安装php依赖
yum -y install openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel pcre libxslt libxslt-devel bzip2 bzip2-devel libmcrypt-devel
编译安装php
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-pdo-mysql --with-mysqli --with-gd --with-zlib --with-mcrypt --enable-fpm
make && make install
配置php相关文件文章来源:https://www.toymoban.com/news/detail-555678.html
#配置php.ini
cp /usr/src/php-7.3.32/php.ini-development /usr/local/php/lib/php.ini
#配置php-fpm.conf
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
#将php-fpm启动文件复制到init.d文件夹中,方便启动php
cp /usr/local/php/sbin/php-fpm /etc/init.d/php-fpm
#复制www.conf.default 为 www.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.defalt /usr/local/php/etc/php-fpm.d/www.conf
启动Php文章来源地址https://www.toymoban.com/news/detail-555678.html
#启动php
/etc/init.d/php-fpm
#查看php扩展
php -m
#开机自动启动
chkconfig --add php-fpm
chkconfig --list php-fpm
chkconfig php-fpm on
#添加php与pecl软链接
ln -s /usr/local/php/bin/php /usr/bin/php
ln -s /usr/local/php/bin/pecl /usr/bin/pecl
到了这里,关于docker dockerfile部署contos7、nginx的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!