Browse Source

初次提交

main
xiaoz 4 years ago
parent
commit
f415114077
  1. 18
      php/Dockerfile
  2. 44
      php/install.sh
  3. 6
      php/run.sh

18
php/Dockerfile

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
FROM php:7.3-fpm
#设置时区
ENV TZ=Asia/Shanghai
#工作目录
WORKDIR /root
#复制安装脚本
COPY ./install.sh /root
#复制启动脚本
COPY ./run.sh /usr/sbin
#执行安装脚本
RUN bash install.sh
#暴露配置文件
VOLUME /usr/local/nginx/conf/vhost
VOLUME /var/www/html
EXPOSE 80
EXPOSE 443
#运行crontab和nginx
CMD ["/usr/sbin/run.sh"]

44
php/install.sh

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
#!/bin/bash
#update system
apt-get update
#install nginx
function install_nginx() {
cd /usr/local
#add user and group
groupadd www
useradd -M -g www www -s /sbin/nologin
#download nginx
wget http://soft.xiaoz.org/nginx/xcdn-binary-1.18-debian.tar.gz
tar -zxvf xcdn-binary-1.18-debian.tar.gz
rm -rf xcdn-binary-1.18-debian.tar.gz
#add env
echo "export PATH=$PATH:/usr/local/nginx/sbin" >> /etc/profile
export PATH=$PATH:'/usr/local/nginx/sbin'
#备份配置文件
cd /usr/local/nginx/conf
cp nginx.conf nginx.conf.bak
apt-get install -y wget
wget -P /usr/local/nginx/conf https://github.com/helloxz/dnmp/raw/main/php/nginx.conf
}
#setting php
function set_php() {
cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
#install gd ext
apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
#install xdebug and redis
pecl install redis-5.1.1 \
&& pecl install xdebug-2.8.1 \
&& docker-php-ext-enable redis xdebug
}
install_nginx && setting
echo '-----------------------------'
echo 'nginx + php install success.'
echo '-----------------------------'

6
php/run.sh

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
#!/bin/bash
#start nginx
/usr/local/nginx/sbin/nginx
echo 'start nginx success.'
#start php-fpm
/usr/local/sbin/php-fpm
Loading…
Cancel
Save