【vmwarevm】Ubuntu+Homestead+Laravel

【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)前使用倉庫源

composer config -g repo

修改`composer`默認(rèn)倉庫為使用`

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è)置決定了你用的是哪一個 Vagrant 提供器:virtualbox、vmware_fusion、vmware_workstation?或者?parallels。你可以根據(jù)自己的喜好來設(shè)置提供器:

provider:vmware_fusion

配置共享文件夾

Homestead.yaml?文件的?folders?屬性里列出所有與 Homestead 環(huán)境共享的文件夾。這些文件夾中的文件若有變更,它們會保持本地機器與 Homestead 環(huán)境之間同步。你可以根據(jù)需要配置多個共享文件夾:

folders:

? ? - map: ~/codeLaravel

? ? ? to: /home/codeLaravel

配置 Nginx 站點

sites?屬性將?域名?映射到 homestead 環(huán)境中的文件夾。Homestead.yaml?文件中已包含示例站點配置。同樣的,你也可以增加多個站點到你的 Homestead 環(huán)境中。 Homestead 可以同時為多個 Laravel 應(yīng)用提供虛擬化環(huán)境:

sites:

? ? - map: homestead.test

? ? ? to: /home/codeLaravel/public

必須將在 Nginx 站點中所添加的「域名」也添加到服務(wù)器的?hosts?上。?hosts?文件會將 Homestead 站點的請求重定向到 Homestead Box 中。在 Mac 或 Linux 上,該文件位于?/etc/hosts。添加的內(nèi)容如下所示:

192.168.10.10????homestead.app

要將 Homestead 直接安裝到項目中,需要使用 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?命令在項目根目錄中生成?Vagrantfile?與?Homestead.yaml?文件。make?命令會自動配置 Homestead.yaml 文件中的?sites?及?folders?指令。

$?php vendor/bin/homestead make

Homestead Installed!

==========

虛擬機啟動成功后,通過下面命令來新建一個名為 Laravel 的項目

$ cd ~/Code

$?composer create-project laravel/laravel Laravel --prefer-dist "5.8.*"

完成之后,訪問?http://homestead.test?你能看到如下圖所示界面,這是 Laravel 為我們生成默認(rèn)界面。

【參考】

https://learnku.com/courses/laravel-essential-training/5.8/the-first-application-hello-laravel/4057

==========


==========

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容