Laravel JP Conference に行ってきました
conference2019.laravel.jp
同じLaravelのカンファレンスではありますが、Laraconとは別枠としての開催だそうで、第1回&今の時点では次回開催は未定とのことでした…。
去年末のPHPカンファレンスで存在を知り、1月ごろに申し込みました。
Laravelド初心者として参加したのですが、デプロイ・DBなどのチューニングと、PHPerなら(いや言語拘らず)役に立つものばかりで、
とても楽しかったです。
スライドはすでにまとめ記事がありましたので、こちらをご確認ください。
どのセッションも、スライドだけでも言いたいことが伝わる素晴らしいクオリティでしたので!
qiita.com
ここからは各セッションの感想です。
[:contents]
LPはたくさんあったので省略…すみません。
ServiceProvider, ServiceContainer入門
複雑な機能が絡み合っているサービスプロバイダ・サービスコンテナまわりを、機能ごとに切り分けてわかりやすく説明。
残念ながら私はまだこの機能を活用するフェーズに立ててないのですが、
それでも、なんのための機能かどうやって使うべきかを理解することができました。
すっごいわかりやすかったです!
SimpleとEasyは違う
easyとsimpleの違いについて、日本人になら誰にでも伝わるワード「創味のつゆ」を用いて説明。
「創味のつゆ」が万能すぎて、発表を聞いてないエンジニア、いや全く関係ない職種にも違いを説明できるような気がしています。
エキテンとLaravelと私
12年目の自社サービス(エキテン)をマイクロサービス化するにあたって、大変だったこと・よかったことの新卒1年目視点のまとめ。
新卒1年目詐欺のトーク力ですごい楽しく聞けました。
「ビジネスサイドの人にリファクタリングとかマイクロサービス化の重要性を説明したので、リファクタリングに成功した」という話があったためか、
リファクタリング後のビジネスサイドのレスポンスを気にする人が多かったように思います。
施策とフィードバックをセットで求めるのは、エンジニアだからかなとか思っちゃいました…。
Webアプリケーションが今こそ知るべき、RDBMSのパフォーマンスチューニングの勘所 ~ 未踏の速度を目指して~
DBの検索方法とそれを踏まえたINDEXの貼り方や、
そもそもSQLを過度に実行しないようにソースコードをしっかり把握しようというお話でした。
DB気になるので参加しましたがLaravel関係なくすっごくためになるセッションでした!
会社でもフレームワークを使っているのですが、
get()などの使用頻度の高い関数については中身を把握しないまま使っていたので、
キチンとどんなSQL文が実行されているか把握しようと思いました。
Laravelのデプロイ戦略。VPSからDocker、Kubernates、サーバレスまで
インフラ周りのお話だと思います。
私にはまだ早かったようで、「メモを取るより考えながら聞いて」とお話が合ったのですが、便利なツールの名前を覚えることで精一杯になってしまいました……。
便利なツールの役割を理解して、しっかり開発製品にあったツールを選定して使えるようになりたいと思いました。
Laravelで学ぶ、ウェブアプリケーションチューニングの基本
「このサイト重い」と言われたとき、
何が原因か、そもそも自分たちが解決できる範囲にあるのか(ウェブアプリの中で「重い」の原因があるのか)を特定する手順について。
そもそもウェブアプリケーションエンジニアである以上、なんとかできる範囲ってとても狭いんだよ、という現実を教えていただきました。
たしかに、ウェブサイトを表示するまでにあらゆる工程がありすぎて、「サイトが重い」なんて雑なコメントじゃ何が原因かわかりっこないですもんね……。
「重い」の原因の特定方法までツールを含めてしっかり説明していただいたので、自社で実践できるように頑張りたいです。
新卒2年目がLaravelコントリビュート出来た理由とその面白さ
コントリビュートって難しくないよ、
例えば、ドキュメント翻訳・issueの追加でもコントリビュート。
やってみたら自分より技術力のあるエンジニアが助けてくれるから、まずは動き出してみようという内容でした。
OSSって言ったら、多くの人が使ってるものだから変なものがコミットされちゃったらまずいんじゃ、と思っていたのですが、
まずはissueで賛否の声をもらえるし、ソースコードに手を加えるとしても、Gitへのプルリクから始まるし、ダメならSTOPされるだけだし、
なんにしても行動してから考えればいいことを教えていただきました。
新卒2年目ということで自分と比較して聞きましたが、
毎日の技術ブログ更新・OSSへのコントリビュートなどはるかに積極的に行動しているなと思いました。
私もアウトプットをもっと頑張ろうと思いました。(Githubからっぽなので…...)
個人的反省。
じつはセッションと並行して、PHPテストワークショップというのが開催されていたのですが、
そしてめっちゃ参加したかったのですが、
ワークショップなのでPCを持ってきている方が対象で、今回は参加できませんでした。
なので、反省① カンファレンスの事前の情報把握が不十分だったこと。
また、Twitterで実況しながらスライドも確認して、気になることは検索して……といろんなことを同時並行でやるのに、スマホ+iPadは微妙だったかもしれません。
なので、反省② カンファレンスにはPC。
PHPカンファレンスでもそう思ったので! (サンプル数2)
持ち運びやすいコンパクトなPCを持っていけるように準備したいと思います。
最後になりますが、今回のセッション以外のカンファレンスまとめを。
参加費は1000円。
懇親会なしの一般参加の枠は250人くらいあったのでしょうか?(自分のチケット番号からの勝手な推測です。)
チケットの販売期間より前に売り切れていたので、次回があれば発売後すぐの購入をオススメします。
私は奇跡的にキャンセル分の再販売を買えました。
TwitterアカウントとTシャツサイズを申し込み時に入力する必要があったのですが、
それは、Twitterアカウント入りの名札・Tシャツの配布のためでした!
来ました!
— Hatsumi (@884_823) February 16, 2019
(アカウント名が技術アカウントじゃないので再ツイートw) pic.twitter.com/1o3CijhHiq
また、たくさんのスポンサーがいらっしゃいまして、
エコバック・無限コーヒー・今半ランチ(人数限定) をゲットすることができました…!
ランチセッション聞けてお弁当もらえて最高 #laraveljpcon pic.twitter.com/H7yjN2npRd
— Hatsumi (@884_823) February 16, 2019
303でかわいいお水もらいました! #laraveljpcon pic.twitter.com/jP9k5ccxXO
— Hatsumi (@884_823) February 16, 2019
なんでタメになる話をきけるのに、いろいろもらっちゃってるんですかね…。
完全に蛇足ですが、こういったことまとめる人あんまりいないかなと思ったので、まとめさせていただきました。
ほんとに、次回開催が決まっていないのが残念です。
次回があったらまた参加したいです!
それとは別に自分の中で、カンファレンスにたくさん参加して知識を身につけたいという思いが強くなったので、
PHP以外のカンファレンスにも参加したいと思います。
Laravelのpublicファイルに合わせてドキュメントルートを変更
Publicディレクトリ
で、ドキュメントルートを変更するように指定があるので、変更します。
su -
cd /etc/httpd/conf
vi httpd.conf
~略~ DocumentRoot "/var/www/html" ~略~ # Further relax access to the default document root: <Directory "/var/www/html"> ~略~
?/var/www/html
で検索すると2箇所見つかると思います。
/var/www/html
を/var/www/html/laravel/public
に置き換えましょう。
~略~ DocumentRoot "/var/www/html/laravel/public" ~略~ # Further relax access to the default document root: <Directory "/var/www/html/laravel/public"> ~略~
systemctl restart httpd
これで http://192.168.33.10/ でLaravelのページが出てくるようになりました。
追記
上記だけだと、Laravelでルート設定をしても新しいページが404エラーになってしまいました……。
mod_rewrite を適用するために httpd.conf を修正 – katz+
<Directory "/">
と
<Directory "/var/www/html/laravel/public">
の
AllowOverride None
を AllowOverride All
に変更してください。
Vagrantで同期するファイルを設定する
ものすごく色々詰まったのですが、ここでは単純な手順メモとして、やるべきことを書いていきますね。
まずはGuest Additions
をVirtualBoxに入れる必要があるようです。
入れないで同期設定をしようとすると、以下のエラーが出ました。
unknown filesystem type 'vboxsf'
手順はこちらを参考にしました。
VirtualBoxのCentos7にGuestAdditionsをインストールする手順 – Linux学習講座
1.は順調にいったのですが
Guest AdditionsのCDイメージ挿入
ここで失敗しました。
メニューのデバイス⇒Guest AdditionsのCDイメージ挿入をクリック
しても、VirtualBox上でエラーが出ます。
しかもエラー文をコピペできず、すごく調べづらい……。
解決方法は、
一度仮想マシンの電源を落とし、VirtualBoxの画面から
設定⇒ストレージ⇒コントローラー:IDE
の横の+マーク付きCDディスク(光学ドライブの追加)を押し、 空のままにする
を選択します。
その後、仮想マシンを再起動し、
メニューのデバイス⇒Guest AdditionsのCDイメージ挿入をクリック
をすることで、Guest Additions
を入れられました!
Guest Additionsのインストール
は手順通りで問題なくできました。 CDイメージなどのメディアをCentOSで使う場合、マウントが必要だというのを初めて知りました…。
ここまでがVirtualBox側の設定です。
次はVagrantの設定をします。
Vagrantを入れた直後に設定した、Vagrantfile
を見直します。
私はC:\Vagrant\centos7\Vagrantfile
に置いてあります。
ローカルにあるので、適当なエディタでconfig.vm.synced_folder
に関する記述を追加します。
初期のVagrantfile
なら、45行目あたりにコメントアウトされてるかと思います。
config.vm.synced_folder "laravel", "/var/www/html/laravel", type: "rsync", rsync__exclude: [ "/storage", "/bootstrap/cache", "/vendor/", ], create: true, owner: "vagrant", group: "vagrant"
config.vm.synced_folder "同期したいローカルフォルダのパス(Vagrantfileからの相対パス)", "同期先となる仮想マシン側のパス"
で設定ができます。
それ以外はオプションで、
type
同期方法
rsync__exclude
除外したいフォルダ
create
同期先に一致するファイルがなければ新規作成するかどうか
owner
,group
同期時の所有者所有グループの名前を何にするか
今回はこれらを設定しました。
そして、コマンドプロンプトから
vagrant reload
error
の文字が出ずに、default
のみで続けば問題なしです!
Vagrantで作った環境だと権限変更してもPermission deniedが出てしまった
※途中で日付設定を変更したのですが、本筋と関係ないので省きます。
本番環境とほぼ同様にLaravel導入できたし、さっそくアクセスするぞ~ととりあえずpublicにアクセスしてみたら
http://192.168.33.10/laravel/public/
The stream or file "/var/www/html/laravel/storage/logs/laravel-2019-01-05.log" could not be opened: failed to open stream: Permission denied
と左上に書かれたページが
この画面はLaravelのエラー画面なので、Laravelを入れることには成功してそうなのですが、
Permission
ということは権限エラー?
ここでいったんLaravelの公式ドキュメントを見てみます。
Laravelをインストールした後に、多少のパーミッションの設定が必要です。storage下とbootstrap/cacheディレクトリをWebサーバから書き込み可能にしてください。設定しないとLaravelは正しく実行されません。Homestead仮想マシンを使用する場合は、あらかじめ設定されています。
なるほど?
指示に従って、storage
とbootstrap/cache
配下をすべて権限変更してみます。
開発環境なので、特定のグループに属していれば書き込み可能としてしまいます。
私の場合はApacheがWebサーバになるので、storage
とbootstrap/cache
の所有グループにapache
を追加してあげればいいはずです。
pwd
/var/www/html/laravel
ll
ll total 444 drwxrwxr-x. 6 vagrant vagrant 4096 Dec 16 18:37 app -rw-rw-r--. 1 vagrant vagrant 1686 Dec 16 18:37 artisan drwxrwxr-x. 3 vagrant vagrant 4096 Dec 16 18:37 bootstrap -rw-rw-r--. 1 vagrant vagrant 1550 Dec 16 18:37 composer.js -rw-rw-r--. 1 vagrant vagrant 177474 Dec 16 18:37 composer.lo drwxrwxr-x. 2 vagrant vagrant 4096 Dec 16 18:37 config drwxrwxr-x. 5 vagrant vagrant 4096 Dec 16 18:37 database -rw-rw-r--. 1 vagrant vagrant 1125 Dec 16 18:37 package.jso -rw-rw-r--. 1 vagrant vagrant 1138 Dec 16 18:37 phpunit.xml drwxrwxr-x. 5 vagrant vagrant 4096 Dec 16 18:37 public drwxrwxr-x. 6 vagrant vagrant 4096 Dec 16 18:37 resources drwxrwxr-x. 2 vagrant vagrant 4096 Dec 16 18:37 routes -rw-rw-r--. 1 vagrant vagrant 563 Dec 16 18:37 server.php drwxr-xr-x. 5 vagrant vagrant 4096 Dec 16 18:37 storage drwxrwxr-x. 4 vagrant vagrant 4096 Dec 16 18:37 tests drwxrwxr-x. 45 vagrant vagrant 4096 Dec 16 18:45 vendor -rw-rw-r--. 1 vagrant vagrant 537 Dec 16 18:37 webpack.mix -rw-rw-r--. 1 vagrant vagrant 205286 Dec 16 18:37 yarn.lock
storage
とbootstrap/cache
の所有グループはvagrant
のようですね。
では、apache
の所属グループを確認してみましょう。
groups apache
apache : apache
apache
グループのみのようなのでvagrant
を追加します。
usermod -aG apache vagrant
groups apache
apache : apache vagrant
最後に、所有グループにも書き込み権限を付与します。
sudo chmod -R 775 bootstrap/cache/
sudo chmod -R 775 storage
ll
以下抜粋
drwxrwxr-x. 3 vagrant vagrant 4096 Dec 17 03:37 bootstrap drwxrwxr-x. 5 vagrant vagrant 4096 Dec 17 03:37 storage
権限変わってますね!
これで当初の権限エラーも直ってるはず!
と
思っていたのですが、
The stream or file "/var/www/html/laravel/storage/logs/laravel-2019-01-05.log" could not be opened: failed to open stream: Permission denied
同じエラーが出ます。
もしかするとVagrantで共有フォルダをしっかり決めていないことが原因?と思ったので、次の記事に続きます。
解決方法までまとめられずに申し訳ありません……。
追記
CentOS7.4上でLaravelプロジェクトを動かすための環境を作る - Qiita
こちらの記事の手順で実行することで、成功しました…!
ありがとうございます。
chcon
コマンドが大切なようですね……。
詳しいことが分かり次第、別記事でまとめます。
composerの移動先を間違えたときの話
ローカル開発環境のVagrant+VirtualBoxで作ったCentOSの
/var/www/html/
配下にLaravelを入れようとして格闘したのでメモします。
結論から言うと、
composer.phar
を/usr/local/bin/composer
に名前変更
mv composer.phar /usr/local/bin/composer
するのではなく、
mv composer.phar /usr/local/bin/composer/composer.phar
と、composerディレクトリをつくってその配下に移動してしまったこと が原因です。
以下、調査方法です。
cd \var\www\html
laravel new laravel
Crafting application... PHP Warning: file_put_contents(/var/www/html/laravel_591a618f398466590af59573919f776f.zip): failed to open stream: Permission denied in /home/vagrant/.config/composer/vendor/laravel/installer/src/NewCommand.php on line 133 PHP Warning: ZipArchive::extractTo(): Permission denied in /home/vagrant/.config/composer/vendor/laravel/installer/src/NewCommand.php on line 151 PHP Warning: ZipArchive::close(): Invalid or uninitialized Zip object in /home/vagrant/.config/composer/vendor/laravel/installer/src/NewCommand.php on line 153 You should verify that the "storage" and "bootstrap/cache" directories are writable. In Process.php line 334: The provided cwd does not exist. new [--dev] [--force] [--] [<name>]
composer周りでエラーが出た模様?
とりあえず権限を確認しました。
pwd
/var/www
ll
ll total 8 drwxr-xr-x. 2 root root 4096 Jun 27 13:49 cgi-bin drwxr-xr-x. 2 root root 4096 Jun 27 13:49 html
chown vagrant:vagrant html
chown: changing ownership of ‘html’: Operation not permitted
権限変更の権限がないと出たのでsudo
を使います。
sudo chown vagrant:vagrant html
ll
total 8 drwxr-xr-x. 2 root root 4096 Jun 27 13:49 cgi-bin drwxr-xr-x. 2 vagrant vagrant 4096 Jun 27 13:49 html
改めてLaravelを入れようと思います。
cd html/
laravel new laravel
Crafting application... sh: composer: command not found Application ready! Build something amazing.
ls
laravel
入ったは入ったけど、composerコマンドがないといわれてる…?
pwd
/usr/local/bin/composer
php composer.phar -V
Composer version 1.8.0 2018-12-03 10:31:16
それなら、直接php composer.phar
をたたいてやれ!と(Laravel用のファイルはあとで移動しようと思ってました)
php composer.phar global create-project --prefer-dist laravel/laravel laravel "5.7.*"
Changed current directory to /home/vagrant/.config/composer The "https://repo.packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed Failed to enable crypto failed to open stream: operation failed https://repo.packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date [Composer\Downloader\TransportException] The "https://packagist.org/p/laravel/laravel%243bc08c6b87557c6612c4ffd6e23bd5099550031af06600dc0e757449c cbea91d.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed Failed to enable crypto failed to open stream: operation failed create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]
composer global create-project
コマンドを使うためには、OpenSSLが必要っぽい…?ですね。
ローカル環境にはちょっと難しく見えたのでここで断念。
このあたりで、冒頭でcomposerの移動先を間違えたことに気が付きました…。
composer周りのミスに気が付いたところで、改めてlaravelコマンドを実行してみましょう。
laravel new laravel/
-bash: laravel: command not found
laravel コマンドがないといわれてます……ナンデ。
echo $PATH
/home/vagrant/.config/composer/vender/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/vagrant/.local/bin:/home/vagrant/bin
ll /home/vagrant/.config/composer/vendor/bin/
total 0 lrwxrwxrwx. 1 vagrant vagrant 28 Dec 16 15:33 laravel -> ../laravel/installer/laravel
パスも間違いなく通ってるように見えるのですが…。
今回は細かい原因追及をやめ、直叩きで実行できないか確認してみます。
/home/vagrant/.config/composer/vendor/bin/laravel -V
Laravel Installer 2.0.1
直叩きならうまくいってますね。今回はこちらでいきます。
cd /var/www/html/
/home/vagrant/.config/composer/vendor/bin/laravel new laravel
Crafting application... Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 86 installs, 0 updates, 0 removals ~略~ Application ready! Build something amazing.
ls
laravel
ようやく…ようやくできました…。
本番環境ではblog
ディレクトリでLaravelを入れてしまったので、開発環境で作ってるものがリリースされる時に修正しようと思います。
CentOS7.6を7.5にダウングレード&7.5に固定
本番環境に合わせて、CentOS7.5を基準に動くつもりが、
開発環境だけ7.6にしてしまったので、その修正と、CentOSのバージョン固定をしたいと思います。
こちらのサイトを参考にさせていただきました。
su -
cd /etc/yum.repos.d
cp CentOS-Base.repo CentOS-Base.repo.orig
vi CentOS-Base.repo
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$inf ra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ~以下略~
こんな感じで、CentOSのことばかり書いてあるファイルを編集します。
7.5の正しいバージョン名?を確認したところ7.5.1804
でした。
$SHELL -c "echo 7.5.1804 > /etc/yum/vars/releasever"
これでバージョン名と同じreleaseverファイルができました。
そのうえでリポジトリの参照先を変えるために、以下のコマンドを打ちました。
vi CentOS-Base.repo
:%s/mirrorlist=/#millorlist=/g
:%s/#baseurl/baseurl/g
:%s/mirror.centos/vault.centos/g
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$in fra baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infr a=$infra baseurl=http://vault.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ~以下略~
正直ここまで手探り状態なのですが、開発環境ですし、あとはなるようになれでやってみます!!!
yum clean all
Loaded plugins: fastestmirror Cleaning repos: base extras updates
これでyumのキャッシュがクリアされるそうです。
そしてダウングレード。
yum distribution-synchronization
~前略~ Error: Trying to remove "systemd", which is protected
systemdを消さなきゃいけないんですね…。
systemdってなんだ?と思ったのですが、参考サイトのほうでそこまで網羅していました。すごい。
mv /etc/yum/protected.d/systemd.conf /etc/yum/protected.d/systemd.conf.bak
このコマンドでsystemdをバックアップファイルに変更して、systemdをなかったことにできました。
改めて
yum distribution-synchronization
~前略~ Removed: GeoIP.x86_64 0:1.5.0-13.el7 NetworkManager.x86_64 1:1.12.0-8.el7_6 NetworkManager-libnm.x86_64 1:1.12.0-8.el7_6 NetworkManager-team.x86_64 1:1.12.0-8.el7_6 NetworkManager-tui.x86_64 1:1.12.0-8.el7_6 audit.x86_64 0:2.8.4-4.el7 audit-libs.x86_64 0:2.8.4-4.el7 bash.x86_64 0:4.2.46-31.el7 bind-libs-lite.x86_64 32:9.9.4-72.el7 bind-license.noarch 32:9.9.4-72.el7 binutils.x86_64 0:2.27-34.base.el7 centos-release.x86_64 0:7-6.1810.2.el7.centos coreutils.x86_64 0:8.22-23.el7 cronie.x86_64 0:1.4.11-20.el7_6 cronie-anacron.x86_64 0:1.4.11-20.el7_6 cryptsetup-libs.x86_64 0:2.0.3-3.el7 curl.x86_64 0:7.29.0-51.el7 dbus.x86_64 1:1.10.24-12.el7 dbus-libs.x86_64 1:1.10.24-12.el7 device-mapper.x86_64 7:1.02.149-10.el7_6.2 device-mapper-libs.x86_64 7:1.02.149-10.el7_6.2 dmidecode.x86_64 1:3.1-2.el7 dracut.x86_64 0:033-554.el7 e2fsprogs-libs.x86_64 0:1.42.9-13.el7 elfutils-default-yama-scope.noarch 0:0.172-2.el7 elfutils-libelf.x86_64 0:0.172-2.el7 elfutils-libs.x86_64 0:0.172-2.el7 ethtool.x86_64 2:4.8-9.el7 file.x86_64 0:5.11-35.el7 file-libs.x86_64 0:5.11-35.el7 findutils.x86_64 1:4.5.11-6.el7 firewalld.noarch 0:0.5.3-5.el7 firewalld-filesystem.noarch 0:0.5.3-5.el7 freetype.x86_64 0:2.8-12.el7 fuse.x86_64 0:2.9.2-11.el7 fuse-libs.x86_64 0:2.9.2-11.el7 glib2.x86_64 0:2.56.1-2.el7 glibc.x86_64 0:2.17-260.el7 glibc-common.x86_64 0:2.17-260.el7 gobject-introspection.x86_64 0:1.56.1-1.el7 grub2.x86_64 1:2.02-0.76.el7.centos grub2-common.noarch 1:2.02-0.76.el7.centos grub2-pc.x86_64 1:2.02-0.76.el7.centos grub2-pc-modules.noarch 1:2.02-0.76.el7.centos grub2-tools.x86_64 1:2.02-0.76.el7.centos grub2-tools-extra.x86_64 1:2.02-0.76.el7.centos grub2-tools-minimal.x86_64 1:2.02-0.76.el7.centos grubby.x86_64 0:8.28-25.el7 gssproxy.x86_64 0:0.7.0-21.el7 hwdata.x86_64 0:0.252-9.1.el7 hyperv-daemons.x86_64 0:0-0.34.20180415git.el7 hyperv-daemons-license.noarch 0:0-0.34.20180415git.el7 hypervfcopyd.x86_64 0:0-0.34.20180415git.el7 hypervkvpd.x86_64 0:0-0.34.20180415git.el7 hypervvssd.x86_64 0:0-0.34.20180415git.el7 initscripts.x86_64 0:9.49.46-1.el7 iprutils.x86_64 0:2.4.16.1-1.el7 ipset.x86_64 0:6.38-3.el7_6 ipset-libs.x86_64 0:6.38-3.el7_6 iptables.x86_64 0:1.4.21-28.el7 kbd.x86_64 0:1.15.5-15.el7 kbd-legacy.noarch 0:1.15.5-15.el7 kbd-misc.noarch 0:1.15.5-15.el7 kernel.x86_64 0:3.10.0-957.1.3.el7 kernel-tools.x86_64 0:3.10.0-957.1.3.el7 kernel-tools-libs.x86_64 0:3.10.0-957.1.3.el7 kmod.x86_64 0:20-23.el7 kmod-libs.x86_64 0:20-23.el7 kpartx.x86_64 0:0.4.9-123.el7 krb5-libs.x86_64 0:1.15.1-34.el7 libbasicobjects.x86_64 0:0.1.1-32.el7 libblkid.x86_64 0:2.23.2-59.el7 libcollection.x86_64 0:0.7.0-32.el7 libcom_err.x86_64 0:1.42.9-13.el7 libcroco.x86_64 0:0.6.12-4.el7 libcurl.x86_64 0:7.29.0-51.el7 libdrm.x86_64 0:2.4.91-3.el7 libfastjson.x86_64 0:0.99.4-3.el7 libgcc.x86_64 0:4.8.5-36.el7 libgomp.x86_64 0:4.8.5-36.el7 libicu.x86_64 0:50.1.2-17.el7 libini_config.x86_64 0:1.3.1-32.el7 libldb.x86_64 0:1.3.4-1.el7 libmount.x86_64 0:2.23.2-59.el7 libmspack.x86_64 0:0.5-0.6.alpha.el7 libpath_utils.x86_64 0:0.2.1-32.el7 libref_array.x86_64 0:0.1.5-32.el7 libselinux.x86_64 0:2.5-14.1.el7 libselinux-python.x86_64 0:2.5-14.1.el7 libselinux-utils.x86_64 0:2.5-14.1.el7 libsemanage.x86_64 0:2.5-14.el7 libsepol.x86_64 0:2.5-10.el7 libssh2.x86_64 0:1.4.3-12.el7 libstdc++.x86_64 0:4.8.5-36.el7 libtalloc.x86_64 0:2.1.13-1.el7 libteam.x86_64 0:1.27-5.el7 libtevent.x86_64 0:0.9.36-1.el7 libtirpc.x86_64 0:0.2.4-0.15.el7 libuuid.x86_64 0:2.23.2-59.el7 libwbclient.x86_64 0:4.8.3-4.el7 linux-firmware.noarch 0:20180911-69.git85c5d90.el7 logrotate.x86_64 0:3.8.6-17.el7 man-db.x86_64 0:2.6.3-11.el7 nfs-utils.x86_64 1:1.3.0-0.61.el7 nss-pem.x86_64 0:1.0.3-5.el7 open-vm-tools.x86_64 0:10.2.5-3.el7 openldap.x86_64 0:2.4.44-20.el7 openssl.x86_64 1:1.0.2k-16.el7 openssl-libs.x86_64 1:1.0.2k-16.el7 policycoreutils.x86_64 0:2.5-29.el7 polkit.x86_64 0:0.112-18.el7 postfix.x86_64 2:2.10.1-7.el7 procps-ng.x86_64 0:3.3.10-23.el7 python.x86_64 0:2.7.5-76.el7 python-firewall.noarch 0:0.5.3-5.el7 python-libs.x86_64 0:2.7.5-76.el7 python-linux-procfs.noarch 0:0.4.9-4.el7 python-perf.x86_64 0:3.10.0-957.1.3.el7 python-urlgrabber.noarch 0:3.10-9.el7 qemu-guest-agent.x86_64 10:2.12.0-2.el7 rpcbind.x86_64 0:0.2.0-47.el7 rpm.x86_64 0:4.11.3-35.el7 rpm-build-libs.x86_64 0:4.11.3-35.el7 rpm-libs.x86_64 0:4.11.3-35.el7 rpm-python.x86_64 0:4.11.3-35.el7 rsyslog.x86_64 0:8.24.0-34.el7 samba-client-libs.x86_64 0:4.8.3-4.el7 samba-common.noarch 0:4.8.3-4.el7 samba-common-libs.x86_64 0:4.8.3-4.el7 selinux-policy.noarch 0:3.13.1-229.el7_6.6 selinux-policy-targeted.noarch 0:3.13.1-229.el7_6.6 setup.noarch 0:2.8.71-10.el7 sg3_utils.x86_64 0:1.37-17.el7 sg3_utils-libs.x86_64 0:1.37-17.el7 shadow-utils.x86_64 2:4.1.5.1-25.el7 sudo.x86_64 0:1.8.23-3.el7 systemd.x86_64 0:219-62.el7 systemd-libs.x86_64 0:219-62.el7 systemd-sysv.x86_64 0:219-62.el7 tar.x86_64 2:1.26-35.el7 teamd.x86_64 0:1.27-5.el7 tuned.noarch 0:2.10.0-6.el7 tzdata.noarch 0:2018g-1.el7 util-linux.x86_64 0:2.23.2-59.el7 vim-minimal.x86_64 2:7.4.160-5.el7 wpa_supplicant.x86_64 1:2.6-12.el7 xfsprogs.x86_64 0:4.5.0-18.el7 yum.noarch 0:3.4.3-161.el7.centos yum-plugin-fastestmirror.noarch 0:1.1.31-50.el7 yum-utils.noarch 0:1.1.31-50.el7 zlib.x86_64 0:1.2.7-18.el7 Installed: GeoIP.x86_64 0:1.5.0-11.el7 NetworkManager.x86_64 1:1.10.2-16.el7_5 NetworkManager-libnm.x86_64 1:1.10.2-16.el7_5 NetworkManager-team.x86_64 1:1.10.2-16.el7_5 NetworkManager-tui.x86_64 1:1.10.2-16.el7_5 audit.x86_64 0:2.8.1-3.el7_5.1 audit-libs.x86_64 0:2.8.1-3.el7_5.1 bash.x86_64 0:4.2.46-30.el7 bind-libs-lite.x86_64 32:9.9.4-61.el7_5.1 bind-license.noarch 32:9.9.4-61.el7_5.1 binutils.x86_64 0:2.27-28.base.el7_5.1 centos-release.x86_64 0:7-5.1804.5.el7.centos coreutils.x86_64 0:8.22-21.el7 cronie.x86_64 0:1.4.11-19.el7 cronie-anacron.x86_64 0:1.4.11-19.el7 cryptsetup-libs.x86_64 0:1.7.4-4.el7 curl.x86_64 0:7.29.0-46.el7 dbus.x86_64 1:1.10.24-7.el7 dbus-libs.x86_64 1:1.10.24-7.el7 device-mapper.x86_64 7:1.02.146-4.el7 device-mapper-libs.x86_64 7:1.02.146-4.el7 dmidecode.x86_64 1:3.0-5.el7 dracut.x86_64 0:033-535.el7_5.1 e2fsprogs-libs.x86_64 0:1.42.9-12.el7_5 elfutils-default-yama-scope.noarch 0:0.170-4.el7 elfutils-libelf.x86_64 0:0.170-4.el7 elfutils-libs.x86_64 0:0.170-4.el7 ethtool.x86_64 2:4.8-7.el7 file.x86_64 0:5.11-33.el7 file-libs.x86_64 0:5.11-33.el7 findutils.x86_64 1:4.5.11-5.el7 firewalld.noarch 0:0.4.4.4-15.el7_5 firewalld-filesystem.noarch 0:0.4.4.4-15.el7_5 freetype.x86_64 0:2.4.11-15.el7 fuse.x86_64 0:2.9.2-10.el7 fuse-libs.x86_64 0:2.9.2-10.el7 glib2.x86_64 0:2.54.2-2.el7 glibc.x86_64 0:2.17-222.el7 glibc-common.x86_64 0:2.17-222.el7 gobject-introspection.x86_64 0:1.50.0-1.el7 grub2.x86_64 1:2.02-0.65.el7.centos.2 grub2-common.noarch 1:2.02-0.65.el7.centos.2 grub2-pc.x86_64 1:2.02-0.65.el7.centos.2 grub2-pc-modules.noarch 1:2.02-0.65.el7.centos.2 grub2-tools.x86_64 1:2.02-0.65.el7.centos.2 grub2-tools-extra.x86_64 1:2.02-0.65.el7.centos.2 grub2-tools-minimal.x86_64 1:2.02-0.65.el7.centos.2 grubby.x86_64 0:8.28-23.el7 gssproxy.x86_64 0:0.7.0-17.el7 hwdata.x86_64 0:0.252-8.8.el7 hyperv-daemons.x86_64 0:0-0.32.20161211git.el7 hyperv-daemons-license.noarch 0:0-0.32.20161211git.el7 hypervfcopyd.x86_64 0:0-0.32.20161211git.el7 hypervkvpd.x86_64 0:0-0.32.20161211git.el7 hypervvssd.x86_64 0:0-0.32.20161211git.el7 initscripts.x86_64 0:9.49.41-1.el7_5.2 iprutils.x86_64 0:2.4.15.1-1.el7 ipset.x86_64 0:6.29-1.el7 ipset-libs.x86_64 0:6.29-1.el7 iptables.x86_64 0:1.4.21-24.1.el7_5 kbd.x86_64 0:1.15.5-13.el7 kbd-legacy.noarch 0:1.15.5-13.el7 kbd-misc.noarch 0:1.15.5-13.el7 kernel-tools.x86_64 0:3.10.0-862.14.4.el7 kernel-tools-libs.x86_64 0:3.10.0-862.14.4.el7 kmod.x86_64 0:20-21.el7 kmod-libs.x86_64 0:20-21.el7 kpartx.x86_64 0:0.4.9-119.el7_5.1 krb5-libs.x86_64 0:1.15.1-19.el7 libbasicobjects.x86_64 0:0.1.1-29.el7 libblkid.x86_64 0:2.23.2-52.el7_5.1 libcollection.x86_64 0:0.7.0-29.el7 libcom_err.x86_64 0:1.42.9-12.el7_5 libcroco.x86_64 0:0.6.11-1.el7 libcurl.x86_64 0:7.29.0-46.el7 libdrm.x86_64 0:2.4.83-2.el7 libfastjson.x86_64 0:0.99.4-2.el7 libgcc.x86_64 0:4.8.5-28.el7_5.1 libgomp.x86_64 0:4.8.5-28.el7_5.1 libicu.x86_64 0:50.1.2-15.el7 libini_config.x86_64 0:1.3.1-29.el7 libldb.x86_64 0:1.2.2-1.el7 libmount.x86_64 0:2.23.2-52.el7_5.1 libmspack.x86_64 0:0.5-0.5.alpha.el7 libpath_utils.x86_64 0:0.2.1-29.el7 libref_array.x86_64 0:0.1.5-29.el7 libselinux.x86_64 0:2.5-12.el7 libselinux-python.x86_64 0:2.5-12.el7 libselinux-utils.x86_64 0:2.5-12.el7 libsemanage.x86_64 0:2.5-11.el7 libsepol.x86_64 0:2.5-8.1.el7 libssh2.x86_64 0:1.4.3-10.el7_2.1 libstdc++.x86_64 0:4.8.5-28.el7_5.1 libtalloc.x86_64 0:2.1.10-1.el7 libteam.x86_64 0:1.27-4.el7 libtevent.x86_64 0:0.9.33-2.el7 libtirpc.x86_64 0:0.2.4-0.10.el7 libuuid.x86_64 0:2.23.2-52.el7_5.1 libwbclient.x86_64 0:4.7.1-9.el7_5 linux-firmware.noarch 0:20180220-62.2.git6d51311.el7_5 logrotate.x86_64 0:3.8.6-15.el7 man-db.x86_64 0:2.6.3-9.el7 nfs-utils.x86_64 1:1.3.0-0.54.el7 nss-pem.x86_64 0:1.0.3-4.el7 open-vm-tools.x86_64 0:10.1.10-3.el7_5.1 openldap.x86_64 0:2.4.44-15.el7_5 openssl.x86_64 1:1.0.2k-12.el7 openssl-libs.x86_64 1:1.0.2k-12.el7 policycoreutils.x86_64 0:2.5-22.el7 polkit.x86_64 0:0.112-14.el7 postfix.x86_64 2:2.10.1-6.el7 procps-ng.x86_64 0:3.3.10-17.el7_5.2 python.x86_64 0:2.7.5-69.el7_5 python-firewall.noarch 0:0.4.4.4-15.el7_5 python-libs.x86_64 0:2.7.5-69.el7_5 python-linux-procfs.noarch 0:0.4.9-3.el7 python-perf.x86_64 0:3.10.0-862.14.4.el7 python-urlgrabber.noarch 0:3.10-8.el7 qemu-guest-agent.x86_64 10:2.8.0-2.el7_5.1 rpcbind.x86_64 0:0.2.0-44.el7 rpm.x86_64 0:4.11.3-32.el7 rpm-build-libs.x86_64 0:4.11.3-32.el7 rpm-libs.x86_64 0:4.11.3-32.el7 rpm-python.x86_64 0:4.11.3-32.el7 rsyslog.x86_64 0:8.24.0-16.el7_5.4 samba-client-libs.x86_64 0:4.7.1-9.el7_5 samba-common.noarch 0:4.7.1-9.el7_5 samba-common-libs.x86_64 0:4.7.1-9.el7_5 selinux-policy.noarch 0:3.13.1-192.el7_5.6 selinux-policy-targeted.noarch 0:3.13.1-192.el7_5.6 setup.noarch 0:2.8.71-9.el7 sg3_utils.x86_64 0:1.37-12.el7 sg3_utils-libs.x86_64 0:1.37-12.el7 shadow-utils.x86_64 2:4.1.5.1-24.el7 sudo.x86_64 0:1.8.19p2-14.el7_5 systemd.x86_64 0:219-57.el7_5.3 systemd-libs.x86_64 0:219-57.el7_5.3 systemd-sysv.x86_64 0:219-57.el7_5.3 tar.x86_64 2:1.26-34.el7 teamd.x86_64 0:1.27-4.el7 tuned.noarch 0:2.9.0-1.el7_5.2 tzdata.noarch 0:2018f-2.el7 util-linux.x86_64 0:2.23.2-52.el7_5.1 vim-minimal.x86_64 2:7.4.160-4.el7 wpa_supplicant.x86_64 1:2.6-9.el7 xfsprogs.x86_64 0:4.5.0-15.el7 yum.noarch 0:3.4.3-158.el7.centos yum-plugin-fastestmirror.noarch 0:1.1.31-46.el7_5 yum-utils.noarch 0:1.1.31-46.el7_5 zlib.x86_64 0:1.2.7-17.el7 Complete!
ものすごい長い実行結果が出てきたのでかいつまんでいます。
最後にもう一度CentOSのバージョンを確認。
cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
今度こそ問題なさそうですね!
"CentOS7"でLaravelの開発環境を作成
開発環境は本番環境とほぼ同じじゃなきゃ意味ないですよね…。
Laravel公式HPのオススメに従ってHomesteadを入れてみましたが
あれはUbuntuがOSで、
私は先に本番環境としてVPSにCentOSをインストールしちゃってるので、不適切でした。
今更ですが開発環境を最初から作り直します。
qiita.com
こちらのサイトを参考にさせていただきました。
まずは自分のPCからコマンドプロンプトを起動して、適当なところで以下のコマンドをポチ。
vagrant -v
Vagrant 2.1.5
Vagrantインストール済みなのが確認できました。
次は私の本番環境と同じCentos7のVagrantを見つけられるか。 app.vagrantup.com
こちらのサイトですでに出来上がってるboxファイルを検索することができます。
ありましたね!
このページのNewタブのコマンドを打つとboxをインストールできるようです。
私はC直下にvagrant専用のフォルダを作ってインストールしました。
C:\Vagrant\centos7
cd Vagrant/centos7
vagrant init centos/7
==> vagrant: A new version of Vagrant is available: 2.2.1 (installed version: 2.1.5)! ==> vagrant: To upgrade visit: https://www.vagrantup.com/downloads.html 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が出来上がったようです!
エクスプローラーから確認し、適当なテキストエディタでVagrantfileを編集します。
# -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("2") do |config| # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. # Every Vagrant development environment requires a box. You can search for # boxes at https://vagrantcloud.com/search. config.vm.box = "centos/7" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs # `vagrant box outdated`. This is not recommended. # config.vm.box_check_update = false # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # NOTE: This will enable public access to the opened port # config.vm.network "forwarded_port", guest: 80, host: 8080 # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine and only allow access # via 127.0.0.1 to disable public access # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" # 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" # Create a public network, which generally matched to bridged network. # Bridged networks make the machine appear as another physical device on # your network. # config.vm.network "public_network" # Share an additional folder to the guest VM. The first argument is # the path on the host to the actual folder. The second argument is # the path on the guest to mount the folder. And the optional third # argument is a set of non-required options. # config.vm.synced_folder "../data", "/vagrant_data" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. # Example for VirtualBox: # # config.vm.provider "virtualbox" do |vb| # # Display the VirtualBox GUI when booting the machine # vb.gui = true # # # Customize the amount of memory on the VM: # vb.memory = "1024" # end # # View the documentation for the provider you are using for more # information on available options. # Enable provisioning with a shell script. Additional provisioners such as # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # documentation for more information about their specific syntax and use. # config.vm.provision "shell", inline: <<-SHELL # apt-get update # apt-get install -y apache2 # SHELL end
vagrant up
Bringing machine 'default' up with 'virtualbox' provider... ==> default: Box 'centos/7' could not be found. Attempting to find and install... default: Box Provider: virtualbox default: Box Version: >= 0 ==> default: Loading metadata for box 'centos/7' default: URL: https://vagrantcloud.com/centos/7 ==> default: Adding box 'centos/7' (v1809.01) for provider: virtualbox default: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1809.01/providers/virtualbox.box default: Download redirected to host: cloud.centos.org default: ==> default: Successfully added box 'centos/7' (v1809.01) for 'virtualbox'! ==> default: Importing base box 'centos/7'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'centos/7' is up to date... ==> default: Setting the name of the VM: centos7_default_1542441826237_51318 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> 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: Machine booted and ready! ==> default: Checking for guest additions in VM... default: No guest additions were detected on the base box for this VM! Guest default: additions are required for forwarded ports, shared folders, host only default: networking, and more. If SSH fails on this machine, please install default: the guest additions and repackage the box to continue. default: default: This is not an error message; everything may continue to work properly, default: in which case you may ignore this message. ==> default: Configuring and enabling network interfaces... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key ==> default: Rsyncing folder: /cygdrive/c/Vagrant/centos7/ => /vagrant
インストール完了のようです。
vagrantの中にあるboxを一覧で出すコマンドを打ってみます。
vagrant box list
centos/7 (virtualbox, 1809.01) laravel/homestead (virtualbox, 6.3.0)
これでようやく、
開発用のサーバーを用意することができました。
ここからはまた本番環境でいれたものと同じもの入れこむ作業になりますね。
cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
あ、あれ…。CentOS7.6で作っちゃってるみたいですね……。
今さっきyumの一括アップデートをしてしまった気がします。
次はダウングレードのやり方からですね……。