Whisper words of wisdom, Lady peeって聞こえる
空耳なのだが、Let it beのところ、Lady peeに聞こえる。
参考書を片手にnode.jsの勉強/CentOSにインストールしたnode.jsの設定続き。仮想マシンのwebサーバに接続する設定、仮想マシンとの共有フォルダ設定を追加。
前回の続き。
vagrantfileを編集して、表題の設定をする。
以下のように2箇所コメントアウトを外した。
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
↓
config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.10"
そして、vagrant upした時にmacのCPUファンがフル回転して1分位して、CentOSへのログインがタイムアウトしてエラーが出るのが嫌なので、参考書の手順にはないけど、以下の2行もconfigの上に記載した箇所のすぐ下に追加した。
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
そして、vagrant reloadしたら、すんなり起動処理が終了した。
想定ではvagrant sshコマンドも自動実行して、ログインした状態になるのだと思っていたけど、そんなことはなかった。よくわからん。
仮想マシンとmacでのフォルダ共有の設定もしてみた。以下の記述部分のコメントアウトを外して、適当にフォルダを変更した。仮想マシン側では「/home/vagrant」を、mac側ではvagrantのフォルダの中の「data」フォルダにした。
config.vm.synced_folder "./data", "/home/vagrant" <--こうやるとnvmが動かなくなる
ということで、 ホームディレクトリを共有フォルダにすると、.bash_profile等のどうやらnvmを動かすのに必要なファイルがどうにかなるらしく、nvmが動かなくなるので、共有フォルダの設定はとりやめにした。(9/2追記)
ところで、macのテキストエディットは、「"vagrant"」とダブルクォーテーションで囲もうとすると、「”vagrant”」のようにダブルクォーテーションに似た別の文字に自動的に置き換わってしまう。全角か?まぁとにかく、というわけで、macのテキストエディットはコーディングには使えなさそうだ。
参考書を片手にnode.jsの勉強/CentOSにインストールしたnode.jsの設定続き。gitもインスコ。
前回からの続き。
参考書によれば、以下のコマンドでスーパーユーザになった時の変更したほうが良いとのこと。
sudo visudo
変更した点は以下の通り。
Defaults env_reset
↓
Defaults !env_reset
# Defaults env_keep += "HOME"
↓
Defaults env_keep += "HOME"
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
↓
# Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
viの操作系を覚えるのは大変。常に使っていればなんてことはないんだろうが、こういうLinuxで設定する時だけ使うってのは、忘れた頃にviを使って改めて調べて覚えるって感じ。でも、この繰り返しで「i」がインサートだってのは覚えたと思う。
元々のvagrantでインストールしたCentOSがCUIだからviを使っているが、GUI起動できるなら普通のメモ帳ソフトで編集した方がviの手順が不要な分だけ早い気はする。
そして、gitをインストール。
sudo yum install git
したらエラーが出た。
ttp://mirror.centos.org/centos/6/SCL/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
他のミラーを試します。
エラー: Cannot retrieve repository metadata (repomd.xml) for repository: scl. Please verify its path and try again
以下のページの方法を試してみようと思う。
したら、以下のエラーが表示された。
[vagrant@localhost ~]$ sudo yum install centos-release-sclo-rh
インストール処理の設定をしています
updates | 3.4 kB 00:00
updates/primary_db | 2.0 MB 00:00
パッケージ centos-release-sclo-rh は利用できません。
エラー: 何もしません
原因がよく分からないまま、gitのインストールをしたら今度はうまくインストール出来た。
念のため、removeしてもう一回gitをinstallしたが、インストール出来た。
参考書を片手にnode.jsの勉強/node.jsをインストールした
CentOSにnode.jsをインストールするにはnvmが必要で、nvmのインストールにはcurlコマンドを使うらしい。
以下のページで「curl -o- 〜 install.sh | bash」コマンドをコピってきて、コマンドラインで実行した。
で、v0.12.4のnvmをインストール。
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.6/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9321 100 9321 0 0 15800 0 --:--:-- --:--:-- --:--:-- 37890
=> Downloading nvm from git to '/home/vagrant/.nvm'
=> Initialized empty Git repository in /home/vagrant/.nvm/.git/
remote: Counting objects: 5278, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 5278 (delta 1), reused 0 (delta 0), pack-reused 5271
Receiving objects: 100% (5278/5278), 1.46 MiB | 728 KiB/s, done.
Resolving deltas: 100% (3178/3178), done.
Your version of git is out of date. Please update it!
=> Appending source string to /home/vagrant/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="/home/vagrant/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[vagrant@localhost ~]$ nvm install v0.12.4
-bash: nvm: コマンドが見つかりません
logout
Connection to 127.0.0.1 closed.
Last login: Tue Aug 30 14:38:57 2016 from 10.0.2.2
----------------------------------------------------------------
CentOS 6.7 built 2015-12-01
----------------------------------------------------------------
[vagrant@localhost ~]$ nvm install v0.12.4
######################################################################## 100.0%
Now using node v0.12.4 (npm v2.10.1)
Creating default alias: default -> v0.12.4
[vagrant@localhost ~]$ nvm alias default v0.12.4
default -> v0.12.4
[vagrant@localhost ~]$ node -v
v0.12.4
node.jsの勉強/参考書を片手にpcの設定作業/vagrantのCentOSにログインした
vagrantをインストールして、vagrant initで以下の通り入力。
#config.vm.box = "base"
config.vm.box = "puphpet/centos65-x64"
vagrant upでvagrantでCentOSを起動したら、次のエラーが表示された。
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'puphpet/centos65-x64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'puphpet/centos65-x64' is up to date...
==> default: Setting the name of the VM: Vagrant_default_1472563241044_8922
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
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.
新しいsshキーを使ってOSにログインしようとしてタイムアウトしてしまったみたいだ。
ここでは勉強として、vagrantのログを読んでみようと思ってネットを検索したところ、vagrantコマンドを実行する時、文頭にログ出力の文字列を加えて実行すればターミナル上にログが出力されるらしいことが分かった。
さっそく以下のコマンドでOSを破棄した所、思ったよりも沢山ログが出力された。
再び、VAGRANT_LOG=info vagrant upでOSを起動して、ターミナルに出力されたログを見ていると以下の記述が沢山あった。
INFO subprocess: Command not in installer, restoring original environment...
INFO ssh: Attempting to correct key permissions to 0600
INFO ssh: Attempting SSH connection...
INFO ssh: Attempting to connect to SSH...
INFO ssh: - Port: 2222
INFO ssh: - Password? false
INFO ssh: - Key Path: ["/Users/Documents/Vagrant/.vagrant/machines/default/virtualbox/private_key"]
INFO ssh: SSH not ready: #<Vagrant::Errors::SSHAuthenticationFailed: SSH authentication failed! This is typically caused by the public/private
keypair for the SSH user not being properly set on the guest VM. Please
verify that the guest VM is setup with the proper public key, and that
the private key path for Vagrant is setup properly as well.>
よく分からないのでそっ閉じしたい気分だが、雰囲気からたぶんpassword?falseとなっているので、passwordを指定しない状態でログインしようとしてエラーとなり、接続ができなかったのだろう。
ちなみにvagrant statusでタイムアウト後の状態をみるとこんな感じ。
$ vagrant status
Current machine states:
default running (virtualbox)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
起動しているみたい。
vagrant sshでssh接続し、username/password=vagrant/vagrantでログイン出来た。
node.jsの勉強/pcの設定作業
この本を読みながらmacの設定をしている。
JS+Node.jsによるWebクローラー/ネットエージェント開発テクニック
- 作者: クジラ飛行机
- 出版社/メーカー: ソシム
- 発売日: 2015/08/31
- メディア: 単行本
- この商品を含むブログ (2件) を見る
今日はVirtualboxとVagrantをインストールするところまでやった。
Virtualboxは以前からインストールされていたけど、新しいバージョンで上書きした。
正しい努力をした者のみ救われる
自分の努力に合わないものを得ようとした時、人は道を外れ、騙されたり、あるいは、警察に捕まったりする。
うまい話は色々あるが、大抵は騙しの手口だ。
仕事上の話だけではなく、ナンパや、あるいは、自分に寄ってくる痴漢も、釣り針が付いていて、怖い人に釣り上げられてしまい、弱みを握られ、人生を不意にしてしまうこともあるだろう。
何かを得ようとした時、甘い誘惑に負けず、正しい努力を積み重ねていくしかないのである。
弱い自分に打ち勝つしかないのである。