Detailed tutorial on how to use docker to build a laravel development environment in win10 home version

Detailed tutorial on how to use docker to build a laravel development environment in win10 home version

operating system:

Win10 Home Edition

Install Docker:

The docker downloaded from the official website cannot be installed successfully, prompting an operating system version problem~~~~

So I directly downloaded the docker installation package provided by Alibaba:

http://mirrors.aliyun.com/doc ...

The community version has the suffix -ce

Alibaba Image Acceleration

First, log in to Alibaba Cloud to search for container image services.

Win10 finds a config.json file under C:Users.dockermachinemachinesdefault, adds the accelerator address in the property RegistryMirror, and restarts the docker virtual machine.

Docker toolbox file mounting mechanism

I have read many articles and many of them directly mount the data under the C drive into the container using -v /c/data:/data. Maybe because I am using docker toolbox, I should share the file on the virtual machine first when mounting, and restart the virtual machine after sharing.

docker-matchine restart default

Enter the virtual machine background docker-matchine ssh default and you can see

At this time, -v /workspace:/workspace is used to mount docker

Custom laravel development image based on ubuntu image installation

docker pull ubuntu

Start the ubuntu container

docker run -itd --name test -p 8080:80 ubuntu

Enter the Ubuntu container to install the required content

apt-get update
apt-get install nginx
apt-get install php
apt-get install php7.4-fpm php7.4-mysql php7.4-gd php7.4-mbstring
apt-get install mysql-server
apt-get install composer
apt-get install net-tools
apt-get install vim
apt-get install node

Enable nginx

service nginx start

Access port 8080 of the docker enabled IP

Create a test project

Configure nginx file

server {
 listen 80;
 listen [::]:80;

 server_name example.com;

 root /workspace/test;
 index index.php index.html;
 
 location ~ \.php$ {
 root /workspace/test;
 index index.php index.html;
 fastcgi_index index.php;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
 include /etc/nginx/fastcgi_params;
 }
}

Restart nginx

service nginx restart

Enable php-fpm

service php7.4-fpm start

Find the /etc/php/7.4/fpm/pool.d/www.conf file and open the php-fpm listening port

listen = /run/php/php7.4-fpm.sock
Modify to listen = 127.0.0.1:9000

Restart php7.4-fpm service

Configure MySQL database

Allow remote users to connect, find the /etc/mysql/mysql.conf.d/mysqld.cnf file, and comment out the following:

bind-address = 127.0.0.1

Enter the user interface to modify root user information

use mysql;
update user set host='%' where user='root';
ALTER USER 'root'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;

Restart mysql service

Save the configured container separately as a laravel image

docker commit -m="laravel development environment" -a="author" e218edb10161 laravel:v1

Export the configured container

docker export 1e560fca3906 > laravel.tar

Complete startup laravel container

docker run -itd --name laravel -p 8080:80 -p 3306:3306 -v /workspace:/workspace -v /workspace/docker-conf/nginx-conf:/etc/nginx/sites-enabled laravel:v1

workspace is the directory of all projects

nginx-conf is a default configuration file in the nginx configuration directory, which is used to override the container's nginx configuration file

Summarize

This is the end of this article about the tutorial on how to use docker to build a laravel development environment under Windows 10 Home Edition. For more information about how to use docker to build a laravel development environment, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Complete steps to build a Laravel development environment using Docker
  • Detailed explanation of using Docker to build a development environment for Laravel and Vue projects
  • Detailed explanation of how to install the laravel development environment with docker

<<:  Analysis of common basic operations of MySQL database [create, view, modify and delete database]

>>:  Basic operations of MySQL data tables: table structure operations, field operation example analysis

Recommend

Optimize MySQL with 3 simple tweaks

I don't expect to be an expert DBA, but when ...

Detailed explanation of MySQL alter ignore syntax

When I was at work today, the business side asked...

5 ways to achieve the diagonal header effect in the table

Everyone must be familiar with table. We often en...

How much data can be stored in a MySQL table?

Programmers must deal with MySQL a lot, and it ca...

In-depth explanation of special permissions SUID, SGID and SBIT in Linux

Preface For the permissions of files or directori...

HTML head tag detailed introduction

There are many tags and elements in the HTML head ...

Detailed explanation of JavaScript function introduction

Table of contents Function Introduction function ...

Linux type version memory disk query command introduction

1. First, let’s have a general introduction to th...

A Brief Analysis on the Time Carrying Problem of MySQL

The default time type (datetime and timestamp) in...

Xftp download and installation tutorial (graphic tutorial)

If you want to transfer files between Windows and...

Use pictures to realize personalized underline of hyperlinks

Don't be surprised if you see some kind of und...

Detailed explanation of Apache website service configuration based on Linux

As an open source software, Apache is one of the ...

What you need to know about MySQL auto-increment ID

Introduction: When using MySQL to create a table,...