zoukankan      html  css  js  c++  java
  • docker 安装 php +nginx 记录

    我的环境CentOS 7.5

    首先安装 nginx

    docker pull nginx
    docker pull php:7.1.30-fpm

    安装完成之后进行配置,首先要确定网站目录、nginx配置文件目录

    mkdir /var/www
    mkdir /etc/conf
    cd /var/conf
    vim test.conf

    输入以下内容

    server {
        listen       80;
        server_name  localhost;
    
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm index.php;
        }
    
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    
        location ~ .php$ {
            fastcgi_pass   php:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /www/$fastcgi_script_name;
            include        fastcgi_params;
        }

    其中root   /usr/share/nginx/html 这个地方是指网站目录,要记住,挂载nginx目录时要用。fastcgi_param SCRIPT_FILENAME /www/$fastcgi_script_name; 这个目录也很重要,挂载PHP目录的时候会用

    启动php,挂载本地目录,注意,启动nginx也必须挂载这个目录:/var/www

    docker run --name  myphp7 -v /var/www:/www -d php:7.1.30-fpm
    docker run --name php-nginx -p 8800:80 -v /var/www:/usr/share/nginx/html -v /var/conf:/etc/nginx/conf.d -d --link myphp7:php nginx

    启后后新建一个PHP测试一下:

    cd /var/www
    vim info.php

    输入

    <?php
        phpinfo();
    ?>

    看看能否打开

    curl localhost:8000/info.php

    结果返回403 Forbidden

    因为是CentOS7,尝试关闭SeLinux

    vim /etc/selinux/config
    
    SELINUX=disabled

    保存重试,仍然返回403 Forbidden。尝试修改权限

    chmod -R 777 /var/www/

    OK!

  • 相关阅读:
    洛谷P1043数字游戏
    luogu P1330 封锁阳光大学
    luoguP1242 新汉诺塔
    luogu P1892 [BOI2003]团伙
    luogu P3375 【模板】KMP字符串匹配
    luoguP1440 求m区间内的最小值
    luoguP2700 逐个击破
    luoguP2814 家谱
    luogu P1962 斐波那契数列
    P3379 【模板】最近公共祖先(LCA)
  • 原文地址:https://www.cnblogs.com/yesok/p/12892826.html
Copyright © 2011-2022 走看看