Reference: https://framework.zend.com/bl… Reference: https://laravel.com/docs/5.5/…

Step 1: Download and install the software

Software 1: VirtualBox5.2(122M)

Download date: 2018-08-22, optional version: 5.2.8


Download Address:
https://www.virtualbox.org/wi…, I downloaded 5.2.8[109M]


5.1 Download Address:
https://www.virtualbox.org/wi…Click Windows Hosts x86/AMD64 to download
http://download.virtualbox.or…

Install at: D: Program Files\Oracle\VirtualBox

2: software Vagrant

Download date 2018=08-22, install version 2.1.2, size 221M


Download Address:
https://www.vagrantup.com/dow…Click Download Windows Bit64 to download
https://releases.hashicorp.co…

Install at: D: Program Files\ Hashicorp \Vagrant

Software 3: Git and SVN

Website https://git-for-windows.githu… Download (science only online) https://github.com/git-for-wi… TortoiseSVN D:\Program Files\TortoiseSVN\ Bin \ Tortoiseplink.exe

Software 4: Homestead

The address of the project: https://github.com/laravel/ho…

PS E:\www> git clone https://github.com/laravel/homestead.git Cloning into 'homestead'... remote: Counting objects: 3041, done. remote: Compressing objects: 100% (22/22), done. remote: Total 3041 (delta 17), reused 28 (delta 15), pack-reused 3002 Receiving objects: 100% (3041/3041) and 632.38 KiB | 242.00 KiB/s, done. Resolving deltas: 100% (1803/1803), and done.

Software 5: Boxes

Reference:
https://laravel.com/docs/5.6/…


Search box
https://app.vagrantup.com/box…I found the box Laravel/Homestead 6.3.0, but did not see the download address, how to download? , using the box install command
vagrant box add laravel/homestead, you will see the box address, such as


https://atlas.hashicorp.com/l…


Use Thunderbolt to download it. The file name is 5b64bd3b-eb87-4af4-9b2d-1c1560efca67. It’s weird. Whatever it is, rename it to 04_homesteadbox

Method 1: On-line installation (speed snail, not feasible)

PS E:\www> vagrant box add laravel/homestead ==> box: Loading metadata for box 'laravel/homestead' box: URL: https://vagrantcloud.com/laravel/homestead This box can work with multiple providers! The providers that it can work with are listed below. Please review the list and choose the provider you will be working  with. 1) hyperv 2) parallels 3) virtualbox 4) vmware_desktop Enter your choice: 3 ==> box: Adding Box 'Laravel/Homestead' (V6.3.0) for Provider: VirtualBox Box: M.E. : https://vagrantcloud.com/laravel/boxes/homestead/versions/6.3.0/providers/virtualbox.box box: Progress: 0% (Rate: 126K /s, Estimated time remaining: 4:33:51)4 // If it is slow and cannot be installed online, please use Thunder to download the link above

Method 2: Command line for offline installation (unsuccessful)

The installation command for the box is Vagrant Box Add-H

PS E:\ WWW > Vagrant Box Add VirtualBox20180822, VirtualBox20180822 // VirtualBox20180822 is Name // VirtualBox20180822 is Path ==> box: Box file was not detected as metadata. Adding it directly... ==> box: Adding box 'virtualbox20180822' (v0) for provider: box: Unpacking necessary files from: file://E:/www/virtualbox.box box: Progress: 100% (Rate: 15.2 M/s, Estimated time remaining: - : - : -) = = > the box: Successfully added box 'virtualbox20180822' (v0) for 'virtualbox'! PS E:\ WWW > Vagrant Box List VirtualBox20180822 (VirtualBox, 0) // There is a problem with displaying installed boxes, the box version is 0, and Homestead has a requirement for the box version, So you have to specify the version number when you install it, PS E:\ WWW > Vagrant Box Remove VirtualBox20180822 Removing Box 'VirtualBox20180822' (v0) with provider 'virtualbox'...

Method 3: Install with a configuration file JSON file (successful)

reference
http://bbs.csdn.net/topics/39…

