$30 off During Our Annual Pro Sale. View Details »
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
似たもの同士のPerlとPHP
uzulla
1
110
More Context, Better Code. 既存コードやOAS等をコンテキストとしてLLMに与える事で、よりよいコード生成を行う話
uzulla
1
110
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
3
170
セッションのトークセッション / Traps for PHP session features in growing web apps
uzulla
2
120
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
5
2k
例外を投げるのをやめてみないか? あるいは受け入れてみないか? - How to use exceptions other than throwing
uzulla
4
920
PHPerが ISUCONでやるべき事
uzulla
1
990
開発生産性は上がらない - N Ways to Reduce Development Productivity
uzulla
1
240
test is not a job
uzulla
1
500
Other Decks in Technology
See All in Technology
Amazon Bedrock Multi-Agent Collaboration Workshop の紹介 - ワークショップでAIエージェントを学ぼう
nasuvitz
2
200
【AWS re:Invent 2024】Amazon Bedrock アップデート総まとめ
minorun365
PRO
7
540
WED Company Deck for Engineer
wed
2
3.7k
職能を超えたモブプログラミングが品質に与えた良い影響
tonionagauzzi
1
150
Kubernetesを知る
logica0419
18
5k
ファインディの4年にわたる技術的負債の返済 / Repaying 4 Years of Technical Debt at Findy
ma3tk
7
3.7k
My Generation 年配者がこの先生きのこるには (Developers CAREER Boost 2024 Edition)/My Generation How elder engineers can survive
kwappa
3
350
ARRが3年で10倍になったプロダクト開発とAI活用の軌跡
akiroom
0
240
[GDG DevFest Bangkok 2024] - The Future of Retail E-commerce with Gemini AI
punsiriboo
0
300
MySQL 8.0 から PostgreSQL 16 への移行と RLS 導入までの道のりと学び
baseballyama
0
940
LangChainとSupabaseを活用して、RAGを実装してみた
atsushii
0
160
お悩みハンドブック紹介資料
grafferhandbook
0
1.2k
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Docker and Python
trallard
41
3.1k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
94
17k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Optimising Largest Contentful Paint
csswizardry
33
3k
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ʣೖΔͱ͘͢͝خ͍͠