wordpress home server with raspberry pi

50
WordPress Home Server with RasPi 2013-May-25 Japanese Raspberry Pi Users Group 池田 百合子 IKEDA Yuriko Sponsored by

Upload: yuriko-ikeda

Post on 14-May-2015

3.506 views

Category:

Technology


5 download

DESCRIPTION

Set up a web server running WordPress by Raspberry Pi.

TRANSCRIPT

Page 1: WordPress Home Server with Raspberry Pi

WordPress Home Server with RasPi

2013-May-25Japanese Raspberry Pi Users Group

池田 百合子IKEDA Yuriko

Sponsored by

Page 2: WordPress Home Server with Raspberry Pi

自己紹介Self Introduction

池田 百合子 (IKEDA Yuriko)WordPress Plugin dev.‣ Ktai Style‣ Ktai Entry写真好き (Love photograph)http://www.yuriko.net/

@lilyfanjp

Page 3: WordPress Home Server with Raspberry Pi

ラズベリーパイa Raspberry PIE

Page 4: WordPress Home Server with Raspberry Pi

Raspberry PiDelivered by

Page 5: WordPress Home Server with Raspberry Pi

raspi-config

Page 6: WordPress Home Server with Raspberry Pi

minimum GPU

Page 7: WordPress Home Server with Raspberry Pi

ここからシェル作業Starting from using shell

Page 8: WordPress Home Server with Raspberry Pi

固定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 192.168.3.14netmask 255.255.255.0network 192.168.3.0broadcast 192.168.3.255gateway 192.168.3.1

Page 9: WordPress Home Server with Raspberry Pi

ホスト名変更Change host name

$ sudo vi /etc/hostname

zinnia$ sudo vi /etc/hosts

#127.0.0.1 raspberrypi192.168.3.14 zinnia$ sudo shutdown -r now

Page 10: WordPress Home Server with Raspberry Pi

Zinnia elegans w/BombusPhoto by Simon Koopmann

Page 11: WordPress Home Server with Raspberry Pi

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-common avahi-daemon bind9-host dbconfig-common geoip-database heirloom-mailx javascript-common libaio1 libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libavahi-core7 libbind9-80 libdbd-mysql-perl libdbi-perl libdns88 libgeoip1 libhtml-template-perl libisc84 libisccc80 libisccfg82 libjs-cropper libjs-prototype libjs-scriptaculous liblwres80 libmcrypt4 libmysqlclient16 libmysqlclient18 libnet-daemon-perl libnss-mdns libonig2 libphp-phpmailer libphp-snoopy libplrpc-perl libqdbm14 mysql-client-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5-cli php5-common php5-gd php5-mcrypt php5-mysql phpmyadmin ssl-cert tinymce wordpress wordpress-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]?

Page 12: WordPress Home Server with Raspberry Pi

MySQL root Password

※RasPi 自体のパスワードとは別にしよう(Use different one from the RasPi login password.)

Page 13: WordPress Home Server with Raspberry Pi

phpMyAdmin 設定pma conf.

Page 14: WordPress Home Server with Raspberry Pi

dbconfig 使用確認Decide using dbconfig

Page 15: WordPress Home Server with Raspberry Pi

DB pass for pma

※さっき設定した MySQL root パスワード(MySQL root password you set a few minutes ago.)

Page 16: WordPress Home Server with Raspberry Pi

pma user password

※これは空白のままOKしてよい(Keep it empty.)

Page 17: WordPress Home Server with Raspberry Pi

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 2 MinSpareServers 2 MaxSpareServers 8 MaxClients 150 MaxRequestsPerChild 0</IfModule>$ sudo vi /etc/apache2/conf.d/charset#AddDefaultCharset UTF-8AddDefaultCharset UTF-8

Page 18: WordPress Home Server with Raspberry Pi

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/Tokyo

mbstring.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)

Page 19: WordPress Home Server with Raspberry Pi

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 Basic AuthName "phpMyAdmin Login" AuthUserFile /etc/phpmyadmin/htpasswd.login </IfModule> Require valid-user</Directory>

