本文章参考连接:Docker 安装 PHP | 菜鸟教程

安装PHP

1、搜索并下载PHP镜像

搜索一个带-fpm的php镜像并下载

2、创建PHP容器

安装Nginx

1、下载Nginx镜像

2、创建Nginx容器

配置Nginx

1、配置default.conf

进入存有default.conf的目录

root@nginx:/# cd /etc/nginx/conf.d/
root@nginx:/etc/nginx/conf.d# ls
default.conf
root@nginx:/etc/nginx/conf.d#

备份原有配置

root@nginx:/etc/nginx/conf.d# cp default.conf default.conf.bak
root@nginx:/etc/nginx/conf.d#

查看原有配置

root@nginx:/etc/nginx/conf.d# cat default.conf
server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

#access_log  /var/log/nginx/host.access.log  main;

location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

# deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

root@nginx:/etc/nginx/conf.d#

将配置内容复制到本地并修改

将修改好的文件上传到本地址映射文件夹

root@nginx:/etc/nginx/conf.d# cd /usr/share/nginx/html
root@nginx:/usr/share/nginx/html# ls
default.conf  hosts  index.css  index.html  index.php

将 default.conf 文件复制到原来的位置

root@nginx:/usr/share/nginx/html# cp ./default.conf /etc/nginx/conf.d/
root@nginx:/usr/share/nginx/html# cd /etc/nginx/conf.d/
root@nginx:/etc/nginx/conf.d# ls
default.conf  default.conf.bak
root@nginx:/etc/nginx/conf.d# cat default.conf
server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

#access_log  /var/log/nginx/host.access.log  main;

location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           html;
        fastcgi_pass   192.168.8.3:9000;
        fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;
        include        fastcgi_params;
    }

# deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

root@nginx:/etc/nginx/conf.d#

2、配置hosts

找到对应目录

root@nginx:/etc/nginx/conf.d# cd /etc/     
root@nginx:/etc# ls
adduser.conf            ca-certificates.conf  deluser.conf  gai.conf  host.conf  issue.net      localtime    netconfig      pam.d      rc1.d  rcS.d        shadow-  systemd
alternatives            cron.d                dpkg          group     hostname   kernel         login.defs   nginx          passwd     rc2.d  resolv.conf  shells   terminfo
apt                     cron.daily            e2scrub.conf  group-    hosts      ld.so.cache    logrotate.d  nsswitch.conf  passwd-    rc3.d  rmt          skel     timezone
bash.bashrc             debconf.conf          environment   gshadow   init.d     ld.so.conf     mke2fs.conf  opt            profile    rc4.d  security     ssl      ucf.conf
bindresvport.blacklist  debian_version        fonts         gshadow-  inputrc    ld.so.conf.d   motd         os-release     profile.d  rc5.d  selinux      subgid   update-motd.d
ca-certificates         default               fstab         gss       issue      libaudit.conf  mtab         pam.conf       rc0.d      rc6.d  shadow       subuid   xattr.conf
root@nginx:/etc#

将hosts配置复制到本地进行修改

root@nginx:/etc# cat hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.8.2     nginx
root@nginx:/etc#

将修改的hosts复制到它容器中原来的位置

root@nginx:/etc# ls
adduser.conf            ca-certificates.conf  deluser.conf  gai.conf  host.conf  issue.net      localtime    netconfig      pam.d      rc1.d  rcS.d        shadow-  systemd
alternatives            cron.d                dpkg          group     hostname   kernel         login.defs   nginx          passwd     rc2.d  resolv.conf  shells   terminfo
apt                     cron.daily            e2scrub.conf  group-    hosts      ld.so.cache    logrotate.d  nsswitch.conf  passwd-    rc3.d  rmt          skel     timezone
bash.bashrc             debconf.conf          environment   gshadow   init.d     ld.so.conf     mke2fs.conf  opt            profile    rc4.d  security     ssl      ucf.conf
bindresvport.blacklist  debian_version        fonts         gshadow-  inputrc    ld.so.conf.d   motd         os-release     profile.d  rc5.d  selinux      subgid   update-motd.d
ca-certificates         default               fstab         gss       issue      libaudit.conf  mtab         pam.conf       rc0.d      rc6.d  shadow       subuid   xattr.conf
root@nginx:/etc# cp /usr/share/nginx/html/hosts ./
root@nginx:/etc# cat hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.8.3     php

root@nginx:/etc#

测试

创建php文件

放到本地挂载的目录中

得到

