忘れがちな記憶へ
忘れていく知識をここにメモしていきます。
VirtualBoxを動かす Ubuntu12.04 LTS
Ubuntu 12.04 Vagrant + Laravel4.1 + PHP 5.5.
Vagrant upで動かしてみる。
http://localhost:8888
でアクセスできると記載されているがつながらないのでvagrant reloadすると55555になっていた。
$ vagrant reload
==> laravel4: Attempting graceful shutdown of VM...
==> laravel4: Clearing any previously set forwarded ports...
==> laravel4: Clearing any previously set network interfaces...
==> laravel4: Preparing network interfaces based on configuration...
laravel4: Adapter 1: nat
==> laravel4: Forwarding ports...
laravel4: 22 => 2222 (adapter 1)
laravel4: 80 => 55555 (adapter 1)
laravel4: 3306 => 55556 (adapter 1)
laravel4: 5432 => 55557 (adapter 1)
==> laravel4: Booting VM...
==> laravel4: Waiting for machine to boot. This may take a few minutes...
laravel4: SSH address: 127.0.0.1:2222
laravel4: SSH username: vagrant
laravel4: SSH auth method: private key
laravel4: Warning: Connection timeout. Retrying...
laravel4: Warning: Connection timeout. Retrying...
laravel4: Warning: Connection timeout. Retrying...
==> laravel4: Machine booted and ready!
==> laravel4: Checking for guest additions in VM...
laravel4: The guest additions on this VM do not match the installed version of
laravel4: VirtualBox! In most cases this is fine, but in rare cases it can
laravel4: prevent things such as shared folders from working properly. If you see
laravel4: shared folder errors, please make sure the guest additions within the
laravel4: virtual machine match the version of VirtualBox you have installed on
laravel4: your host and reload your VM.
laravel4:
laravel4: Guest Additions Version: 4.2.0
laravel4: VirtualBox Version: 4.3
==> laravel4: Setting hostname...
==> laravel4: Mounting shared folders...
laravel4: /vagrant => /home/gabriel/laravel/Laravel4-Vagrant
laravel4: /var/www => /home/gabriel/laravel/Laravel4-Vagrant/www
laravel4: /tmp/vagrant-puppet-2/manifests => /home/gabriel/laravel/Laravel4-Vagrant/puppet/manifests
laravel4: /tmp/vagrant-puppet-2/modules-0 => /home/gabriel/laravel/Laravel4-Vagrant/puppet/modules
==> laravel4: VM already provisioned. Run `vagrant provision` or use `--provision` to force it
これでいつものLaravelの初期画面が表示された。
http://localhost:55555/
参考:
Vagrantのインストール Ubuntu12.04 LTS
Ubuntu 12.04 Vagrant + Laravel4.1 + PHP 5.5.
と始めて第二段。
今日はVagrantのインストール。
ここ(Download Vagrant)でダウンロードする。
$ wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.5.2_x86_64.deb
# Vagrant Packageのインストール
$ dpkg -i vagrant_1.5.2_x86_64.deb
参考:
Vagrant Download
VirtualBoxのインストール Ubuntu12.04 LTS
Ubuntu 12.04 Vagrant + Laravel4.1 + PHP 5.5.
まずはVirtualBoxのインストール
ここ(VirtualBox 4.3.10 for Linux)を見ればだいたいわかる。
source.listへの登録
$ vim /etc/apt/sources.list
deb http://download.virtualbox.org/virtualbox/debian precise contrib
公開鍵の登録
$ wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
OK
VirtualBoxのインストール
$ sudo apt-get update
$ sudo apt-get install virtualbox-4.3
インストールマニュアルには以下のことが記載されているがapt-get installに含まれてるようだ。
Note: Ubuntu/Debian users might want to install the dkms package to ......
参考:
Download VirtualBox
PHP Laravel4でController on Ubuntu12.04 LTS
ルートの設定
app/routes.php
// UserControllerにshowProfileメソッドを追加する。
Route::get('user/{id}', 'UserController@showProfile');
Controllerの設定
app/controllers/UserController.php
<?php
class UserController extends BaseController {
/**
* Instantiate a new UserController instance.
*/
public function __construct()
{
Log::info('Start UserController: __construct');
}
/**
* 指定されたユーザーのプロファイルを表示する
*/
public function showProfile($id)
{
Log::info('Start IDs:'.$id);
// $user = User::find($id);
$name='Hoge';
Log::info(' name:'.$name);
return View::make('greeting', array('name' => $name));
}
}
Viewの設定
app/views/greeting.blade.php
<html>
<body>
<h1>こんにちは、{{{$name}}}さん</h1>
</body>
</html>
参考:
Laravel4 Controller 日本語版
Laravel4.1ドキュメント