tp5 + laradock build back-end summary of the problem applet from zero

A, laradock up the first time, build process is very slow

 Because the mirror pulling default container in a foreign country, so before docker-compose up container, locate the following text in the file .env

CHANGE_SOURCE=false

 Then false to true, and locate the following text

# UBUNTU_SOURCE = aliyun

 In front of the # removed, that is, remove the comment, the default image abroad into a domestic source of fast aliyun mirror source

 Then the workspace of the time zone, time zone changed to China, look for the following words

WORKSPACE_TIMEZONE=UTC

 UTC changed the PRC

 Then execute the command

docker-compose up -d nginx mariadb

 Need to start their choice of container

 Contrast personally build over time, under 20M bandwidth does not change, then mirroring the fast one hour slower then the day after the change, only 10min 

Two, laradock given during the starting container of build workspace

 If the relevant text "raw.githubusercontent.com" appears, the binding domain to the ip local hosts

 For example to linux

vim /etc/hosts

 Enter "199.232.28.133 raw.githubusercontent.com" to the file

Three, composer install slow

Installing laradock worksapce vessel in the warehouse from a third party managed tp5 taken git pulled down in the frame, composer install very slow, domestic sources need to be replaced, the following command to execute

composer config -g repo.packagist composer https://packagist.phpcomposer.com

 Four, composer ignore the version number installed

 composer install encountered Your requirements could not be resolved to an installable set of packages. error, you can ignore the version number installed, execute the following command

composer install --ignore-platform-reqs

 Five, composer install tp5 database migration tool

 tp5.0 migration tool is 1. *, tp5.1 is 2. * If the version number is specified, the default install the latest migration tool, execute the following command

composer require topthink/think-migration=1.*

 Six, laradock when connected, host name to fill tp5 configuration database container

 mariadb this container I use, so the following configuration

'host'=>'mariadb'

 Seven, tp5 full access to the runtime

chmod -r runtime 777

 Eight, tp5 catch exceptions thrown in mysql

 Exception the catch before the parameter plus a backslash, showing from the bottom to begin capturing Exception

catch(\Exception)

 When the Nine, do image upload interfaces, mkdir error no permission

 For ease of reference pictures, I picture storage directory designated as public / uploads, but the error can be resolved by giving the public full access

chmod -r public 777

 Ten, when the back-end interface to verify permissions

 A very good authorization mechanism, php oauth2 when there is a good library  https://github.com/thephpleague/oauth2-server , but very reluctantly, unlike laravel have passport, also supports Drupal, cakephp and other frameworks

 Use Json-web-token just fine  https://github.com/firebase/php-jwt

 XI, cross-domain processing

  Add file to execute when the application is initialized in tags.php in the application directory, for example, I put the cross-domain on applicationapi / behavior / CORS.php file, it sends a header in the application initialization

    // application initialization 
    'app_init' => [ 
        'App API \\ \\ \\ behavior CORS' 
    ],

 Cross-domain file

<?php
namespace app\api\behavior;
 
use think\Response;
 
class CORS
{
    public function appInit(&$params)
    {
        header('Access-Control-Allow-Origin: *');
        header("Access-Control-Allow-Headers: token,Origin, X-Requested-With, Content-Type, Accept");
        header("Access-Control-Allow-Methods:GET, POST");
        if (request()->isOptions()) {
            exit();
        }
    }
}

 Twelve, git push / pull need to authenticate, enter the user name and password multiple times

 linux environment, perform in the repository directory

git config --global credential.helper store

 Thirteen, git push stuck

 Set borderless contract, the exchange http request to set a large buffer

git config --global sendpack.sideband false
git config --global http.postBuffer 524288000

 Fourteen, nginx does not support the pathinfo tp5

 Change the project configuration file corresponding .conf

LOCATION / { 
         try_files $ $ URI URI / / the index.php is_args $ $ args; 
         # add some ↓↓↓↓↓ 
         IF (-! E $ request_filename) { 
                the rewrite ^ $ /index.php?s=$ (*.) . 1  Last ; 
                BREAK; 
         } 
         # add some ↑↑↑↑↑ 
}

 

 # 更改前 location ~ \.php$ {
 location ~ \.php { 
        try_files $uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        # 添加部分↓↓↓↓
        # Set var PATH_INFO
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        #  添加部分↑↑↑↑
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;   
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
}

Specific options until I find time to learn about

Remark

As we all know, from github clone has been relatively slow, you can choose to use cloud code, commonly used in advance to import warehouse to the cloud workspace own code, when you need to use code by cloning cloud

 

Guess you like

Origin www.cnblogs.com/YC-L/p/12535549.html