Knowledge point 1: Vagrant manages the virtual machine by first reading Vagrant’s configuration file, Vagrantfile, Where did it go to read the file, website is https://www.vagrantup.com/docs/vagrantfile/#lookup-path, it has something to do with your current working directory, If the current directory is C:\Users\Administrator>, then look for the Vagrantfile under C:\Users\Administrator>. In fact, the Vagrantfile is already written in the Homestead project. So it’s best if the current directory is Homestead. Once Homestead is installed in the previous step, change the current working directory to E:\ WWW \ Homestead \

  1. Copy the downloaded box to it"E:\www\homestead\boxes\virtualbox20180826.box"Next (I renamed the box)
  2. New original data (metadata) file E: \ WWW \ favored / 0000 json (name), refer to https://www.vagrantup.com/docs/boxes/format.html#box-metadata

    {" name ":" laravel/favored ", "versions" : [{" version ":" 6.3.0 ", "will" : [{" name ":" virtualbox ", "url" : "file://E:/www/homestead/boxes/virtualbox20180826.box" }] }] }
  3. The new Homestead configuration file, Homestead.yaml, is double-clicked to executeE:\www\homestead\init.bat
  4. Generate a private secret key

    PS D:\Program Files\Git\usr\bin> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (C:\Users\daqi/.ssh/id_rsa): Created directory 'C:\Users\daqi/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in C:\Users\daqi/.ssh/id_rsa. Your public key has been saved in C:\Users\daqi/.ssh/id_rsa.pub. The key fingerprint is: SHA256:4wIBwmk+PF+ZMeU9SqoD6GpCaa2ZiXmxtGy0u6dL1IE daqi@maibenben The key's randomart image is: +---[RSA 2048]----+ |o o .. | | = o o. . | |+ E o =o o | |.= . *o . . | |.. B +. .S | |.==o.. . . | |+**B . . | |=BB o . | |+o=* | +----[SHA256]-----+ PS D:\Program Files\Git\usr\bin>
  5. Installation box

    PS E:\www\homestead> vagrant box add 0000.json ==> box: Loading metadata for box '0000.json' box: URL: file://E:/www/homestead/0000.json = = > box: Adding box 'laravel/favored (v6.3.0) for the provider: virtualbox box: Unpacking necessary files from: file://E:/www/homestead/boxes/virtualbox20180826.box box: Progress: 100% (Rate: 24.2 M/s, Estimated time remaining: - : - : -) = = > the box: Successfully added Box 'Laravel/Homestead' (V6.3.0) for 'VirtualBox '!

Question 1: Where is Box installed? Answer: “C: \ Users \ daqi \. Vagrant. D/boxes/laravel VAGRANTSLASH – favored \ 6.3.0 \ virtualbox \ ubuntu 18.04 – amd64 – disk001 VMDK”

Step 2: Virtual host configuration

Reference: https://www.cnblogs.com/ajian… Refer to the source code E:\ WWW \Homestead \scripts\ Homestead.rb for specific configuration, analyze the source code to know what options should be written in E:\ WWW \Homestead \Homestead.yaml

project content explain
provider VirtualBox or VMware_Fusion or VMware_Workstation or HyperV or Parallels The default is virtualbox
name — — — The default is favored to 7
box — — — The default is laravel/favored
version — — — Default is >= 6.3.0
hostname — — — The default is favored
ip Autonetwork or specified IP, can also be blank Private IP address, default is 192.168.10.10
networks — — — Is an array with each item including configuration type, IP,bridge,netmask
default_ssh_port — — — SSH port
ports — — — port
default_ports — — — Port mapping, default 80 => 8000,443 => 44300,3306 => 33060,4040 => 4040, 5432 => 54320,8025 => 8025,7017 => 27017
authorize — — — certification
keys — — — — — —
copy — — — Copy the file to the virtual host
folders — — — Set up Shared Folder
sites — — — The default site type is laravel, but can also be zf, symfony, apigility, expressive, zray
variables — — — The global variable
databases — — — The database
schedule — — — — — —
-- IP: "192.168.10.10" Memory: 2048 Cpus: 1 Provider: VirtualBox Authorize: ~/.ssh/id_rsa.pub keys: Authorize: ~/. - ~/.ssh/id_rsa folders: - map: ~/code to: /home/vagrant/code - map: E:/www/wangqianjin/jihuizhenghao to: /var/www/jihuizhenghao sites: - map: homestead.test to: /home/vagrant/code/public - map: store.jihuizhenghao.com type: Magento # Different types call different serves. Type.sh, default is laravel PHP: * Shell provisioner 'args' must be a string or array. To: /var/www/jihuizhenghao/store databases: - jihuizhenghao

Modify the C: \ Windows \ System32 \ drivers \ etc \ hosts

192.168.10.10  store.jihuizhenghao.com
192.168.10.10  api.jihuizhenghao.com

Step 3: Priming

PS E:\ WWW \ Homestead > Vagrant Up PS E:\ WWW \ Homestead > Vagrant provision // Execute after modification of configuration file

Step 4: SSH connect and add root

Remote login

