PHP development environment 03 – use kfkdock to build PHP project environment

Time:2020-11-26

Build web service quickly based on docker

According to the user-defined configuration file to quickly build the web environment.

catalog

What can this project do

  1. Build PHP development / production environment.
  2. Build node development / production environment.

GitHub address, video tutorial

GitHub address
Video tutorial

Software included

PHP / Nginx / MySQL / MongoDB / Redis / Memcached

Project directory structure

/kfkdock
    /Data database data (mysql, redis, Mongo)
    /Etc application configuration item
    /Logs various logs (mysql, nginx, PHP)
    /Vhost virtual host configuration
    /Www project catalogue
    /docker- compose.yml      Docker compose configuration file

Fast running kfkdock

Running PHP services

1. Install necessary tools

[[MAC] docker / docker compose / accelerator](https://github.com/kfkme/kfkd…
[[Linux Ubuntu] docker / docker compose / accelerator](https://github.com/kfkme/kfkd…

2. Download kfkdock source code to build container
#Enter user directory
cd ~/

#Download the source code
git clone https://github.com/kfkme/kfkdock.git

#Enter the directory
cd kfkdock

#Building containers
sudo docker-compose build

#Start container
sudo docker-compose up -d
3. Test PHP code
#Start container
cd ~/kfkdock
sudo docker-compose up

#Modify PHP file
vi ~/kfkdock/www/localhost/index.php

#Address bar access localhost
http://localhost

#Done!

Run the laravel project

4. Testing laravel project
#Edit local host file
vi /etc/host
#Join
127.0.0.1   laravel.cc

#Make a copy of project laravel
~/kfkdock/www/laravel

#Enter the php71 container
docker-compose exec php71 bash

#Loading composer dependencies
cd /var/www/laravel
composer install --no-plugins --no-scripts

#Exit the container and set the nginx configuration of the larevel project
vi ~/kfkdock/vhost/laravel.cc.conf
server {
    listen       80;
    server_name  laravel.cc;
    root   /var/www/laravel/public;
    index  index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass   php71:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

#Exit container
exit

#Restart container, apply configuration
docker-compose restart

#Visit test domain name
http://laravel.cc

#Success!

Run front end service

Database configuration
DB_CONNECTION=mysql
DB_HOST=mysql57
DB_PORT=3306
DB_DATABASE=shop
DB_USERNAME=root
DB_PASSWORD=kfkdock

Run front end service

Enter the front container
docker-compose exec node sh
other

Delete container image / configure Xdebug / docker- compose.yml Syntax explanation / dockerfile syntax explanation

QQ communication group

Group number: 259937756<img border=”0″https://pub.idqqimg.com/wpa/images/group.png&quot” rel=”nofollow noreferrer”>https://pub.idqqimg.com/wpa/i…;>

PHP development environment 03 - use kfkdock to build PHP project environment

reference resources

Recommended Today

Front end development of the convenience store cashier system code

1 + X front end primary JQ Community convenience store cashier system code <body> <input type=”text” value=”” disabled=”disabled” /> <form action=”” method=””> <span>4.5</span> <input type=”button” onclick=”addClick(4.5)” value=”+” /><br> <span>15</span> <input type=”button” onclick=”addClick(15)” value=”+” /><br> <span>5</span> <input type=”button” onclick=”addClick(5)” value=”+” /><br> </form> < input type = “button” name = “value =” check out “onclick =” sub() […]