WordPress Home Server with Raspberry Pi


Published on

Set up a web server running WordPress by Raspberry Pi.

Published in: Technology
  • Be the first to comment

WordPress Home Server with Raspberry Pi

  1. 1. WordPress HomeServer with RasPi2013-May-25Japanese Raspberry Pi Users Group池田 百合子IKEDA YurikoSponsored by
  2. 2. 自己紹介Self Introduction池田 百合子 (IKEDA Yuriko)WordPress Plugin dev.‣ Ktai Style‣ Ktai Entry写真好き (Love photograph)http://www.yuriko.net/@lilyfanjp
  3. 3. ラズベリーパイa Raspberry PIE
  4. 4. Raspberry PiDelivered by
  5. 5. raspi-config
  6. 6. minimum GPU
  7. 7. ここからシェル作業Starting from using shell
  8. 8. 固定IP化Use static IP$ cd /etc/network/$ sudo cp interfaces interfaces-static$ sudo mv interfaces interfaces-dhcp$ ln -s interfaces-static interfaces$ sudo vi interface-staticiface eth0 inet staticaddress
  9. 9. ホスト名変更Change host name$ sudo vi /etc/hostnamezinnia$ sudo vi /etc/hosts# raspberrypi192.168.3.14 zinnia$ sudo shutdown -r now
  10. 10. Zinnia elegans w/BombusPhoto by Simon Koopmann
  11. 11. apt-get install$ sudo apt-get update$ sudo apt-get install wordpress mysql-server phpmyadmin libnss-mdnsThe following NEW packages will be installed:apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-commonavahi-daemon bind9-host dbconfig-common geoip-database heirloom-mailxjavascript-common libaio1 libapache2-mod-php5 libapr1 libaprutil1libaprutil1-dbd-sqlite3 libaprutil1-ldap libavahi-core7 libbind9-80libdbd-mysql-perl libdbi-perl libdns88 libgeoip1 libhtml-template-perllibisc84 libisccc80 libisccfg82 libjs-cropper libjs-prototypelibjs-scriptaculous liblwres80 libmcrypt4 libmysqlclient16libmysqlclient18 libnet-daemon-perl libnss-mdns libonig2 libphp-phpmailerlibphp-snoopy libplrpc-perl libqdbm14 mysql-client-5.5 mysql-commonmysql-server mysql-server-5.5 mysql-server-core-5.5 php5-cli php5-commonphp5-gd php5-mcrypt php5-mysql phpmyadmin ssl-cert tinymce wordpresswordpress-l10n wwwconfig-common0 upgraded, 56 newly installed, 0 to remove and 166 not upgraded.Need to get 41.6 MB of archives.After this operation, 186 MB of additional disk space will be used.Do you want to continue [Y/n]?
  12. 12. MySQL root Password※RasPi 自体のパスワードとは別にしよう(Use different one from the RasPi login password.)
  13. 13. phpMyAdmin 設定pma conf.
  14. 14. dbconfig 使用確認Decide using dbconfig
  15. 15. DB pass for pma※さっき設定した MySQL root パスワード(MySQL root password you set a few minutes ago.)
  16. 16. pma user password※これは空白のままOKしてよい(Keep it empty.)
  17. 17. Apache2 設定Apache2 conf.$ sudo vi /etc/apache2/apache.conf#<IfModule mpm_prefork_module># StartServers 5# MinSpareServers 5# MaxSpareServers 10# MaxClients 150# MaxRequestsPerChild 0# </IfModule><IfModule mpm_prefork_module>StartServers 2MinSpareServers 2MaxSpareServers 8MaxClients 150MaxRequestsPerChild 0</IfModule>$ sudo vi /etc/apache2/conf.d/charset#AddDefaultCharset UTF-8AddDefaultCharset UTF-8
  18. 18. PHP5 設定PHP5 conf.$ sudo vi /etc/php5/apache2/php.inishort_open_tag = Offmemory_limit = 32Mdefault_charset = "UTF-8"upload_max_filesize = 8Mmax_file_uploads = 2date.timezone = Asia/Tokyombstring.language = Japanesembstring.internal_encoding = UTF-8mbstring.http_input = passmbstring.http_output = passmbstring.encoding_translation = Off$ sudo vi /etc/php5/cgi/php.ini$ sudo vi /etc/php5/cli/php.ini(memory_limit, upload 関連は変更不要)(Untouch memory_limit, upload settings)
  19. 19. phpMyAdmin保護Protect pma$ sudo vi /etc/phpmyadmin/apache.conf# Authorize for setup# <Directory /usr/share/phpmyadmin/setup># <IfModule mod_authn_file.c># AuthType Basic# AuthName "phpMyAdmin Setup"# AuthUserFile /etc/phpmyadmin/htpasswd.setup# </IfModule># Require valid-user#</Directory># Authorize for login<Directory /usr/share/phpmyadmin><IfModule mod_authn_file.c>AuthType BasicAuthName "phpMyAdmin Login"AuthUserFile /etc/phpmyadmin/htpasswd.login</IfModule>Require valid-user</Directory>
  20. 20. Basic 認証パスワードSet Basic auth password$ cd /etc/phpmyadmin$ sudo htpasswd -c htpasswd.login myadminNew password: (強固でなくていい; may be weak)Re-type new password: (再度入力)Adding password for user myadmin
  21. 21. Apache 再起動Reboot apache$ sudo /etc/init.d/apache2 restart[ ok ] Restarting web server: apache2...waiting.
  22. 22. Avahi 設定Avahi conf.$ sudo vi /etc/avahi/hosts192.168.3.14 zinnia.local$ cd /etc/avahi/services/$ sudo cp phpmyadmin.service http.service$ sudo vi http.service<?xml version="1.0" standalone=no?><!DOCTYPE service-group SYSTEM "avahi-service.dtd"><service-group><name replace-wildcards="yes">WWW on %h</name><service><type>_http._tcp</type><port>80</port><txt-record>path=/</txt-record></service></service-group>
  23. 23. ブラウザで接続Connect with browser:http://zinnia.local/phpmyadmin/
  24. 24. Basic 認証Basic auth
  25. 25. phpMyAdmin ログインpma login
  26. 26. 匿名ユーザ削除Delete anon. user
  27. 27. DB ユーザ追加Add a DB user
  28. 28. 新規 DB 作成Create a new DB
  29. 29. WordPressas .deb
  30. 30. FHS 準拠Filesystem Hierarchy Standard本体Core files/usr/share/wordpress/プラグインテーマPlugin&Theme/var/lib/wordpress/wp-content/or/srv/www/wp-content/{HTTP_HOST}設定Settings/etc/wordpress/説明Documents/usr/share/doc/wordpress/
  31. 31. 利点ProsWP のアップデートは aptitude(Updating WP with aptitude.)54のロケールに対応(Supports 54 locales.)WP コアファイルが DocRoot 外(WP core files are outside DocRoot.)
  32. 32. 欠点Consサブディレクトリで独立した複数のサイト設置が困難(Difficult to locate a few independentsites as sub-dir.)➡マルチサイト機能でサブディレクトリを使えばよい
  33. 33. サイト作成Creating a site
  34. 34. 今回のサイトThe examplehttp://zinnia.local/blog/内側向けサイト(For internal use)
  35. 35. apache2 設定apache2 conf.$ sudo a2enmod rewrite$ sudo cp /usr/share/doc/wordpress/examples/apache.conf /etc/apache2/sites-available/wp$ sudo vi /etc/apache2/sites-available/wp## Without using Virtual host, hosted off /blogAlias /blog/wp-content /var/lib/wordpress/wp-contentAlias /blog /usr/share/wordpress<Directory /usr/share/wordpress>Options FollowSymLinksAllowOverride Limit Options FileInfoDirectoryIndex index.phpOrder allow,denyAllow from all</Directory><Directory /var/lib/wordpress/wp-content>Options FollowSymLinksOrder allow,denyAllow from all</Directory>$ sudo a2ensite wp$ sudo /etc/init.d/apache2 restart
  36. 36. wp-config 作成Create wp-config$ sudo cp /usr/share/wordpress/wp-config-sample.php/etc/wordpress/config-zinnia.local.php$ sudo vi /etc/wordpress/config-zinnia.local.phpdefine(DB_NAME, pi_wp);^Mdefine(DB_USER, pi);^Mdefine(DB_PASSWORD, password_here);^Mdefine(AUTH_KEY, 次のスライド参照);^Mdefine(SECURE_AUTH_KEY, see the next slide);^Mdefine(LOGGED_IN_KEY, ...);^Mdefine(NONCE_KEY, ...);^Mdefine(AUTH_SALT, ...);^Mdefine(SECURE_AUTH_SALT, ...);^Mdefine(LOGGED_IN_SALT, ...);^Mdefine(NONCE_SALT, ...);^Mdefine(WPLANG, ja);^Mdefine(WP_CONTENT_DIR, /var/lib/wordpress/wp-content);define(FS_METHOD, direct);
  37. 37. https://api.wordpress.org/secret-key/1.1/salt/※2,3回リロードして使う(Before using, reload several times)※値コピー後も2,3回リロード(Be sure to reload several times AFTER copy.)
  38. 38. wp-content 書込可wp-content to be writable$ sudo cd /var/lib/wordpress$ sudo chown -R www-data wp-content
  39. 39. 5min. install
  40. 40. Done!
  41. 41. Logging in
  42. 42. Admin panel
  43. 43. Add Multibyte Plugin
  44. 44. Install Plugin
  45. 45. Installed & Activated
  46. 46. Front page
  47. 47. TODOsOS ユーザ追加 (Adding OS user)/etc/skel, /etc/profile, /etc/adduser.conf,/etc/sudoersupdate-alternatives --config editorメール設定 (MTA configuration)iptables 設定 (iptables configuration)サイト外観調整 (Adjust appearance)
  48. 48. ClusteringPlease buy at
  49. 49. 複数ホストMulti hostsDB 移設 (Moving DB)phpMyAdmin 設定変更(Change conf. of pma)wp-config設定変更(Rewrite wp-conf.)www db
  50. 50. 参考URLReferencesスライド公開中 (Slide shared)http://www.slideshare.net/lilyfan/raspi-wordpress20130525Japanese Raspberry Pi UGhttp://raspi.jp/