#contents

** 動作環境 [#k9bb21a2]

- Windows
-- Windows 7 (32bit)
-- Oracle VM VirtualBox 5.0.16
-- Cygwin

- Mac
-- OS X 10.11 El Capitan
-- VirtualBox 5.0.20

** 仮想マシン作成・起動 [#of04b149]

- CentOS7.0(64bit)のbox(テンプレート)を追加

 $ vagrant box add CentOS7.0 https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box

- boxのテンプレート一覧: http://www.vagrantbox.es/

- box一覧表示

 $ vagrant box list
 CentOS7.0 (virtualbox, 0)

- 仮想マシン用ディレクトリ作成

 $ mkdir ~/MyVagrant
 $ cd MyVagrant
 $ mkdir CentOS7.0
 $ cd CentOS7.0

- vagrantの初期化

 $ vagrant init CentOS7.0
 A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant.

- Vagrantfileの下記行のコメントアウトを解除しネットワークアダプタ―(ホストオンリーアダプター)を追加

 $ vi Vagrantfile
 --------------------
 config.vm.network "private_network", ip: "192.168.33.10"
 --------------------

- ブリッジアダプタ―を追加する場合(ブラウザ経由でアクセスする場合)はVagrantfileの下記行のコメントアウトを解除

 config.vm.network "public_network"


- boxを利用して仮想マシン起動

 $ vagrant up

- SSH接続確認

 $ vagrant ssh
 Welcome to your Vagrant-built virtual machine.
 [vagrant@localhost ~]$

- 状態確認

 $ vagrant status

- 停止

 $ vagrant halt

** Webサーバーの設定 [#a3ebb2f3]

 $ sudo yum -y install httpd
 $ sudo systemctl start httpd.service    // Apacheを起動
 $ sudo systemctl enable httpd.service    // Apacheを常時起動
 $ sudo systemctl stop firewalld    // ファイアーウォールを停止
 $ sudo systemctl disable firewalld    // ファイアーウォールを常時停止
 $ ps aux | grep httpd

** Hello World! [#x1b47fcc]

 $ cd /var/www/html
 $ vi hello.js
 --------------------
 alert("Hello World!");
 --------------------

- &color(red){※};hello.jsが保存できない(4/5)

** vagrant up時のhost-only adapter対処法 [#d7a77c91]

- 固定IP(192.168.33.10)設定時に下記ネットワークエラー発生(原因はVirtualBoxのバグ)

 $ vagrant up
 Bringing machine 'default' up with 'virtualbox' provider...
 ==> default: Clearing any previously set forwarded ports...
 ==> default: Clearing any previously set network interfaces...
 There was an error while executing `VBoxManage`, a CLI used by Vagrant
 for controlling VirtualBox. The command and stderr is shown below.
 
 Command: ["hostonlyif", "create"]
 
 Stderr: 0%...
 Progress state: E_INVALIDARG
 VBoxManage.exe: error: Failed to create the host-only adapter
 VBoxManage.exe: error: Assertion failed: [!aInterfaceName.isEmpty()] at 'F:\tinderbox\win-5.0\src\VBox\Main\src-server\HostNetworkInterfaceImpl.cpp' (74) in long __thiscall HostNetworkInterface::init(class com::Bstr,class com::Bstr,clas s com::Guid,enum __MIDL___MIDL_itf_VirtualBox_0000_0000_0036).
 VBoxManage.exe: error: Please contact the product vendor!
 VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
 VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleCreate(struct HandlerArg *)" at line 71 of file VBoxManageHostonly.cpp

+ コントロールパネル >> ネットワークとインターネット >> ネットワーク接続
+ "VirtualBox Host-Only Networkを"無効にする"=>"有効にする"
+ 再度 vagrant up 実行

** "Hostsupdater"のインストール方法 [#ldb45194]

- vagrant up時にhostsファイルの書き換えを自動的に行うVagrantのプラグイン

 $ pwd
 /home/y.shimojo/MyVagrant
 $ vagrant plugin install vagrant-hostsupdater
 Installing the 'vagrant-hostsupdater' plugin. This can take a few minutes...
 Installed the plugin 'vagrant-hostsupdater (1.0.2)'!

- hostsファイルへのアクセス許可設定
+ hostsファイル >> "セキュリティ" >> "編集"
+ "Users"の"変更"と"書き込み"を許可
+ Vagrantfileにホスト名を追記
 config.vm.hostname = "www.sample.com"
+ hostsファイルが書き換わっていることを確認
 192.168.33.10  www.sample.com  # VAGRANT: 46d1144a4d5fa999fc18c6c6f5f39b5c (default) / 324e5f83-bd7e-4126-92b7-097d14f9b4bc

** CentOS 7のロケールを変更 [#w638878c]

- 現在のロケールを確認(デフォルトはドイツ語)

 $ localectl status
    System Locale: LANG=de_DE.UTF-8
        VC Keymap: de
       X11 Layout: de

- 使用可能なロケール(英語)一覧表示

 $ localectl list-locales | grep en_US
 en_US
 en_US.iso88591
 en_US.iso885915
 en_US.utf8

- ロケールの変更

 $ sudo localectl set-locale LANG=en_US.utf8

- ロケールの変更確認

 $ cat /etc/locale.conf
 LANG=en_US.utf8

- 使用可能なKeycap(US)一覧表示

 $ localectl list-keymaps | grep us
 ......
 us
 us-acentos
 us-alt-intl
 us-altgr-intl
 us-colemak
 us-dvorak
 us-dvorak-alt-intl
 us-dvorak-classic
 us-dvorak-intl
 us-dvorak-l
 us-dvorak-r
 us-dvp
 us-euro
 us-hbs
 us-intl
 us-mac
 us-olpc2
 us-workman
 us-workman-intl
 ......

- Keycapの変更

 $ sudo localectl set-keymap us

- Keycapの変更確認

 $ cat /etc/vconsole.conf
 KEYMAP=us

- 変更の反映

 $ source /etc/locale.conf
 $ localectl status
    System Locale: LANG=en_US.utf8
        VC Keymap: us
       X11 Layout: us
        X11 Model: pc105+inet
      X11 Options: terminate:ctrl_alt_bksp

** PHP 5.6のインストール [#b96b67fb]

- Remiリポジトリの追加

 $ sudo yum -y install epel-release
 $ cd /etc/yum.repos.d
 $ sudo wget http://rpms.famillecollet.com/enterprise/remi.repo

- yum listで提供されているパッケージを確認

 $ yum list --enablerepo=remi --enablerepo=remi-php56 | grep php

- RemiリポジトリからPHP 5.6をインストール

 $ sudo yum -y install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-pear php-mbstring php-mcrypt php-mysqlnd

- PHPバージョン確認

 $ php -v
 PHP 5.6.21 (cli) (built: Apr 28 2016 07:39:37)

** MySQL 5.7をインストール [#m6472133]

- MySQLのyumリポジトリ追加

 $ sudo yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

- MySQL Community Serverをインストール

 $ sudo yum -y install mysql-community-server

- MySQLバージョン確認

 $ mysqld --version
 mysqld  Ver 5.7.16 for Linux on x86_64 (MySQL Community Server (GPL))

- MySQL自動起動設定

 $ sudo systemctl enable mysqld.service 

*** MySQLのrootパスワード再設定 &color(red){※};MySQLのrootパスワードを失念した場合 [#s5465486]

- 一時的にパスワード認証なしでログイン可能状態に変更

 $ sudo vi /etc/my.cnf
 ...
 skip-grant-tables # 追加
 ...
 
 $ sudo systemctl restart mysqld.service

- パスワードを再設定

 mysql> use mysql
 mysql> UPDATE user SET authentication_string=password('your_admin_password') WHERE user='root';

- 再設定したパスワードをMySQLに反映

 mysql> flush privileges;

- MySQLをログアウト

 mysql> quit

- パスワード認証なしでログイン不可状態に変更

 $ sudo vi /etc/my.cnf
 ...
 skip-grant-tables # 削除
 ...
 
 $ sudo systemctl restart mysqld.service

- MySQLにrootユーザーでログイン

 $ mysql -u root -p
 Enter password:

*** MuSQLのパスワードポリシー変更 [#o5e033b3]

- 'password_policy' を 'LOW' に、'password_length' を '4' 文字に変更

 mysql> SET GLOBAL validate_password_policy=LOW;
 mysql> SET GLOBAL validate_password_length=4;

- パスワードポリシー確認

 mysql> SHOW VARIABLES LIKE 'validate_password%';
 +--------------------------------------+-------+
 | Variable_name                        | Value |
 +--------------------------------------+-------+
 | validate_password_check_user_name    | OFF   |
 | validate_password_dictionary_file    |       |
 | validate_password_length             | 4     |
 | validate_password_mixed_case_count   | 1     |
 | validate_password_number_count       | 1     |
 | validate_password_policy             | LOW   |
 | validate_password_special_char_count | 1     |
 +--------------------------------------+-------+
 7 rows in set (0.00 sec)

- パスワード変更(任意)

 mysql> SET PASSWORD for root@localhost=PASSWORD('your_admin_password');

- MySQL再起動

 $ sudo systemctl restart mysqld.service


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS