Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
レンサバけもの道
Search
uzulla
February 10, 2020
Technology
2
2.9k
レンサバけもの道
uzulla
2020-02-10 PHPerKaigi 2020 day 1
uzulla
February 10, 2020
Tweet
Share
More Decks by uzulla
See All by uzulla
More Context, Better Code. 既存コードやOAS等をコンテキストとしてLLMに与える事で、よりよいコード生成を行う話
uzulla
1
100
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
3
170
セッションのトークセッション / Traps for PHP session features in growing web apps
uzulla
2
110
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
5
2k
例外を投げるのをやめてみないか? あるいは受け入れてみないか? - How to use exceptions other than throwing
uzulla
4
890
PHPerが ISUCONでやるべき事
uzulla
1
840
開発生産性は上がらない - N Ways to Reduce Development Productivity
uzulla
1
220
test is not a job
uzulla
1
490
あなたのPHPアプリ、ログはでてますか?あるいはログをだしてますか? / Are you writing a log? Or just out a log?
uzulla
17
7.4k
Other Decks in Technology
See All in Technology
飲食店データの分析事例とそれを支えるデータ基盤
kimujun
0
190
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
420
Terraform Stacks入門 #HashiTalks
msato
0
360
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
SSMRunbook作成の勘所_20241120
koichiotomo
3
160
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
2
230
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
180
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
550
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
340
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Site-Speed That Sticks
csswizardry
0
31
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
The Pragmatic Product Professional
lauravandoore
31
6.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Navigating Team Friction
lara
183
14k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Thoughts on Productivity
jonyablonski
67
4.3k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Transcript
Ϩϯαό͚ͷಓ
None
uzulla Hachioji.pm ʮϝʔϧϑΥʔϜΛॻ͍ͯΒ͍ͯͨ͠ʯ
ϨϯαόͬͯΔਓʁ (ڍखئ͍·͢) (༐ؾͷࢦඪ)
Ϩϯαόͬͨࣄͳ͍ਓʁ (ڍखئ͍·͢) (ͲΕ͘Β͍ϚδτʔϯͰ͖͔͢ࢦඪ)
ʮϨϯαό͚ͷಓʯͱʁ • ! "࡞๏"ແࢹ͢Δ • " ϞμϯʢϞμϯͱʁʣΑΓʹ͢Δ • # ۀऀ͕ʮΑ͠ʯͱ͠ͳ͍Մೳੑ͕͋Γ·͢
• ϨϯαόͰґଘͤ͞ͳ͍ʮී௨ʯΛ
• "ڐՄΛಘΔͳɺँࡑͤΑ" • (அΒͳ͍͕ҟ༷ͳͷͰڐՄͮ͠Β͍) • DISCRAIMER • ! At your
OWN risk. !
͝ଘϨϯαόͱʁ • (جຊ)ߴूLAMPɺrootݖݶͳ͠ • Pros • ʢVHෳ࡞ΔͳΒʣ҆ͯ͘ཧෆཁ ϝʔϧͱDNS͕͍ͭͯ͘Δ • Cons
• ݹͯ͘༥௨͕͖͔ͳ͍ˍṖͷ࡞๏ DNS͕͍͖ͭͯͪΌ͏
ฏ͍ͨ͘͏ͱ • PaaSͱ͔VHҰݸʹ̍ܖͰ͔͍ͨʂ • ಛʹɺ༡ͼͷίʔυΛಈ͔͓ͯ͘͠ͱ͔ • ͏OSɾϛυϧΣΞอक໘ • ͍͏΄Ͳrootݖݶ͍ΒΜͳ… ʢ˞ݸਓͷײʣ
• ʢC֦ு͔ͭΘͳ͍ͳΒʣ
Netlify… • DNSͳͲผʹඞཁ • GitωΠςΟϒɺઃఆ͕(ࣝ͋Ε)Ұॠ • ͔͍͍ͬ͜ • VHҰͭͰ̍ܖ •
ʮGitHub PagesͰ͍͍ͷͰʁʯ • PHP͏͔͝ͳ͍ !
Heroku… • (ͪΌΜͱॻ͚)εέʔϧΞτͰ͖Δ • ϛυϧΣΞ͕๛ • σϕϩούʔϑϨϯυϦʔ • ENV͕ݸผʹઃఆ͍͢͠ •
͔͍͍ͬ͜ • VHҰͭͰ̍ܖ
Ϩϯαό… • εέʔϧΞτͰ͖ͳ͍ • ͍ʢॾઆ͋Δʣ • VHͨ͘͞Μͭͬͯ͘ఆֹʂ • DBͨ͘͞Μͭͬͯ͘ఆֹʂ •
(ϓϥϯʹΑΓ·͢) • ཧը໘ϙνϙνˍͭͩ͠͠Δ͍
ۙͷϨϯαό • ࣮࣭WordPressʢCMSʣ༻ڥ • ʮWPಈ͚͑͑Ζʯͱ͍͏Կ͔͕ݟ͑Δ • WP͕ʮਅ໘ʯͰҾ͖ͣΒΕ͍ͯΔ(?) • → ݁ՌతʹPHPͷόʔδϣϯ͕Ξοϓ͍ͯ͠Δ
• → ͳͲओு࢝͠Ίͨ
ࢲͱϨϯαόͷ͖߹͍ • ࣄͰWordPress • ࣄͰCMS(OSS/ಠࣗ) • ࣄͰϖϥΠνɾίʔϙϨʔταΠτ • ϝʔϧαʔόʔ •
झຯͰ࣮ݧɾ։ൃɾσϞͳͲ
ॴͰϨϯαό • ࣮ʢେʣsshͰ͖Δ • ཧ༝ʢधཁʣෆ໌ɺҰ෦ͷϨϯαό͕ੲ͔Β Ͱ͖ͨͷͰԣฒͼͷͨΊʁ • Ͳ͜ʮࣗݾʯͱ໌ه
• sshͰ͖ͳ͍Ϩϯαόආ͚Δ • ແྉϨϯαό • ҆Ձϓϥϯ • ʮΕ͖͋͠ΔΏ͍͠ΐ͋Δۀऀʯ •
͜ΕΒͷ͍Έͪແ͍ʢภݟʣ
Φν • SSH͏ɺNO MORE FTP • ϞμϯͳσϓϩΠΛ͢Δ • ʮʯΛ͢Δ •
Τϥʔ • ϩά • ͜ΕͰେ׆༻ʂ
sshɾγΣϧ
݁ɿ ͓͏ʂʂʂ • ࠓͲ͜Ͱ͋Δ(࠷ͷϓϥϯͰͳ͚Ε) • ͭΒ͞ͷׂ̑γΣϧΛఘΊΔ͜ͱʹ͋Δ • Τϥʔϩά͕tail -fͰ͖Δ͚ͩͰҧ͏
ٯʹΞϯνύλʔϯʮFTPࣗಈԽʯ • ʢ҉߸Խͱ͔Ҏલʹʣ • ਗ਼͘ਖ਼͍͕͠ɺແବͰ͢(ݸਓͷओு) • ͦͷಓམͱ݀͠ʹ௨͍ͯ͡Δ • ଞͷڥͱͷϫʔΫϑϩʔ͕ͣΕ͗͢Δ
Ͳ͏׆༻͢Δ͔ʁ • লུ • ϩάΠϯͨ͠ΒखݩͷPCͱಉ͡ϊϦͰ͍͜͏ʂ • ϩάΠϯͯ͠vi͠·͘Ζ͏ʢʁʁʣ
ͰίϚϯυ͕ແ͍orݹ͍ • ͨͱ͑git 1.8.3ͱ͔… • ݹ͍ͳΒɺϏϧυͪ͠Ό͓͏ϗττΪε • ͳΜͱେϏϧυͰ͖Δڥ͋Δ $ wget
https://ʙ/git-2.9.5.tar.gz $ tar xvzf gitʙ; cd gitʙ $ configure --prefix=$HOME/local/bin $ make -i install # -i is ignore $ echo "PATH=$PATH:~/local/bin/" >> ~/.bashrc
root͕ͳͯ͘Ͳ͏ʹ͔ͳΔ • $HOMEʹ͍ΕͪΌ͍͍͑ΜͩΑʂ • --prefix͚ͯϏϧυ • PATH௨͍͍ͤ͡ΌΜ͍͍͡ΌΜ • ʢͨͱ͑ʣaws-cliͱ͔s3cliͱ͔͍Εͯ͜ •
tarͱ͔͕GNUͰͳ͍? ͍Ε͍ͯ͜͏ʂ
ϥϯλΠϜґଘπʔϧͲ͏͢Δʁ • Perlͱ͔Pythonͱ͔ • ʮ(prefix͖Ͱ)ϥϯλΠϜΛϏϧυʯ • ݹ͍ͷΛແཧͯ͠Θͳ͍΄͏͕͍͍ • ·͋PHPͰॻ͚͍͍Μ͡ΌͶʁ •
͋Δ͍go langͷπʔϧΛ͑ΒͿ
ʮͱ͜ΖͰ Linuxbrewʁʯ • ґଘΛ͍Ε͍ͯ͘ͱϦιʔε੍ݶʢʁʣͰࢮ͵ ʢྫɿConoHa WINGʣ • (جຊ)Βͳ͍ʢྫɿFreeBSDͷ͘͞Βʣ • ੈքͦ͜·Ͱ͘ͳ͔ͬͨ
• ಈ͘ॴ͋Δ͔Ͷʂ • ͋Δ͍ͬͱ͢Δʢলུʣ • ۀऀ͞Μ͕Μͬͯʂ !
ϨϯαόCLIͷҙ • ࣗݾ • ṖͷϦιʔε੍ݶʹҙ • ಥϓϩηε͕ࢮ͵ • ࢦඪ͕͖ͬΓͯ͠ͳ͍ ࣗݾ͔ͩΒ͔ͨ͠ͳ͍ʢʁʣ
• ۀऀ͞Μ͕Μͬͯʂ
σϓϩΠ
ͭΒ͞ͷׂ͕̏͜͜ • ͓࡞๏ͷʮFTP & Ṗͷchrootʯ • FTPݖݶ͕Ψό͍ɺϛεͰଈࢮ ʢϓϥϯʹΑΔ͕ɺID͕Ұݸ͔͠ͳ͍ʣ • ṖͷσΟϨΫτϦߏ
• ܁Γฦ͠ʹͳΔ͕ɺ͓࡞๏ແࢹ͠Α͏
• ී௨ʹ • ʢsshͯ͠ʣgit pull • Shell Script/Makefile • ansible(
sshࣗಈԽ) • Deployer • ͔͍͍ͭ͑ΜͰ͢Α
ॳखɿنఆͷDocRootΛແࢹͤΑ • ۀऀͷσϑΥΛແࢹͤΑ • public_htmlҎԼʹϑΝΠϧΛஔ͔ͳ͍ • ద͓͍ͯSymlink͠Α͏ • publichtdocsΛln -s
• (FollowSymlinks͕Offʁۀऀม͑Α͏͆)
ͨͱ͑ྫ # Ϩϯαόͷઃఆলུ $ mkdir ~/repo; cd ~/repo $ git
clone
[email protected]
:uzulla/Mizam.git $ cd Mizam $ make dev-setup # composer instlal $ ln -s ~/repo/Mizam/public/ \ ~/www/pktest.8oji.tokyo/public_html
ΫϨσϯγϟϧ • Tokenͱ͔ΛͲ͜ʹࠐΉ͔ʁ • VPSಉ༷ʹ dotenv • ʮ্Ґʯͷ.htaccess׆༻ # (publicͷΈɺwwwҎԼʹln
-sͨ͠ڥͰʣ # ~/www/pktest.8oji.tokyo/.htaccess SetEnv TOKEN xxxxxx # $_ENVͰͳ͘getenv()Ͱऔಘ͢Δ΄͏͕ແ # symlinkΛͨͲΒͳ͍ͷͰɺҙ # cli͋ΔͳΒແཧ͔ͳʔw
ͭ·Γ # Appͷ git cloneઌ ~/repo/Mizam/ # ຊͷhtdocs ~/repo/Mizam/public #
Ϩϯαόઃఆͷhtdocsʢln -s͢Δʣ ~/www/pktest.8oji.tokyo/public_html # App dirͷʮ֎ʯʹɺenv༻ͷ.htaccessΛͭ͘ΔʢOPʣ ~/www/pktest.8oji.tokyo/.htaccess
SymlinkΛ͏ࡍͷҙ • ʮͨͲΓํʯڥͰҟͳΔͷͰҙɾ׆༻ • PHPͷ__DIR__SymlinkΛḷΔ realpath()૬ʹͳΔ →configϑΝΠϧhtdocsҎԼͷඞཁͳ͍ ※ ެ։σΟϨΫτϦʹ͢Δ߹ҙ •
ApacheSymlink͔ݟͳ͍ (.htaccessͷPathͳͲ)
ϨϯαόͰDeployer • ssh͕Ͱ͖ΔͷͰɺී௨ʹಈ͘Αʂ • (…ࢲͷͨΊͨ͠ݶΓͰ) • (͘͞Βcsh͔ͩΒɺbashʹchshඞཁ) • deployerϦϞʔτ͕bashલఏΆ͍ •
DBϚΠάϨʔγϣϯπʔϧಈ͘ • ྫɿgithub.com/uzulla/deployer-phinx-test
DBૢ࡞ • phpMyadminͱ͔͔ͭͬͯΒΕͳ͍Ͱ͠ΐ • ී௨ʹssh ϙʔτϑΥϫʔυͯͭ͠ͳ͝͏ • Sequel Proͱ͔DBeaverͱ͔… •
αʔόʔ্Ͱphinxͱ͔ಈ͘Αʢલड़ʣ
(CI/)CD • ͔͍͍ͭͬͯΜͩΑʂʢ͍ͭ͜͠ʣ • ʢSymlinkΛ͏ͳΒʣී௨ͷVPSͱ΄΅ಉ༷ • CIͰσϓϩΠ • GitHub Ac5ons
• ྫɿNetlify ϨϯαόͰͶͬͱΓͱͨ͠ϓΞϚϯ ζܧଓతσϓϩΠ
(GHAͰ)CDʹ͢Δͱ… • GitHubίϛοτݖݶͰΞΧϯτཧͰ͖ͯศར • νʔϜʹFTPΞΧϯτΛࢃ͔ͳͯ͘ྑ͍ • αʔόʔϑΝΠϧΛ͍͡Βͳ͍ • ʢ͍ͬͨ͡ !
͕Ͱ͖ͯͯdiff͕ݟΕΔʢʣʣ
↪ ંฦ͠ ͜͜·Ͱʹ࣭͕͋ΕϠδͰ͍ͩ͘͞
VHʹ͍ͭͯ ʢͱ͍͏͔DNSʹ͍ͭͯʣ
ϨϯαόͱDNSີ݁߹ • ίϯύωͰVHͭ͘Δ→AϨίʔυ͕ੜ͑Δ • NameServerΛϨϯαόʹ༬͚Δ͔͠ͳ͍ • ʮNSΛ༬͚ͨ͘ͳ͍ʯʢҰ෦ͷਓؒஊʣ • ϨϯαόͷϨϯλϧDNSػೳ •
ଟ͘ͷϨϯαό֎෦NSΛߟྀͯ͠ͳ͍ɺͭΒ͍
DNS͕ࣗͰͲ͏ʹ͔Ͱ͖ͳ͍ͱ… • ͢ͳ͓ʹෆศ • ৭ʑͳΠϯϑϥʹϨϯαόΛΈࠐΈͮΒ͍ • Route53Ͱ"ALIAS"͍͍ͨ • CloudFlareʢʣ͕͔ͭ͑ͳ͍ •
ۃكʹɺ༬͚ͳ͍ͱVH͕͖Εͳ͍߹͋Δ • ֤ࣾؤுͬͯ΄͍͠ !
େͲ͏ʹ͔ಈ͘ • େCNAME͔A͔NSΛΉ͚Εಈ͖͢Δ • ·ΕʹϨϯαόͷϗετมߋͰഁ໓͢Δ͜ͱ • ఘΊΑ͏ʢʁʁʁʣ • Ϩϯαό͕ఏڙ͢ΔແྉSSL(Let's Encrypt)
͕ಈ͔ͳ͍͜ͱ͕͋Δ • ߟྀͯ͠ΔͷͰಈ͘ۀऀʢ͘͞Βʣ
Tips ઃఆͷௐํ • Ϩϯαόͷࢦ͕ࣔ͋ΕͦͷΑ͏ʹ • ͳ͚Ε͠ΒͯCNAMEΛઃఆ͢Δ • ApexυϝΠϯͳΒ֮ޛͯ͠AΛઃఆ # ௐΔྫ
$ dig {ίϯύωͰ࡞ͬͨυϝΠϯ} @{ʮϨϯαόͷʯNS}
$ dig pktest.8oji.tokyo @ns1.dns.ne.jp # ུ ;; ANSWER SECTION: pktest.8oji.tokyo.
3600 IN A 59.106.19.66 # ;; AUTHORITY SECTION: pktest.8oji.tokyo. 3600 IN NS ns1.dns.ne.jp. pktest.8oji.tokyo. 3600 IN NS ns2.dns.ne.jp.
$ dig www.example.com @ns.example.com # ུ ;; ANSWER SECTION: www.example.com.
3534 IN A XXX.XXX.XXX.XXX ʔʔʔ www.example.com. 3534 IN CNAME www1234.example.jp
ϩά
ΤϥʔϩάͷͭΒ͞ • ͭΒ͞ͷׂ͕̏͜͜ɺຊʹශऑ • ίϯύωͰݟΔɺFTPͰDLɺݕࡧͳ͠ɺࠈ • (େ)ApacheͷErrorLogʹҰॹʹग़͍ͯΔ • ͦͦOffͷ͜ͱଟ͍
ͳͷͰ • ࠷ݶ • ಠࣗͷPathʹग़ྗ͢Δ ʢίʔυ͕յΕ͍ͯΔͱؾ͚ͮͳ͍ͷͰʣ ίʔυͷ֎ɺphp.iniʹઃఆ͢Δ͖ ʢphp.ini, .htaccess.user.iniʣ •
E_ALLʹ͠·͠ΐ͏
ͰɺͲ͏ͬͯݟΔʁ • ૉʹssh Ͱtail -fͨ͠Γgrepͨ͠Γ • Ξϯνύλʔϯ:ΤϥʔϩάΛࠩDL • REST (Restart)
• ͳΈ͙ͩ·͍͠ • ਓʹΒͳ͚Ε͍͚ͳ͍࣌͋Δ…
Tips:FTPͷREST # REST → RESTART # lftp ίϚϯυͷ߹ $lftp
[email protected]
# ॳճDL > get large.log # ࠩDL > reget large.log
s"pʹ͋ΔΑ $ sftp
[email protected]
sftp> get large.log Fetching /path/to/large.log to
large.log sftp> reget large.log Resuming /path/to/large.log to large.log
ͬͱͪΌΜͱ͍ͨ͠ • ֎෦ϩάαʔϏεͷ׆༻ • CloudWatch Logs • PaperTrail • Rollbar(Τϥʔ…?)
• • Fatal͕ͰͨΒSlackʹ௨ඈ͢ͳͲͰ͖Δ
ϩάͷૹΓํ • File tail͑ͳ͍… • ʮಈ͚͘Ͳʢ͈́ʯ • େϓϩηεͳͷͰɺෆࢥٞͳྗͰࢮ͵ • ͳͷͰ
• Τϥʔɾྫ֎ॲཧʹॻ͘ • ࣗྗͰtailͯ͠ૹΔ
Τϥʔɾྫ֎ॲཧʹॻ͘ • ·ͬͱ͏ͳίʔυͳΒ͜ΕͰOKͷͣ • (ޙड़ͷྫࢀরʣ • ҙɿૹ৴ෛՙʮߴ͍ʯ • No'ceΈ͍ͨͳͷૹΒͳ͍ɺຊʹඞཁͳͷ ͚͓ͩ͘Δ͖ɻ
ࣗલͰΠϕϯτ࣌ʹૹΔ • CloudWatch logྫ • github.com/uzulla/send-log-to-cloudwatch-log- sample.php • maxbanton/cwhͰmonologಉ༷ •
(Մೳ͕ͩࣗલૹ৴݁ߏ໘ ɹnextSequenceToken͕ͭΒ͍ʣ
FATALΛͲ͏͢Δ͔ʁ • FatalͰࢮ͵ͱΞϓϦ͔Βඈͤͳ͍ • ΤʔδΣϯτͷৗறʮେʯͰ͖ͳ͍ • ۪ʹϩά૿ΛCronͰૹΓ͚ͭΔ͔͠ͳ͍… • (ࡶͳͷͰऔΓ͜΅ͪ͠ΐͬͱఘΊΔ) •
PHP͕ѼઌࢦఆͰSYSLOGΛͳ͛ΒΕΕφΞ… ʢpapertrailTLSͰSYSLOGΛड͚ΒΕΔʣ
CronͰ૿ϩάΛૹΔ • ϩά͕૿͚۪͑ͨͩʹૹΔ • Papertrailྫ • github.com/uzulla/send-log-to-papertrail-cron.php • cronͷMAILTOΛͪΌΜͱઃఆ͠Α͏ •
log truncateผ్CronͰ
ϩʔςʔγϣϯʹ͍ͭͯ • CronͰεΫϦϓτճ͔͢͠ͳ͍… • औΓ͜΅͠յΕ͕க໋తͳϩάผͰ • ʮக໋తϩά͕େྔʹग़ΔΞϓϦͱ…͏͝͝ʯ #!bash cat error.log
| gzip -c \ > /path/to/error.log.`date +%w`.gz :> /path/to/error.log
ϩάʹ͍ͭͯ • க໋తϩάͱग़͚͢͠Δͱָ # ҙਤͤͣʮͰͪΌͬͨʯϩάશ෦க໋తͰ͠ΐʁ ini_set('error_log','/path/to/fatal_error.log'); # ʮҙࣝతʹʯଞϑΝΠϧʢmonologͰ͍͍Αʂʣ error_log( date("Y/m/d
H:i:s")." - ".$message."\n", 3, '/path/to/app_error.log');
ϨϯαόͷϩάपΓࠜຊతͳղܾࡦ͕ͳ͍ • ͩΕڵຯ͕ͳ͍Μͩͳʂ • WPͱ͔ECCUBEͰΤϥʔϩάͪΌΜͱݟͯΔਓ ͍Δͷ͔ʁ • ʮԶΈ͍ͨͳϨϯαόͰϩάݟ͍ͨΕɺ ଞʹɺ͍·͔͍ͬͯ͢Ͷʔ͔ɺʯ •
ۀऀ͞Μ͕Μͬͯʂʂ
Ϩϯαόతͳ༨ஊ • ϑΝΠϧͷύʔϛογϣϯʹҙ͢Δ͜ͱ • ۀऀʹΑΔ͕ɺΓΖΜ͡ΐ͏ಉډਓʹʮΈ͑ͪΌ ͏ʯͷͰ • (ಉډͰɺPATH͕Θ͔ΓɺPermissionʹΑΔ͕) • ʮແҙຯͳ755ΊΑ͏Ͷʯ
όοΫΞοϓ
εΫϦϓτॻ͍ͯࣗͰΖ͏ • ྺ࢙తʹ͍ͬͯɺۀऀͷόοΫΞοϓΛ৴ͯ͠ ͍͚ͳ͍ • ଟॏͰͱΓ·ͬ͠ΐ͍ • CronͰݻΊͯS3ʹ͋͛Ε͓̺ • ʮόοΫΞοϓ͍͢͠ʯΑ͏ʹ࡞Ζ͏
• (ϨϯαόʹݶΒͳ͍͕)
• ۪ʹγΣϧεΫϦϓτ • tar.gzͰݻΊΔ • Symlinkҡ࣋ • DB • mysqldump͕·Εʹͳ͍͜ͱ͋Δɺ൵͍͠
• ετΞઌ֎෦ʹ • ී௨ʹs3cliͱ͔͍ΕΑ͏ʢԿͩʁʣ • S3ଆϥΠϑαΠΫϧ͕͋ΔͷͰ࠷ߴʂʂ (ੈཧΛؙ͛Ͱ͖Δ) • Amazon S3ͰΦϒδΣΫτͷ༗ޮظݶΛઃఆ
ϛϥʔతʹखݩʹམͱ͍ͨ͠ͱ͖ • FTPͤͣɺrsync͕͍͍ͧ • (ssh+rsyncͬͯຊʹศརͩΑͶ…) $ rsync -auz -e "ssh"
--progress \
[email protected]
:app app_copy # ͓ΈͰauvzͰΑ͍͔ͱ • ٯͰ͖·͕͢ɺrsyncʢʹݶΒͣϛϥʔΞο ϓϩʔυʣࣄނΓ͍͢ͷͰɺdry-runͯ֬͠ೝ ͔ͯ͠Βʹ͠Α͏Ͷɻ
ࢹ
֎ܗࢹ • ಛʹίϝϯτͳ͠ɺී௨ʹͦ͏͍͏αʔϏε͔ͭ ͑ΑΖ͍͠ • Up$me Robotͱ͔
ϝτϦοΫ • ϨϯαόͰϝτϦοΫͱ…͏͙͙಄͕… • Disk༰ྔ͘Β͍CronͰ͕ΜΕOK • ϩάʹ࣮ߦ࣌ؒΛࠐΜͰૹ৴ͱ͔…͏ͬ಄͕ • … •
ͤΊͯෛՙ੍ݶ͖ͨͱ͖ʹΓ͍ͨ… • APIͰऔΓ͍ͨ…ۀऀ͞Μ͕Μͬͯʂ
ॴḨϨϯαό • ෛՙΤϥʔ֎ܗࢹͰؾ͔ͮ͘͠ͳ͍͔ • ॴḨϨϯαόɺఘΊ؊৺ • ۪ʹΞϓϦνϡʔχϯά͠·͠ΐ͏ • CDNΦϓγϣϯ֎͚CDNݕ౼͠·͠ΐ͏
։ൃڥ
ϨϯαόͰ։ൃͯ͠ͳΒͳ͍ • εςʔδϯάఔʹͯ͠ɺdevΊͱ͜͏ • LAMPͳΒڥखݩʹͭ͘ΕΔͰ͠ΐ • ϞμϯͰڥґଘͷͳ͍PHPΛॻ͖·͠ΐ͏ • Ͱ͖ΔͰ͠ΐ͏ʁʢʣ
• ڥΛ࡞ΔͳΒDockerΑΓVMͷ΄͏͕Α͍ • (େɺઃఆΛ͜ͶΔ͜ͱʹͳΔͷͰ) • ൿͷVM͕Ͱ͖Δ… • ansibleͰఆٛ͢Δͱ͔ͨ͠Β͍͍Α • ݹͷDistroͰ࡞ΔͷͩΔ͍ͳʔ͆
• ಠࣗύονDistroෆ໌ͳ͜ͱ • Linuxྗ͕ΘΕΔʢʁʣ
• ϙʔτϑΥϫʔυͰຊ൪ͷDBΛखݩڥʹͭͳ͙ ͘Β͍ී௨ʹͰ͖Δ • Phinxͱ͔ϚΠάϨʔγϣϯπʔϧΒͤΔͷͰ ͖Δ • ϨϯαόΛಛผͩͱࢥΘͳ͍͜ͱ͕؊ཁ
མͱ݀͠ • ϛυϧΣΞઃఆʹҙ • ಛʹMysqlͷsql modeͳͲ • php.iniࠜੑͰἧ͑Δ • php.iniͷ
- h2ps:/ /speakerdeck.com/uzulla/ php-dot-inifalsehua
·ͱΊ
• ͏VPSӡ༻ͨ͘͠ͳ͍Ͱ͠ΐ… • ʢ̍υϝͰ̍ܖͷʣPaaSߴ͗͢ϫϩλ • ϨϯαόΛrootͷͳ͍Linuxͱͯ͠ݟΔ • ࡞๏ແࢹ͠Α͏ʢࣗݾʣ • ऑΛਖ਼͘͠ೝࣝ͠Α͏
• ͏·͘Εɺ͍͏΄ͲෳࡶͰͳ͍
ߋʹৄ͍͠ͱ͜Ζ • Ұॹʹ͚ͷಓΛΓ։͖·͠ΐ͏ • ͓ؾܰʹձSNSͰ͝૬ஊ͍ͩ͘͞ʂ • ͜͏͍ͬͨࣄʹલ͖ͳϨϯαόۀऀ༷ʂʂ
Φν • ʮ͜ͷҟৗͳྗͰɺΑͯ͘τϯτϯͰʁʯ • ʮͦΕͳʯ • ͕ۚ͋Δਓͤͤ͜·͍͜͠ͱΛ͠ͳͯ͘Α͍
Ҏ͓߱·͚
ConoHa WING • ࠷͔ۙͭͬͨ • ॳظແྉɺैྔ՝ۚϓϥϯ͕͋Δʂʂ • ϨϯαόΛͨΊ͢ͷʹѱ͘ͳ͍ • ࠷ར༻ظ͕ؒͳ͍ʂʂ2ԁ/࣌ʂ
• CLIͷ੍ݶ͕ṖʢLinuxbrew͕མͪΔʣ • ॳظͳ͠࠷ར༻ظؒͳ͠ʂ
Tips • ʮϨϯαόۀऀ໊ʯͰΓํΛάάΔͳ • 95%͕ݹ͍όουϊϋ • ʮී௨ʯͷΓํΛ࣋ͪࠐΈ·͠ΐ͏ • ʮ͜ͷτʔΫࣗମ͕όουϊϋͳͷͰʁʯ
ϚωʔδυαʔϏε͓͏ • CDN > ෛՙ੍ݶ • ϝʔϧૹड৴ > IPϒϩοΫճආɺSPFɺDKIMର ԠɺWebhook
• ࢹ • ϨϯαόΑΓߴͭ͘͘ͷέΔ
PHP͕͏͚͝… • JVM͕͏͘͝ʂʢʁʣ • ࡢൃද͞ΕͨΊΓʔ͞Μͷphp-java • h+ps:/ /github.com/php-java/php-java • ϨϯαόͰJVMݴޠ͕ಈ͘ʂʂʢʁʁʣ
• ͬͯΈΑ͏ʂʢࡢ23࣌͝Ζʣ
None
೦ʢࡢͬͯବͩͬͨ͆ʣ • kotlin?͏͘͝Β͍͠Αʂ • (CGIΈ͍ͨͳಈ࡞ʹͳΔ͚Ͳ͆)
PHPͷόʔδϣϯΞοϓ • ͍͖ͳΓΓସ͑ͳ͍ • खݩڥͰςετΛ·Θͯ͠Ҡߦ४උ͢Δ • ϨϯαόͰUnitTestΛ·Θ͢ͷ͋Γ • େ৭ʑೖͬͯΔPHPͷ࣮ߦύεʹҙ ʢޙड़ʣ
• தʹͬͦ͜ΓΓସ͑ͯࢼͯ͠ΈΔʢসʣ
PHPόΠφϦͷॴ • whichͰ୳ͤͳ͍ɺ֤ࣾͰόϥόϥͰ͢ • Un-documentͳ͜ͱ͕ଟ͍ͷͰɺphpinfo()ݟΔ ͨͱ͑खݩͷ͘͞Βͷ߹ $ /usr/local/php/7.3/bin/php -v
PHP 7.3.12 (cli) (built: Dec 5 2019 10:06:07) ( NTS ) $ /usr/local/php/4.4/bin/php -v PHP 4.4.9 (cli) (built: Dec 4 2019 14:37:37) • UnitTest࣌ʹඞͣόΠφϦͷύεΛࢦఆ͢Δ͜ͱ
νϡʔχϯάʢসʣ • େ(ڞ༗ͱͳΔ)DB͕ʢ࣌ؒଳͰʣ͍ • MysqlΑΓSqlite͕͍͜ͱ • సૹྔͰౖΒΕΔɺCDNΞηοτ৴Λ͚Δ • େ༰ྔσΟεΫͷ͍Έͪ…͏͝͝ •
ϨϯαόͷϓϥϯΞοϓޮՌͳ͍ࣄଟ͍… • ෛՙͳΒɺૉʹPaaSͱ͔ʹҾͬӽͦ͏
ࢼ༻ظؒ • େ͖ͳͰ͍͑ͳ͍͕… • ͪΌΜͱղ͢ΕʂԿͰʂࢼ༻Ͱ͖Δʂ͜ ͱ͕ଟ͍ʂ • (ݸਓͷײͰ͢) • ͱΓ͋͑ͣࢼ༻ͯ͠Έ·͠ΐ͏
• ʢॳظඅ༻จԽͲ͏ʹ͔ͳΓ·ͤΜ͔Ͷʣ
Ϩϯαό֤ࣾͷࢲ৴ • WordPressҰຊʹͳͬͯ·ͤΜ͔ʁ • PHPͱ͍͏͢Β͍͠ݴޠΛಈ͔͢ʮϞμϯͳʯ Πϯϑϥͱ͕ͯ͠ΜΓ·ͤΜ͔ʁ • ֤ࣾʮதͷਓʯʮΘ͔ͬͯΔʯਓ͕ଟ͍ͷͰɺ Θ͔ͬͯΔͷͩͱ͓͍·͕͢ •
ചͱ͍ͯ͠͠ͱ͍͏͓·͋͋ΔΜͰ͠ΐ ͏͕…
ฏͨ͘ݴ͏ͱ • DocRootͱϩά͚ͩͲ͏ʹ͔ͳΓ·ͤΜ͔Ͷ • LinuxbrewʢHomebrewʣೖΔͱ͘͢͝خ͍͠