Use software such as PuTTY or Xshell to remotely connect the virtual machine host: 192.168.10.10, port :22, user name: Vagrant, password: Vagrant

Enable root user

Ubuntu is not root logged in by default

wang@bogon:~$sudo passwd // Enter the new UNIX password: // Enter the root password here to use welcome2018 Retype new UNIX password: Passwd: password updated successfully wang@bogon:~$su // Passwd: password updated successfully wang@bogon:~$su // to root password: :/home/ubuntu# //# indicates the root user $

Step 5: Customize

// ======== View PHP version: :~$php-v PHP + 1.2.9-1 +ubuntu18.04.1+ 1 (CLI) (Built: AUG 19 2018 07:16:54) (NTS) Copyright (C) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend Opcache V7.2.9-1 +ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1998-2018 Zend Technologies with Zend Opcache V7.2.9-1 +ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies with Blackfire v1.22.0~ Linux-x64-NON_ZTS72, https://blackfire.io, Copyright (c) 1999-2018, by Zend Technologies with Blackfire v1.22.0~ Linux-x64-NON_ZTS72, https://blackfire.io, By Blackfire // ======== mysql :~$mysql --version MySQL Ver 14.14distrib 5.7.23, ~$nginx-v nginx version: nginx/1.15.0. For Linux (x86_64) using EditLine wrapper // ========

Install php7.0

// Magento 2.0 does not support 7.1 and 7.2, so you need to install PHP 5.6,7.0,7.1,7.2,7.3. For details, see /usr/lib/ PHP

vagrant@homestead:~$ sudo update-alternatives --config php There are 5 choices for the alternative php (providing /usr/bin/php). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/php7.3 73 Manual Mode 1 /usr/bin/php5.6 56 Manual Mode 2 /usr/bin/php7.0 70 Manual Mode 3 /usr/bin/php7.1 71 /usr/bin/php7.3 73 Manual Mode Press <enter> to /usr/bin/php7.3 73 Manual Mode Press <enter> to /usr/bin/php7.3 keep the current choice[*], or type selection number: 2 update-alternatives: Using /usr/bin/php7.0 to provide /usr/bin/php (PHP) in manual mode vagrant@homestead:~$php-v PHP 7.0.31-1+ubuntu18.04.1+deb.sury.org + 1 (cli) (built: Jul 25 2018 10:01:10) (NTS) Copyright (C) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend Opcache v7.0.31-1+ubuntu18.04.1+ sury.org+1, Copyright (c) 1998-2017 Zend Technologies with Zend Opcache v7.0.31-1+ubuntu18.04.1+ sury.org+1, Copyright (c) 1999-2017, by Zend Technologies with Blackfire v1.22.0~ Linux-x64-NON_ZTS70, https://blackfire.io, Copyright (c) 1999-2017, by Zend Technologies with Blackfire v1.22.0~ Linux-x64-NON_ZTS70, https://blackfire.io, by Blackfire

Keep in mind that different websites can set up their own versions of PHP, as specified in Homestead.yaml

Step 6: Web server configuration (focus)

01: Configuration in homestead.yaml

Sites: -map: store.jihuizhenghao.com type: magento # Different types call different serve. Type.sh, default is laravel PHP: * Shell provisioner 'args' must be a string or array. To: /var/www/jihuizhenghao/store

02: Website profile

