docker 安装 Laravel 环境 (nginx mariadb PHP7.3)

1,安装mariadb

创建网路

    docker network create --subnet=172.18.0.0/16 mynetwork
    docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root --net mynetwork --ip 172.18.0.2 --name mariadb mariadb:latest

查看

mysql -h127.0.0.1 -uroot -proot

2,安装nginx-php7.3

安装centos
    docker run -itd  --privileged --net mynetwork --ip 172.18.0.3 -v /Users/vckin/Desktop/vckin/app/code:/var/www -v /Users/vckin/Desktop/vckin/nginx:/etc/nginx/conf.d -p 80:80 -p 443:443 --name nginx-php73 centos:latest /usr/sbin/init
进入docker 里面安装php7.3
    yum install epel-release -y
    yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    yum install yum-utils -y
    yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll php73-php-dom php73-php-zip php73-php-process php73-php-redis
    systemctl start php73-php-fpm
安装composer
    php73 -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
    php73 composer-setup.php
    php73 -r "unlink('composer-setup.php');"
    ln -s /usr/bin/php73 /usr/local/bin/php
    mv composer.phar /usr/local/bin/composer
安装nginx
    yum install nginx -y
    systemctl start nginx

测试nginx 创建/Users/vckin/Desktop/vckin/nginx/test.conf

server {
        #侦听80端口
        listen       80;
        index index.php index.html index.htm;
        #设定本虚拟主机的访问日志
        server_name  localhost;
        root /var/www/public;
        #rewrite_log on;
        #access_log  logs/hc-admin.access.log  main;
        #error_log  logs/hc-admin.access.log  main;
    location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css|ttf|woff|woff2)$
    {
        root /var/www/public;
    }
    location / {  
        index  index.htm index.html index.php;  

        if (!-e $request_filename) {  
           rewrite  ^/(.*)$  /index.php/$1  last;  
           break;  
        }  
    }  
    location ~ \.php/?.*$ {  
        root        /var/www/public;  
        #此处为docker Gateway ip
        fastcgi_pass   127.0.0.1:9000;  
        fastcgi_index  index.php;  
        #加载Nginx默认"服务器环境变量"配置  
        #include        fastcgi.conf;  
        include fastcgi_params; 

        set $fastcgi_script_name2 $fastcgi_script_name;  
        if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {  
            set $fastcgi_script_name2 $1;  
            set $path_info $2;  
        }  
        fastcgi_param   PATH_INFO $path_info;  
        fastcgi_param   SCRIPT_FILENAME   $document_root$fastcgi_script_name2;  
        fastcgi_param   SCRIPT_NAME   $fastcgi_script_name2;  
    }
    } 

4,测试

创建 index.php
    phpinfo();
Vckin
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
讨论数量: 2

分享下我编排的简单 docker-compose 配置,一起探讨~

自认为很精简,很容易理解、方便使用

5天前 评论

测试 nginx 创建 test.conf这是在容器里编辑吗?我看root是 /var/www/public

4天前 评论
Vckin (楼主) 4天前

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!