Homestead 사용법

IT 2018. 9. 20. 16:39


- 라라벨 홈스테드, 개발용 로컬 서버 환경 구축


- Laravel Homestead  설치 방법

https://www.lesstif.com/pages/viewpage.action?pageId=24445701   <=== 권장

http://l5.appkr.kr/lessons/02-install-homestead-windows.html

https://laravel.com/docs/4.2/homestead


//=======================

* 준비

- Virtualbox 설치

https://www.virtualbox.org/wiki/Downloads



- Git 설치 (옵션)

- Git Bash 필요

https://gitforwindows.org/

- Git Bash: MinGW64를 이용한 bash 쉘 제공

"C:\Program Files\Git\git-bash.exe" --cd-to-home



- PHP 설치 (옵션)



- composer 설치 (옵션)

- php 의존성 관리 프로그램

https://getcomposer.org/download/

- composer.phar (php archive 파일) 을 다운로드해서 서버로 복사


- 윈도우 OS에서 설정

echo @php "%~dp0composer.phar" %*>composer.bat

composer.bat 와 composer.phar을 $PATH 설정된 폴더로 복사



//=============================

Vagrant 설치

- 버츄얼박스 가상 이미지 제공

- 다운로드

https://www.vagrantup.com/downloads.html



//===========

* laravel/homestead 설치

- 라라벨 개발용 서버,

-  가상 머신 이미지 다운로드


vagrant  box  add  laravel/homestead


만약 안된다면

vagrant box add laravel/homestead https://atlas.hashicorp.com/laravel/boxes/homestead




//======================================

- homestead 설치(로컬!! Windows 10 OS )


- 설치할 폴더로 이동

c:\users\userID

- Git Bash 실행 ("C:\Program Files\Git\git-bash.exe" --cd-to-home)


- 파일 다운로드

- Homestead CLI tool

git clone https://github.com/laravel/homestead.git Homestead

- 초기화, Homestead.yaml파일등 복사

cd Homestead

bash init.sh

- 참고 : 윈도우용= init.bat

- 참고 : ~/Homestead = C:\Users\userID\Homestead



- SSH 보안키(페어) 생성

ssh-keygen -t rsa -C "userID@homestead"

- 중간에 파일 이름을 입력하지 않으면 C:\Users\userID\.ssh 폴더에 키 파일 생성

- *.pub=공개키


//==========================

- Homestead.yaml 파일 수정

ip 192.168.10.10 //가상머신의 IP , 수정하지 않는다.


folders //공유폴더경로

folders:

    - map: ~/code

      to: /home/vagrant/code


sites //웹서버 접속용 로컬 도메인

sites:

- map: homestead.test

      to: /home/vagrant/code/public


- hosts 파일 수정

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


192.168.10.10  homestead.test


//==========================

- vagrant 가상머신 제어

~/Homestead(로컬 c:\users\userID\Homestead) 로 이동

vagrant up   <== 가상머신 시작

- 에러가 나면 virtualbox 재설치, virtualbox용 네트워크 설정 확인(랜카드)


vagrant  suspend - 일시중지

vagrant halt - 끄기

vagrant reload - 재가동



//======================

- 가상머신에 ssh 접속

vagrant ssh 

or ssh vagrant@192.168.10.10

Putty 유틸로도 접속가능

- Host Name : vagrant@192.168.10.10

ID = vagrant , PASSWORD = vagrant



//===================

- 웹서버 설정 변경

/etc/nginx/sites-enabled/homestead.test 파일 수정


root "경로"  



//===================

- 웹서버 접속

/home/vagrant/code/public 폴더(로컬 ~/code/pulbic)에 t.php생성

<?php phpinfo(); ?>

http://homestead.test/t.php

//======================

- mysql 접속

Host : 192.168.10.10 - 머신 IP

Port : 3306

User Name : homestead

Password : secret





//=================================

//참고

HHVM(HipHop Virtual Machine)

- 페이스북에서 제작

- JIT 컴파일을 이용한 PHP 버추얼 머신

- 기존 php 엔진보다 5~9배 빠름




- Nginx에 fastcgi로 설치 방법

https://www.digitalocean.com/community/tutorials/how-to-install-hhvm-with-nginx-on-ubuntu-14-04




//===============================

// 참고만

* VirtualBox로 가상머신이미지를 직접 로드해서 사용하는 방법(homestead에서는 불필요)


- 가상머신을 선택 : VirtualBox

- 자동으로 다운로드 해서 설치 : 10분정도 걸림

 = "D:\HashiCorp\Vagrant\embedded\mingw64\bin/curl.EXE" -q --fail --location --max-redirs 10 --verbose --user-agent "Vagrant/2.1.5 (+https://www.vagrantup.com; ruby2.4.4) " --continue-at - --output C:/Users/userID/.vagrant.d/tmp/box294969b313e1338f0cd6a347f68be3b599016863 https://vagrantcloud.com/laravel/boxes/homestead/versions/6.3.0/providers/virtualbox.box

- 이미지 다운로드 경로 : C:\Users\userID\.vagrant.d\boxes

- VirtualBox 프로그램 실행 -> 파일 -> 가상 시스템 가져오기 


- 가상머신 시작

- 로그인 :  ID = vagrant , PASSWORD = vagrant

- 아이피 확인 : 아마 거의 10.0.2.15

- 가상머신 종료


- 가상머신 설정 : 로컬에서 가상머신으로 SSH 접속이 가능하도록 설정

가상머신 선택 -> 설정 -> 네트워크 -> 네트워크 : NAT

-> 고급 : '포트 포워딩' 버튼 -> 규칙 추가 버튼 

-> 프로토콜=TCP, 호스트IP=로컬IP, 포트=22, 게스트IP=버추얼머신IP, 포트=22, 

- 가상머신 시작

- SSH (Putty) 로그인 :  ID = vagrant , PASSWORD = vagrant



반응형

'IT' 카테고리의 다른 글

AWS 사용법  (0) 2018.09.20
리눅스 사용법 정리  (0) 2018.09.20
크롬 이미지 일괄 다운로더 추천  (0) 2018.08.06
갤럭시 S3 루팅 방법  (0) 2018.08.06
갤럭시 S3 커스텀 롬  (0) 2018.08.02
Posted by codens