apt-getとyumの違い

Why?

  • いっつもyum使ってるけど、Ubuntu使ったときにapt-get使ったけど、違いが説明しきれなかった

同じところ

  • apt も yum もパッケージ管理ソフト
    • 自動ダウンロード、インストール、アップグレード

違うところ

参考

Linux パッケージ管理コマンド比較(yum / dnf / apt 等) - らくがきちょう

TODO

Ubuntu に Java インストール

What?

  • UbuntuJava環境をインストールする

Why?

  • NeobundleInstall を叩いたときにJavaがなくてコケた

Solution

  • Apt-get でインストールする

  • Ubuntu version

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"
  • パッケージのIndexをアップデートする
$ sudo apt-get update
  • Javaがインストールされているか確認
$ java -version
bash: java: command not found
  • Apt-getでJava Runtime Environment (JRE)をインストールする
$ sudo apt-get install default-jre
$ sudo apt-get install default-jdk

参考

How To Install Java on Ubuntu with Apt-Get | DigitalOcean

TODO List

  • Apt-get と yum の使い分け
  • JREJDK の違い

Laravel homesteadで最初のVagrant upが止まる

What?

$ vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
    homestead-7: Adapter 1: nat
    homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
    homestead-7: 80 (guest) => 8000 (host) (adapter 1)
    homestead-7: 443 (guest) => 44300 (host) (adapter 1)
    homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
    homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
    homestead-7: 27017 (guest) => 27017 (host) (adapter 1)
    homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
    homestead-7: SSH address: 127.0.0.1:2222
    homestead-7: SSH username: vagrant
    homestead-7: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
  • ゲストPCをVirtualbox GUIから直接コンソールをShowすると、以下で止まっている
A start job is running for raise network interfaces (5 mins 8 sec)

Why?

  • VirtualboxNetwork > Adapter 1(NAT) > Advanced > Cable Connected のチェックが外れていただけだった。。

Solution?

  • VirtualboxNetwork > Adapter 1(NAT) > Advanced > Cable Connected のチェックを入れて、再度vagrant up

  • もし再度vagrant upして止まったら一度destroyしてから、再度up

  • 判別手順

    • Vagrantではエラーが出ずに止まる
      • VirtualboxGUIからShowしてコンソールを確認
        • A start job is running for raise network interfaces ネットワークの何かを延々と待っているっぽい
    • Virtualboxにそもそも普通にssh接続できるのか
    • Virtualboxのネットワーク設定がおかしいのか
      • NATとHost-only Adapterは設定されてる?
        • されてる
      • Port Forwardingは設定されてる?
        • ssh Host 2222 -> Guest 22 に設定されてる
      • Virtualbox上でネットワーク設定で通常と違うところは?
        • Cable Connectedが。。。チェックが外れてる。。。

無駄に頑張ったこと

  • (GUIから見る前)Virtualboxが立ち上がる前に死んだと思った
    • VirtualboxGUIから入ってShowすると普通に生きてた
  • ssh認証設定が間違っていると思っていた
    • ~/.homestead/Homestead.yamlssh keyの所在を確認したが、問題ない
    • そもそもauthorisationエラーが出てない
  • Hostsの設定が間違っていると思っていた
    • ~/.homestead/Homestead.yamlのIP設定がおかしいと思った
      • そもそも立ち上げる前なので関係ない
      • ここが間違っているとIPorドメインでアクセスしようとしたときに死ぬはず
  • Vagrant, Virtualbox のバージョンが古いと思った
    • バージョンが古ければエラーが出るはずだけど、一応念を入れて最新にした

Laravel homesteadを使ってLaravel 5のローカル開発環境を構築

Index

What?

Why?

  • Laravel は、PHPのくせにNode.js諸々が必要だったりして、かなり環境構築が面倒
    • Vargrantを使って一気に環境を作れると便利!
    • Laravel環境に必要なものをhomesteadという名前のVagrantboxとしてまとめたぜ!

How to?

Step1: 事前準備

  • Vagrant と homesteadの初期化をしておく

  • ローカル開発環境(つまりはお手元のmac)で

    • Vagrant をインストール(時間かかる)
    • VagrantのHomestead boxをダウンロードしておく(時間かかる)
      • vagrant box add laravel/homestead
    • Homestead をcloneして、初期化(一瞬)
      • git clone https://github.com/laravel/homestead.git homestead
      • cd homestead; sh init.sh
        • ~/.homesteadディレクトリの中に設定ファイルがコピーされる

Step2: 設定

  • Homesteadの設定をする
    • ~/.homestead/Homestead.yaml を編集する
      • sites.map 以外はディフォルト
ip: "192.168.10.10" # VMのIPになる
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Develop/Trial/tryLaravel # ローカルでLaravelをインストールするorされているディレクトリ
      to: /home/vagrant/Code # VM内のディレクトリ

sites: # Nginxの設定
    - map: homestead.app # ドメイン設定、Hosts設定とつながる
      to: /home/vagrant/Code/Laravel/public # Laravelのpublicディレクトリの場所

databases:
    - homestead
  • ホストPCでHostsを追記(homestead.appドメインでアクセスするため
    • 再起動はいらないよー
192.168.10.10 homestead.app

Step3: VM立ち上げ

$ mkdir -p ~/Develop/Trial/tryLaravel
  • VMを立ち上げる
    • bootするのに数分かかる
$ cd ~/homestead/
$ vagrant up
  • 確認

Step4: Laravelインストール

  • ホストPCからゲストPCにsshログイン
$ vagrant ssh
  • ゲストPCで、Laravelインストール
$ cd ~/Code
$ composer create-project laravel/laravel --prefer-dist laravel

参考

Laravel homesteadを利用したLaravel 5 ローカル開発環境の構築 | hrendoh's memo

Laravel Homesteadを使ってみよう! - Qiita

Homestead.yamlの編集 | WinRoadのLaravel4初心者講座

Laravel homestead初期設定中に失敗したときのやり直し方

What?

  • Laravel homestead初期設定中に失敗したときのやり直し方

Why?

$ vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Running provisioner: file...
Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.

Solution

  • 一回殺してから、再起動
$ vagrant destroy
$ vagrant up

Mac で vagrant のバージョンアップをする

What?

  • Macvagrant のバージョンアップをする

Why?

  • Laravel環境をhomesteadで作ろうとしたらバージョン低すぎて怒られた
$ vagrant up
This Vagrant environment has specified that it requires the Vagrant
version to satisfy the following version requirements:

>= 1.8.4

Solution

  • 作業前
$ vagrant -v
Vagrant 1.8.1
  • Mac用のpkgをダウンロードしてGUIでインストールするだけ

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

  • 作業後
$ vagrant -v
Vagrant 1.9.1

Jenkins初期セットアップ時にプラグインがインストールできない

What?

Jenkins初期セットアップ時に以下エラーが表示され、プラグインがインストールできない。

An error occurred during installation: No such plugin: cloudbees-folder

Why?

まだ不明

Solution?

http://localhost:8080/restart でJenkinsを再起動する

or

service jenkins restart でJenkinsを再起動する

をやってみたけど、だめだったのでGetting startedをスキップしてしまった。継続調査中。

参考

stackoverflow.com