爱快docker安装PHP和Nginx相关推荐

  1. 爱快docker 安装wordpress 6.1.1教程

    首先高级应用-插件管理-镜像管理-添加 搜索wordpress 选择一个版本下载 下载完成 开始添加wordpress 这里挂载了两个目录: /upupbl/wordpress/uploads.ini ...

  2. 爱快docker安装青龙教程

    首先高级应用-插件管理-镜像管理-添加 搜索qinglong如下 点进入下载页 选择第一个latest 返回容器列表-添加 添加 在磁盘根目录下新建qinlong文件夹,下面再分别建db,log,co ...

  3. 爱快docker青龙面板保姆级

    爱快docker真要不会的可以看我上一篇文章 爱快>高级应用<插件管理<docker<接口管理 这样设置↓(和我不一样也可以但等下有的东西要和我的不太一样) 爱快>高级应 ...

  4. docker安装halo+mysql+nginx搭建个人博客

    docker 安装halo+mysql+nginx搭建个人博客(debian or ubuntu) 1 简介 本文主要介绍debian和国内腾讯云ubuntu下安装docker,使用docker安装h ...

  5. 甜糖官方爱快docker

    一:安装docker首先进入爱快云平台 https://yun.ikuai8.com/ 登录上找到(插件应用) 点击未开启设备>已开启 然后来到爱快(高级应用>插件管理>docker ...

  6. 爱快 Docker NodeRed Tcp服务器远程连接试验

    有一台基于4415软路由安装的ubuntu server系统,在Ubuntu上通过Docker安装了NodeRed.ubuntu通过爱快硬路由与外网连接.爱快硬路由通过动态域名和端口映射实现远程访问u ...

  7. 爱快虚拟机安装Windows

    1.安装64位的爱快. 2.创建普通分区. (1).登录爱快,系统设置→磁盘管理→磁盘分区→快速分区 (2).分区,最少分2个分区,第一个逻辑分区是爱快系统日志,分2GB就可以.其他根据需求. (3) ...

  8. 爱快路由安装mysql_ESXi安装爱快iKuai OS路由(图文教程)

    对于爱快软路由iKuai OS来说,免费的版本提供ISO.IMG和GHO,32位和64位版本,可谓说很全了,也就是说安装爱快简单的不能再简单了,ESXi是打造All In One的必备神器之一,在ES ...

  9. 一种刷下行流量的方式 [爱快 docker版]

    参考:https://www.developer024.com/98.html 各位正在做PCDN的朋友可能带宽流量总是上行大于下行,这种情况极为容易进运营商的风控模型. 至于到底有没有效果,还得看各 ...

最新文章

  1. 索引文件核心头文件定义
  2. linux的mysql修改用户密码与忘记密码的方法
  3. pythonunittest接口测试_基于python+unittest +requests接口测试
  4. 【Java注解】自定义注解、与数据库结合使用
  5. php行内块,块级元素和行内块元素是什么?
  6. JQuery上传插件Uploadify使用详解
  7. 拥抱.NET 5,从自研微服务框架开始
  8. Python中字符串格式化:%和format
  9. iframe父页面与子页面之间的元素获取与方法调用
  10. Redhat或者Centos 手动安装sublime text 3
  11. Vue-CLI and Leaflet (9): 点聚合 Leaflet.markercluster
  12. 德鲁伊 oltp oltp_深入研究内存中OLTP表的哈希索引
  13. 阶段3 1.Mybatis_01.Mybatis课程介绍及环境搭建_01.mybatis课程介绍
  14. 接口交互时的URL带有日期格式的参数,注意拼装地址中的特殊符号(如空格等)
  15. 遥感学习笔记(四)——遥感数据分类
  16. SPSS 探索性因素分析与验证性因素分析的区别【SPSS 034期】
  17. 前台可以用if elseif吗_划重点美容仪的介质用完了,可以用自己的精华吗?
  18. c语言和Python整除符号,互联网常识:python除法运算符有哪些
  19. 【工作感悟】路自在前,冷暖自知
  20. 【Torch API】pytorch 中torch.ones_like和torch.zeros_like函数详解

热门文章

  1. html转为ipynb,jupyter .ipynb转.py的实现操作
  2. php微信小程序毕业设计 php家政服务预约小程序毕业设计开题报告功能参考
  3. 设计模式之抽象工程模式
  4. rtx4060ti参数 rtx4060ti功耗 rtx4060相当于什么水平
  5. 一年中最后一个月的最后一天说说_一年最后一个月的句子
  6. python3.6 m venv py3_python 3.6 的 venv 模块
  7. AE制作Json动画教程
  8. 如何看待华为鸿蒙的任务流转功能?
  9. mysql各种索引名称_MySQL索引类型大汇总
  10. 木瓜移动跨境电商SaaS 聚焦核心用户的核心需求场景