//E:\www\wangqianjin\jihuizhenghao\store\nginx.conf.jihuizhenghao # File E:\ WWW \wangqianjin\jihuizhenghao\store\nginx.conf. Jihuizhenghao ## root $MAGE_ROOT; index index.php; autoindex off; charset UTF-8; error_page 404 403 = /errors/404.php; #add_header "X-UA-Compatible" "IE=Edge"; # # # the location use the location [= | | | ~ ~ * ^ ~] / uri / {... # #} = beginning said exactly match ^ ~ said uri begin with a conventional string in the beginning, understand to match the url path. Nginx does not encode URLs, so the request is /static/20%/aa, which can be matched by the rule ^~ /static/ /aa (note the space). # ~ Begin means case-insensitive regular matching # ~* Begin means case-insensitive regular matching #! ~ and! ~* is a regular # / generic match for case insensitive and case insensitive cases, respectively. Any request will be matched. location = ^/del.php$ { rewrite del.php$ /0000.php last; Setup (with/or without /),location (with/or without /),location (with/or without /),location (with/or without /),location (with/or without /),location (with/or without /),location (with/or without /),location (with/or without /) The second parameter is a regular or normal string location ~ * ^ / setup ($| /) {$MAGE_ROOT root; location ~ ^/setup/index.php { fastcgi_pass fastcgi_backend; fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600"; fastcgi_read_timeout 600s; fastcgi_connect_timeout 600s; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ ^/setup/(? ! pub/). { deny all; } location ~ ^/setup/pub/ { add_header X-Frame-Options "SAMEORIGIN"; PHP}} # update application entrance location ~ * ^ / update ($| /) {$MAGE_ROOT root; location ~ ^/update/index.php { fastcgi_split_path_info ^(/update/index.php)(/.+)$; fastcgi_pass fastcgi_backend; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; } # Deny everything but index.php location ~ ^/update/(? ! pub/). { deny all; } location ~ ^/update/pub/ { add_header X-Frame-Options "SAMEORIGIN"; } } location / { try_files $uri $uri/ /index.php$is_args$args; } location /pub/ { location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) { deny all; } alias $MAGE_ROOT/pub/; add_header X-Frame-Options "SAMEORIGIN"; } location /static/ { # Uncomment the following line in production mode # expires max; # Remove signature of the static files that is used to overcome the browser cache location ~ ^/static/version { rewrite ^/static/(version[^/]+/)? (.*)$ /static/$2 last; } location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { add_header Cache-Control "public"; add_header X-Frame-Options "SAMEORIGIN"; expires +1y; if (! -f $request_filename) { rewrite ^/static/? (.*)$ /static.php? resource=$1 last; } } location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { add_header Cache-Control "no-store"; add_header X-Frame-Options "SAMEORIGIN"; expires off; if (! -f $request_filename) { rewrite ^/static/? (.*)$ /static.php? resource=$1 last; } } if (! -f $request_filename) { rewrite ^/static/? (.*)$ /static.php? resource=$1 last; } add_header X-Frame-Options "SAMEORIGIN"; } location /media/ { try_files $uri $uri/ /get.php$is_args$args; location ~ ^/media/theme_customization/.*\.xml { deny all; } location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { add_header Cache-Control "public"; add_header X-Frame-Options "SAMEORIGIN"; expires +1y; try_files $uri $uri/ /get.php$is_args$args; } location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { add_header Cache-Control "no-store"; add_header X-Frame-Options "SAMEORIGIN"; expires off; try_files $uri $uri/ /get.php$is_args$args; } add_header X-Frame-Options "SAMEORIGIN"; } location /media/customer/ { deny all; } location /media/downloadable/ { deny all; } location /media/import/ { deny all; } # PHP entry point for main application location ~ (index|get|static|report|404|503|health_check)\.php$ { try_files $uri =404; fastcgi_pass fastcgi_backend; fastcgi_buffers 1024 4k; fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000"; fastcgi_read_timeout 600s; fastcgi_connect_timeout 600s; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } gzip on; gzip_disable "msie6"; gzip_comp_level 6; gzip_min_length 1100; gzip_buffers 16 8k; gzip_proxied any; gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/xml+rss image/svg+xml; gzip_vary on; # Banned locations (only reached if the earlier PHP entry point regexes don't match) location ~* (\.php$|\.htaccess$|\.git) { deny all; }

03: Web server configuration file script (automatically generate configuration files)

// E:\www\homestead\scripts\serve-magento.sh #! /usr/bin/env bash # Settings for Web servers configured with Magento # # Set the type to Magento # in Homestead.yaml Please write the current site configuration file/var/WWW/jihuizhenghao storenginx. Conf. Jihuizhenghao echo "parameters: $* # favored - 7: Parameters: HTTP: / / store.jihuizhenghao.com/var/WWW/jihuizhenghao/store 80 443 7.2 false echo "parameter number $# # favored - 7: "Upstream connection:" Upstream connection: "Upstream connection:" Upstream connection: "Upstream connection:" Upstream connection: "Upstream connection:" Upstream connection: "Upstream connection:" /var/run/php5-fpm.sock; /var/run/php5-fpm.sock; server unix:/var/run/php/php$5-fpm.sock; } server { listen ${3:-80}; listen ${4:-443} ssl http2; server_name $1; set \$MAGE_ROOT $2; access_log off; error_log /var/log/nginx/$1-error.log error; include $2/nginx.conf.jihuizhenghao; } " echo "$block" > "/etc/nginx/sites-available/$1" ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"

If an error

FastCGI sent in stderr: "Access to the script '/var/www/jihuizhenghao/store/setup/index.php/navigation/header-bar' has been denied (see security.limit_extensions)" 

Change cgi.fix_pathinfo=1 in /etc/php.7.0/fpm /php.ini

Note: Using Homestead to manage a PHP development environment is really a good choice, given the variety of PHP environments you can build