S3導入したらGem::Ext::BuildError: ERROR: Failed to build gem native extension.が発生した

##起こった問題
S3を導入して、`bundle exec cap production deploy`を実行すると、以下のようなエラーが出るようになって数時間ネット上をさまよいました。

```ターミナル
      01 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
      01
      01 current directory:
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/ovirt-engine-sdk-4.2.4/ext/ovirtsdk4c
      01 /home/ec2-user/.rbenv/versions/2.3.1/bin/ruby -r
      01 ./siteconf20180510-4555-1tzvudt.rb extconf.rb
      01 checking for xml2-config... yes
      01 checking for curl-config... no
      01 *** extconf.rb failed ***
      01 Could not create Makefile due to some reason, probably lack of necessary
      01 libraries and/or headers.  Check the mkmf.log file for more details.  You may
      01 need configuration options.
      01
      01 Provided configuration options:
      01  --with-opt-dir
      01  --without-opt-dir
      01  --with-opt-include
      01  --without-opt-include=${opt-dir}/include
      01  --with-opt-lib
      01  --without-opt-lib=${opt-dir}/lib
      01  --with-make-prog
      01  --without-make-prog
      01  --srcdir=.
      01  --curdir
      01  --ruby=/home/ec2-user/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME)
      01  --with-libcurl-config
      01  --without-libcurl-config
      01  --with-pkg-config
      01  --without-pkg-config
      01 extconf.rb:40:in `<main>': The "libcurl" package isn't available. (RuntimeError)
      01
      01 To see why this extension failed to compile, please check the mkmf.log which can
      01 be found here:
      01
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/ovirt-engine-sdk-4.2.4/mkmf.log
      01
      01 extconf failed, exit code 1
      01
      01 Gem files will remain installed in
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/ovirt-engine-sdk-4.2.4 for
      01 inspection.
      01 Results logged to
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/ovirt-engine-sdk-4.2.4/gem_make.out
      01
      01 An error occurred while installing ovirt-engine-sdk (4.2.4), and Bundler cannot
      01 continue.
      01 Make sure that `gem install ovirt-engine-sdk -v '4.2.4'` succeeds before
      01 bundling.
      01
      01 In Gemfile:
      01   fog was resolved to 2.0.0, which depends on
      01     fog-ovirt was resolved to 1.0.3, which depends on
      01       ovirt-engine-sdk
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as ec2-user@13.231.98.2: bundle exit status: 5
bundle stdout: Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
```
logファイル見てって言われたからlogファイル開いたけど何にも書いてませんでした。

###解決策
fogのバージョンを下げてあげたら直りました。

```Gemfile
gem 'fog', '~> 1.41.0'
```
と書いてbundle installを実行。元々はバージョン指定をしてなくて、2.0.0でした。
するとこのエラーに関しては解決しました。

##また別の問題が起こった
```ターミナル
      01 rake aborted!
      01 Mysql2::Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/mysql2-0.4.10/lib/mysql2/client.rb:89:in `connect'
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/mysql2-0.4.10/lib/mysql2/client.rb:89:in `initialize'
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `new'
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `mysql2_conne…
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:729:in `n…
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:773:in `c…
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:752:in `t…
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:713:in `a…
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:490:in `c…
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `c…
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:883:in `r…
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:91:in `connection'
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/migration.rb:1118:in `initialize'
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/migration.rb:1006:in `new'
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/migration.rb:1006:in `up'
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/migration.rb:984:in `migrate'
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/tasks/database_tasks.rb:163:in `migrate'
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (…
      01 /var/www/chat-space/shared/bundle/ruby/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
      01 /home/ec2-user/.rbenv/versions/2.3.1/bin/bundle:23:in `load'
      01 /home/ec2-user/.rbenv/versions/2.3.1/bin/bundle:23:in `<main>'
      01 Tasks: TOP => db:migrate
      01 (See full trace by running task with --trace)
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as ec2-user@13.231.98.2: Exception while executing as ec2-user@13.231.98.2: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!

```
###解決策
socketファイルがないって言われてます。
touchコマンドでファイルを作るも改善されず。
本番環境のターミナルに移動して`sudo service mysqld restart`を実行する。
ディレクトリを移動してlsコマンドでmysql.sockがあることを確認。
無事`bundle exec cap production deploy`が通るようになり、本番環境でもアプリが動くようになりました。