CF에 라라벨 앱 올려보기

(CF에 Laravel 앱 올려보기에서 넘어옴)
CF에 Laravel 앱 올려보기
CF에 라라벨 애플리케이션 올리기

1 사전작업[ | ]

2 laravel-cf 클론[ | ]

ubuntu@zetawiki:~$ git clone https://github.com/jmnote/laravel-cf.git
ubuntu@zetawiki:~$ cd laravel-cf/
ubuntu@zetawiki:~/laravel-cf$ ll
total 24
drwxrwxr-x  4 ubuntu ubuntu 4096 Aug 29 05:44 ./
drwxrwxr-x 11 ubuntu ubuntu 4096 Aug 29 05:44 ../
drwxrwxr-x  2 ubuntu ubuntu 4096 Aug 29 05:44 .bp-config/
-rw-rw-r--  1 ubuntu ubuntu   44 Aug 29 05:44 .cfignore
drwxrwxr-x  8 ubuntu ubuntu 4096 Aug 29 05:44 .git/
-rw-rw-r--  1 ubuntu ubuntu  137 Aug 29 05:44 manifest.yml

3 laravel 프로젝트 생성[ | ]

ubuntu@zetawiki:~/laravel-cf$ composer create-project laravel/laravel
Installing laravel/laravel (v5.2.31)
  - Installing laravel/laravel (v5.2.31)
    Loading from cache

Created project in /home/ubuntu/laravel-cf/laravel
> php -r "copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
... (생략)
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
> php artisan key:generate
Application key [base64:uNg1ZCX6Vy7tvgqHeUkg2TTYQ91SbK1alfs5WhF8Owo=] set successfully.

4 파일 생성[ | ]

ubuntu@zetawiki:~/laravel-cf$ touch laravel/storage/framework/cache/hello
ubuntu@zetawiki:~/laravel-cf$ touch laravel/storage/framework/sessions/hello
ubuntu@zetawiki:~/laravel-cf$ touch laravel/storage/framework/views/hello

5 manifest 수정[ | ]

  • DB상품 확인
ubuntu@zetawiki:~/laravel-cf$ cf services
Getting services in org cloudpack / space testuser03 as testuser03...
OK

name       service      plan        bound apps   last operation
mydb1      devpack-db   1gb                      create succeeded
→ 서비스 인스턴스 이름(name컬럼)은 mydb1
→ 서비스 이름(service컬럼)은 devpack-db
ubuntu@zetawiki:~/laravel-cf$ vi manifest.yml
---
applications:
- name: laravel-jmnote
  memory: 128M
  buildpack: https://github.com/cloudfoundry/php-buildpack
  services:
  - mydb1

6 소스코드 수정[ | ]

ubuntu@zetawiki:~/laravel-cf$ vi laravel/config/database.php
<?php
$vcap_credentials = $_ENV['VCAP_SERVICES']['devpack-db'][0]['credentials'];

return [
... (생략)
        'mysql' => [
            'driver' => 'mysql',
            'host' => $vcap_credentials['hostname'],
            'port' => $vcap_credentials['port'],
            'database' => $vcap_credentials['name'],
            'username' => $vcap_credentials['username'],
            'password' => $vcap_credentials['password'],
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => false,
            'engine' => null,
        ],
... (생략)

7 cf push[ | ]

ubuntu@zetawiki:~/laravel-cf$ cf push
Using manifest file /home/ubuntu/laravel-cf/manifest.yml

Creating app laravel-jmnote in org cloudpack / space testuser03 as testuser03...
OK
... (생략)
requested state: started
instances: 1/1
usage: 128M x 1 instances
urls: laravel-jmnote.devpack.co.kr
last uploaded: Mon Aug 29 06:36:25 UTC 2016
stack: unknown
buildpack: https://github.com/cloudfoundry/php-buildpack

     state     since                    cpu     memory          disk           details
#0   running   2016-08-29 03:37:37 PM   97.6%   70.7M of 128M   182.5M of 1G

8 확인[ | ]

→ 아래와 같은 라라벨 초기화면이 나온다.

9 같이 보기[ | ]

10 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}