動作環境

仮想マシン作成・起動

$ vagrant box add CentOS7.0 https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box
$ vagrant box list
CentOS7.0 (virtualbox, 0)
$ mkdir ~/MyVagrant
$ cd MyVagrant
$ mkdir CentOS7.0
$ cd CentOS7.0
$ 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.
$ vi Vagrantfile
--------------------
config.vm.network "private_network", ip: "192.168.33.10"
--------------------
config.vm.network "public_network"
$ vagrant up
$ vagrant ssh
Welcome to your Vagrant-built virtual machine.
[vagrant@localhost ~]$
$ vagrant status
$ vagrant halt

Webサーバーの設定

$ 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!

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

vagrant up時のhost-only adapter対処法

$ 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
  1. コントロールパネル >> ネットワークとインターネット >> ネットワーク接続
  2. "VirtualBox Host-Only Networkを"無効にする"=>"有効にする"
  3. 再度 vagrant up 実行

"Hostsupdater"のインストール方法

$ 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)'!
  1. hostsファイル >> "セキュリティ" >> "編集"
  2. "Users"の"変更"と"書き込み"を許可
  3. Vagrantfileにホスト名を追記
    config.vm.hostname = "www.sample.com"
  4. hostsファイルが書き換わっていることを確認
    192.168.33.10  www.sample.com  # VAGRANT: 46d1144a4d5fa999fc18c6c6f5f39b5c (default) / 324e5f83-bd7e-4126-92b7-097d14f9b4bc

CentOS 7のロケールを変更

$ 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
$ 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
......
$ sudo localectl set-keymap us
$ 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のインストール

$ sudo yum -y install epel-release
$ cd /etc/yum.repos.d
$ sudo wget http://rpms.famillecollet.com/enterprise/remi.repo
$ yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
$ sudo yum -y install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-pear php-mbstring php-mcrypt php-mysqlnd
$ php -v
PHP 5.6.21 (cli) (built: Apr 28 2016 07:39:37)

MySQL 5.7をインストール

$ sudo yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
$ sudo yum -y install mysql-community-server
$ mysqld --version
mysqld  Ver 5.7.16 for Linux on x86_64 (MySQL Community Server (GPL))
$ sudo systemctl enable mysqld.service 

MySQLのrootパスワード再設定 MySQLのrootパスワードを失念した場合

$ 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> flush privileges;
mysql> quit
$ sudo vi /etc/my.cnf
...
skip-grant-tables # 削除
...

$ sudo systemctl restart mysqld.service
$ mysql -u root -p
Enter password:

MuSQLのパスワードポリシー変更

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');
$ sudo systemctl restart mysqld.service

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