Home > PHP Framework > Laravel > Detailed explanation of docker installation of Laravel environment [nginx mariadb PHP7.4]

Detailed explanation of docker installation of Laravel environment [nginx mariadb PHP7.4]

藏色散人
Release: 2021-05-12 09:04:20
forward
2196 people have browsed it

下面由laravel教程栏目给大家介绍docker 安装 Laravel 环境 (nginx mariadb PHP7.4)--centos7.3,希望对需要的朋友有所帮助!

1,安装mariadb

创建网路

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

查看

mysql -h127.0.0.1 -uroot -proot
Copy after login

2,安装nginx-php7.4

安装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
Copy after login
进入docker 里面安装php7.4
    yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

    yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
    yum -y install yum-utils
    yum-config-manager --enable remi-php74
    yum update
    yum install php php-cli
    yum install php-fpm php-cli php-bcmath php-gd php-json php-mbstring php-mcrypt php-mysqlnd php-opcache php-pdo php-pecl-crypto php-pecl-mcrypt php-pecl-geoip php-recode php-snmp php-soap php-xmll php-php-dom php-zip php-process php-redis 
    systemctl start php-fpm
Copy after login
安装composer
    php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"
    mv composer.phar /usr/local/bin/composer
Copy after login
安装nginx
    yum install nginx -y
    systemctl start nginx
Copy after login

测试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;  
    }
    }
Copy after login

4,测试

创建 index.php
    phpinfo();
Copy after login
相关推荐:最新的五个Laravel视频教程

The above is the detailed content of Detailed explanation of docker installation of Laravel environment [nginx mariadb PHP7.4]. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template