ホスト環境
- Windows10 Home 1903
- Vagrant 2.2.6
BOXの追加
vagrant box add CentOS7 https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box
vagrant init CentOS7
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "CentOS7"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder "../projects", "/var/projects",create:"true"
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
end
end
仮想マシンの起動、接続
vagrant up
vagrant ssh
日本時間
$ date
$ sudo cp /usr/share/zoneinfo/Japan /etc/localtime
$ date
MySQLインストール
リポジトリの追加、インストール
$ sudo yum remove -y mariadb-libs
$ sudo yum localinstall -y https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
$ sudo yum install -y mysql-community-server
version確認
$ mysql --version
mysql Ver 8.0.18 for Linux on x86_64 (MySQL Community Server - GPL)
$ mysqld --version
/usr/sbin/mysqld Ver 8.0.18 for Linux on x86_64 (MySQL Community Server - GPL)
起動
$ sudo systemctl start mysqld
$ systemctl status mysqld
自動起動設定
$ sudo systemctl enable mysqld
$ systemctl is-enabled mysqld
パスワード変更
$ sudo grep password /var/log/mysqld.log
...temporary password is generated for root@localhost: Hu-lFWs4y*>Y
$ mysql -u root -p
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password'
/etc/my.cnf
[mysqld]
character-set-server=utf8mb4
[client]
default-character-set=utf8mb4
$ sudo service mysqld restart
mysql> show variables like 'character_set%';
mysql-develのインストール
$ sudo yum install -y mysql-devel
gitのインストール
$ sudo yum install -y git
fatal: unable to access...
以下記事参照
git fatal: unable to access Peer reports incompatible or unsupported protocol version.
$ sudo yum update -y nss curl libcurl
- 諸々インストール
$ sudo yum -y install gcc openssl-devel readline-devel zlib-devel
node.jsのインストール
NodeSource Node.js Binary Distributions
$ sudo yum install gcc-c++ make
$ su
# curl -sL https://rpm.nodesource.com/setup_13.x | bash -
# sudo yum install -y nodejs
rbenvのインストール
$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
bashに追記
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ exec $SHELL -l
確認
$ rbenv --version
rbenv 1.1.2-11-gc46a970
ruby-buildのインストール
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
Rubyのインストール
$ rbenv install --list
$ rbenv install -v 2.6.4
確認
$ rbenv versions
2.6.4
有効にするversionの設定
$ rbenv global 2.6.4
確認
$ ruby -v
ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-linux]
Railsのインストール
$ gem install rails -v 5.2.3
$ rails -v
Rails 5.2.3
アプリ作成
cd /var/projects
rails new first_article -d mysql
...
...
...
+--------------------------------------------------------------------+
| |
| NOTICE: chromedriver-helper is deprecated after 2019-03-31. |
| |
| Please update to use the 'webdrivers' gem instead. |
| See https://github.com/flavorjones/chromedriver-helper/issues/83 |
| |
+--------------------------------------------------------------------+
Gemfileを編集
group :test do
...
- gem 'chromedriver-helper'
+ gem 'webdrivers'
database.yml
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: password
socket: /var/lib/mysql/mysql.sock
database作成
$ rails db:create
Created database 'first_article_development'
Created database 'first_article_test'
server起動
rails s -b 0.0.0.0
アクセス
...応答時間が長すぎます。の文言が、、、、
以下の記事を参照
CentOS 7 firewalld よく使うコマンド
# firewall-cmd --add-port=3000/tcp --zone=public --permanent
# firewall-cmd --reload
Yay! You’re on Rails!が画面でれば成功‼