【vmwarevm】Ubuntu+Homestead+Laravel
==========
Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-54-generic x86_64)
* Homestead v9.0.0 released
* Settler v8.0.0 released
==========
$ cd~
$ cd?.composer/
$ ls
auth.json? cache? composer.json? composer.lock? config.json? vendor
$ cd vendor/
$ ls
autoload.php? bin? composer? doctrine? guzzlehttp? hirak? illuminate? laravel? nategood? nesbot? psr? ralouphie? symfony
$ composer update
==========
$ git --version
git version 2.17.1
$?composer --version
Composer version 1.8.6 2019-06-11 15:03:05
查看`composer`當(dāng)前使用倉(cāng)庫(kù)源
composer config -g repo
修改`composer`默認(rèn)倉(cāng)庫(kù)為使用`
composer config -g repositories.packagist composer http://packagist.phpcomposer.com
$ vi /home/vagrant/.composer/config.json?
{
? ? "config": {"secure-http": false},
? ? "repositories": {
? ? ? ? "packagist": {
? ? ? ? ? ? "type": "composer",
? ? ? ? ? ? "url": "http://packagist.phpcomposer.com"
? ? ? ? }
? ? }
}
==========
$ cd~
git clone https://github.com/laravel/homestead.git Homestead
$ cd Homestead/
$?git checkout v6.1.0
$ bash init.sh
Homestead initialized!
配置 Homestead
$ sudo vi Homestead.yaml
配置提供器
Homestead.yaml?中的?provider?參數(shù)設(shè)置決定了你用的是哪一個(gè) Vagrant 提供器:virtualbox、vmware_fusion贾漏、vmware_workstation?或者?parallels。你可以根據(jù)自己的喜好來(lái)設(shè)置提供器:
provider:vmware_fusion
配置共享文件夾
Homestead.yaml?文件的?folders?屬性里列出所有與 Homestead 環(huán)境共享的文件夾刻伊。這些文件夾中的文件若有變更搬男,它們會(huì)保持本地機(jī)器與 Homestead 環(huán)境之間同步腺兴。你可以根據(jù)需要配置多個(gè)共享文件夾:
folders:
? ? - map: ~/codeLaravel
? ? ? to: /home/codeLaravel
配置 Nginx 站點(diǎn)
sites?屬性將?域名?映射到 homestead 環(huán)境中的文件夾悼尾。Homestead.yaml?文件中已包含示例站點(diǎn)配置。同樣的章贞,你也可以增加多個(gè)站點(diǎn)到你的 Homestead 環(huán)境中祥绞。 Homestead 可以同時(shí)為多個(gè) Laravel 應(yīng)用提供虛擬化環(huán)境:
sites:
? ? - map: homestead.test
? ? ? to: /home/codeLaravel/public
必須將在 Nginx 站點(diǎn)中所添加的「域名」也添加到服務(wù)器的?hosts?上。?hosts?文件會(huì)將 Homestead 站點(diǎn)的請(qǐng)求重定向到 Homestead Box 中鸭限。在 Mac 或 Linux 上蜕径,該文件位于?/etc/hosts。添加的內(nèi)容如下所示:
192.168.10.10????homestead.app
要將 Homestead 直接安裝到項(xiàng)目中败京,需要使用 Composer:
$ cd ~
$ mkdir -p code
$ cd code
$?composer require laravel/homestead --dev
Warning: Accessing packagist.phpcomposer.com over http which is an insecure protocol.
Warning: Accessing packagist.phpcomposer.com over http which is an insecure protocol.
Warning: Accessing packagist.phpcomposer.com over http which is an insecure protocol.
Using version ^9.0 for laravel/homestead
./composer.json has been created
Warning: Accessing packagist.phpcomposer.com over http which is an insecure protocol.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 9 installs, 0 updates, 0 removals
? - Installingsymfony/polyfill-ctype (v1.11.0): Loading from cache
? - Installingsymfony/yaml (v4.3.3): Loading from cache
? - Installingsymfony/process (v4.3.3): Loading from cache
? - Installingpsr/container (1.0.0): Loading from cache
? - Installingsymfony/service-contracts (v1.1.5): Loading from cache
? - Installingsymfony/polyfill-php73 (v1.11.0): Loading from cache
? - Installingsymfony/polyfill-mbstring (v1.11.0): Loading from cache
? - Installingsymfony/console (v4.3.3): Loading from cache
? - Installinglaravel/homestead (v9.0.7): Loading from cache
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
symfony/console suggests installing psr/log (For using the console logger)
Writing lock file
Generating autoload files
Homestead 安裝完后兜喻,可以使用?make?命令在項(xiàng)目根目錄中生成?Vagrantfile?與?Homestead.yaml?文件。make?命令會(huì)自動(dòng)配置 Homestead.yaml 文件中的?sites?及?folders?指令赡麦。
$?php vendor/bin/homestead make
Homestead Installed!
==========
虛擬機(jī)啟動(dòng)成功后朴皆,通過(guò)下面命令來(lái)新建一個(gè)名為 Laravel 的項(xiàng)目
$ cd ~/Code
$?composer create-project laravel/laravel Laravel --prefer-dist "5.8.*"
完成之后,訪問(wèn)?http://homestead.test?你能看到如下圖所示界面泛粹,這是 Laravel 為我們生成默認(rèn)界面遂铡。
【參考】
https://learnku.com/courses/laravel-essential-training/5.8/the-first-application-hello-laravel/4057
==========
==========