Page 20: WordPress Home Server with Raspberry Pi

Basic 認証パスワードSet Basic auth password

$ cd /etc/phpmyadmin$ sudo htpasswd -c htpasswd.login myadmin

New password: (強固でなくていい; may be weak)Re-type new password: (再度入力)Adding password for user myadmin

Page 21: WordPress Home Server with Raspberry Pi

Apache 再起動Reboot apache

$ sudo /etc/init.d/apache2 restart

[ ok ] Restarting web server: apache2...waiting.

Page 22: WordPress Home Server with Raspberry Pi

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>

Page 23: WordPress Home Server with Raspberry Pi

ブラウザで接続Connect with browser:

http://zinnia.local/phpmyadmin/

Page 24: WordPress Home Server with Raspberry Pi

Basic 認証Basic auth

Page 25: WordPress Home Server with Raspberry Pi

phpMyAdmin ログインpma login

Page 26: WordPress Home Server with Raspberry Pi

匿名ユーザ削除Delete anon. user

Page 27: WordPress Home Server with Raspberry Pi

DB ユーザ追加Add a DB user

Page 28: WordPress Home Server with Raspberry Pi

新規 DB 作成Create a new DB

Page 29: WordPress Home Server with Raspberry Pi

WordPressas .deb

Page 30: WordPress Home Server with Raspberry Pi

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/

Page 31: WordPress Home Server with Raspberry Pi

利点Pros

WP のアップデートは aptitude(Updating WP with aptitude.)

54のロケールに対応(Supports 54 locales.)

WP コアファイルが DocRoot 外(WP core files are outside DocRoot.)

Page 32: WordPress Home Server with Raspberry Pi

欠点Cons

サブディレクトリで独立した複数のサイト設置が困難(Difficult to locate a few independent sites as sub-dir.)

➡マルチサイト機能でサブディレクトリを使えばよい

Page 33: WordPress Home Server with Raspberry Pi

サイト作成Creating a site

Page 34: WordPress Home Server with Raspberry Pi

今回のサイトThe example

http://zinnia.local/blog/

内側向けサイト(For internal use)

Page 35: WordPress Home Server with Raspberry Pi

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 FollowSymLinks AllowOverride Limit Options FileInfo DirectoryIndex index.php Order allow,deny Allow from all</Directory><Directory /var/lib/wordpress/wp-content> Options FollowSymLinks Order allow,deny Allow from all</Directory>$ sudo a2ensite wp$ sudo /etc/init.d/apache2 restart

Page 36: WordPress Home Server with Raspberry Pi

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');

Page 37: WordPress Home Server with Raspberry Pi

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.)

Page 38: WordPress Home Server with Raspberry Pi

wp-content 書込可wp-content to be writable

$ sudo cd /var/lib/wordpress$ sudo chown -R www-data wp-content

Page 39: WordPress Home Server with Raspberry Pi

5min. install

Page 40: WordPress Home Server with Raspberry Pi

Done!

Page 41: WordPress Home Server with Raspberry Pi

Logging in

Page 42: WordPress Home Server with Raspberry Pi

Admin panel

Page 43: WordPress Home Server with Raspberry Pi

Add Multibyte Plugin

Page 44: WordPress Home Server with Raspberry Pi

Install Plugin

Page 45: WordPress Home Server with Raspberry Pi

Installed & Activated

Page 46: WordPress Home Server with Raspberry Pi

Front page

Page 47: WordPress Home Server with Raspberry Pi

TODOsOS ユーザ追加 (Adding OS user)/etc/skel, /etc/profile, /etc/adduser.conf, /etc/sudoersupdate-alternatives --config editor

メール設定 (MTA configuration)iptables 設定 (iptables configuration)サイト外観調整 (Adjust appearance)

Page 48: WordPress Home Server with Raspberry Pi

ClusteringPlease buy at

Page 49: WordPress Home Server with Raspberry Pi

複数ホストMulti hosts

DB 移設 (Moving DB)phpMyAdmin 設定変更(Change conf. of pma)

wp-config設定変更(Rewrite wp-conf.)

www db