360 nginx+php,docker安装nginx+php环境

创建项目目录,并设置用户与用户组。(tp5为例)

016897f34360

image.png

创建nginx和php的dockerfile

nginx

FROM nginx

//设置docker里面nginx用户的用户id

RUN usermod -u 1001 nginx

php

FROM php:7.1.0-fpm

//设置docker里面www-data用户的用户id

RUN usermod -u 1001 www-data

RUN apt-get update

RUN apt-get install vim

构建镜像

docker build -t nginx:test .

启动容器

nginx(设置.bashrc的目的是进入docker里面可以使用ll查看文件权限)

docker run --name my-nginx -p 80:80 -d -v /home/www:/usr/share/nginx/html -v /home/nginx/conf/conf.d:/etc/nginx/conf.d -v /home/nginx/.bashrc:/root/.bashrc --link

my-php:php nginx:my

php

docker run --name my-php -v /home/www/tp5:/var/www/html -v /home/nginx/.bashrc:/root/.bashrc -p 9000:9000 -d php:my

nginx的配置文件

server {

listen 80;

server_name tp5.examlpe.com;

root /usr/share/nginx/html/tp5/public/;

set $root /usr/share/nginx/html/tp5/public/;

location ~ .*\.(mp4)$

{

client_body_buffer_size 2048m;

client_max_body_size 120m;

root $root;

}

location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$

{

root $root;

}

location / {

index index.php index.html index.htm;

if (!-e $request_filename) {

rewrite ^(.*)$ /index.php?s=/$1 last;

break;

}

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/share/nginx/html;

}

location ~ \.php$ {

root /var/www/html/public/;

fastcgi_pass php:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /var/www/html/public/$fastcgi_script_name;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param PHP_ADMIN_VALUE "open_basedir=/var/www/html/:/tmp/:/proc/";

include fastcgi_params;

}

}

.bashrc文件

# ~/.bashrc: executed by bash(1) for non-login shells.

# Note: PS1 and umask are already set in /etc/profile. You should not

# need this unless you want different defaults for root.

# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '

# umask 022

# You may uncomment the following lines if you want `ls' to be colorized:

# export LS_OPTIONS='--color=auto'

# eval "`dircolors`"

# alias ls='ls $LS_OPTIONS'

alias ll='ls $LS_OPTIONS -l'

# alias l='ls $LS_OPTIONS -lA'

#

# Some more alias to avoid making mistakes:

# alias rm='rm -i'

# alias cp='cp -i'

# alias mv='mv -i'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值