end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

python srcのオレオレ 雛形(テンプレート template )

たまにしか使わず、忘れるので、これからも追記してくであろうメモ

1枚script

#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import getopt
import sys


def main():
    img_file_path = sys.argv[1] # 引数受取り

    # 文字列出力
    print 'バイト文字列で出力'
    print u'UNICODE文字列で出力'

    list = [1,10,100]
    for char in chars_list:
        print "CHAR: %02d" % char  # 変数の文字列展開

def load_csv_file(tsv_file_path):
    csv_rows = csv_read(tsv_file_path, 'shift_jisx0213')
    for row in csv_rows:
        print row[2]
        time.sleep(3)
    return


if __name__ == '__main__':
    main()

potrace による raster (bitmap) to vector

http://potrace.sourceforge.net/

install

$ wget http://potrace.sourceforge.net/download/1.15/potrace-1.15.tar.gz
$ tar -zxvf potrace-1.15.tar.gz
$ cd potrace-1.15
$ ./configure
$ make
$ su
# make install

usage

例えば、以下はインターネットにある間取り画像を image magickのconvertでビットマップ変換し、 potraceで、ベクター(SVG)に変換してます。

$ /usr/local/bin/convert 2ldk.png 2ldk.bmp
$ /usr/local/bin/potrace --backend svg 2ldk.bmp 

他にも autotrace もありますが、installもしていません http://autotrace.sourceforge.net/

inkscapeでも可能で、inkscapeは変換パラメータがいろいろとありました。

部分積分の導出(証明)と、利用方法

以前の上記エントリとも関連しますが、この手の内容は「部分積分」という名前しか記憶にないので… end0tknr.hateblo.jp

部分積分の公式

 \Large
  \int^b_a f(x) g(x) dx = [ f(x) G(x) ]^b_a - \int^b_a f'(x) G(x) dx

※ただし、  G'(x) = g(x)

導出

積の微分の公式から変形して行きます

 \Large
  \{ f(x)g(x) \}' = f'(x)g(x) + f(x)g'(x) \cdots 式1

上記を積分

 \Large
  f(x)g(x) = \int{ f'(x)g(x) } dx + \int{ f(x)g'(x)} dx

左辺/右辺を移項

 \Large
  \int{ f(x)g'(x)} dx = f(x)g(x) - \int{ f'(x)g(x) } dx
 \Large
  \int^b_a{ f(x)g'(x)} dx = [  f(x)g(x) ]^b_a - \int^b_a{ f'(x)g(x) } dx

最後に、前述の式1に  G'(x) = g(x) を適用し、完了

利用方法

例えば

 \Large
  \int^1_0 e^x x dx = [ e^x \cdot x ]^1_0 - \int^1_0 e^x \cdot 1 dx

openssl主要コマンド一覧 - ssl証明書期限やcipher suite の確認

だいぶ、忘れていたのでメモ

cipher suite の一覧

$ openssl ciphers -v

cipher suite の対応状況

# 対応しているcipher
$ openssl s_client -connect www.google.co.jp:443 -cipher AES256-SHA
# 対応してないcipher
$ openssl s_client -connect www.google.co.jp:443 -cipher AES256-SHA256

ssl証明書の表示と、有効期限確認

$ openssl s_client -connect www.google.co.jp:443 -showcerts
$ openssl s_client -connect www.google.co.jp:443 < /dev/null 2> /dev/null | openssl x509 -text | grep Not

ssl証明書の有効期限確認 (local版)

$ openssl x509 -in /path/to/server.crt -noout -dates

install openvas-9 to raspbian (raspberry pi) from src

OpenVAS - OpenVAS - Open Vulnerability Assessment System

2018/1/27追記

openvasと別の脆弱性スキャナとして、vuls というものがあるようですが、そちらは別途(いつか...)

2017/10/11追記

その後、「普段、使ってるcentos6 or 7にもinstall」と試みましたが、 依存libraryにつまづくことが多く、断念。 更に、その後、ubuntu16.04にはこのエントリとほぼ同様の手順でできました。

openvas ver.9は、openvas ver.8からの変更点が多いらしい為、install & test.

  • ※www.openvas.org では、vmのisoも配布されていましたが、baseのgreenbone os でのcve情報更新等が分からず、諦めました
  • ※手元にあるcent osに対し、package installしようとも思いましたが、vmのdisk space不足で諦めました。

今回は、raspbian (raspberry pi) に対して、srcからinstallしています。

参考にさせて頂いたurl

openvas-8とopenvas-9の違いはありますが、qiitaのentryのまんまです。

qiita.com

https://serenity-networks.com/?s=openvas

avleonov.com

hackertarget.com

download & 解凍

OpenVAS - Install OpenVAS from Source Code

$ mkdir ~/tmp/openvas
$ cd ~/tmp/openvas

$ wget http://wald.intevation.org/frs/download.php/2420/openvas-libraries-9.0.1.tar.gz
$ wget http://wald.intevation.org/frs/download.php/2423/openvas-scanner-5.1.1.tar.gz
$ wget http://wald.intevation.org/frs/download.php/2448/openvas-manager-7.0.2.tar.gz
$ wget http://wald.intevation.org/frs/download.php/2429/greenbone-security-assistant-7.0.2.tar.gz
$ wget http://wald.intevation.org/frs/download.php/2397/openvas-cli-1.4.5.tar.gz

$ tar -zxvf openvas-libraries-9.0.1.tar.gz
$ tar -zxvf openvas-scanner-5.1.1.tar.gz
$ tar -zxvf openvas-manager-7.0.2.tar.gz
$ tar -zxvf greenbone-security-assistant-7.0.2.tar.gz
$ tar -zxvf openvas-cli-1.4.5.tar.gz

それぞれのdirにINTALLファイルがある為、事前に確認するとよいと思います。

依存packeのinstall

apt-get update や apt-get upgrade もおすすめします

$ sudo apt-get install libgnutls28-dev libglib2.0-dev libssh-dev libpcap-dev \
       libpcap-dev libhiredis-dev libgpgme11-dev libgcrypt20-dev uuid-dev \
       libldap2-dev bison doxygen

依存packeのinstall その2

こちらは、診断結果レポートのpdf出力用

$ sudo apt-get install texlive-latex-extra --no-install-recommends
$ sudo apt-get install texlive-fonts-recommended

make & install

$ cd openvas-libraries-9.0.1
$ less INSTALL
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
$ make rebuild_cache
$ sudo make install

$ cd openvas-scanner-5.1.1
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
$ make rebuild_cache
$ sudo make install

$ sudo apt-get install libsqlite3-dev xmltoman
$ cd openvas-manager-7.0.2
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
$ make rebuild_cache
$ sudo make install

$ suto apt-get install libmicrohttpd-dev libxml2-dev libxslt1-dev gettext xsltproc
$ cd greenbone-security-assistant-7.0.2
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
$ make rebuild_cache
$ sudo make install

$ cd openvas-cli-1.4.5
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
$ make rebuild_cache
$ sudo make install

証明書の作成

openvas8からコマンドが変更されています

$ openvas-manager-7.0.2/INSTALL
$ sudo apt-get install gnutls-bin  ## install certtool
$ sudo openvas-manage-certs -a     ## openvas-mkcert in openvas8

openvas8では「openvas-mkcert-client -n -i in 」も必要でしたが、 openvas9では不要かも?

scan情報の更新

数時間を要します。 特に greenbone-scapdata-sync が途中から、part 0 Done -> part 1 Done ... を繰り返していた為、 中断し、再実行しましたが、何か間違えたのかな?

$ sudo greenbone-nvt-sync          ## openvas-nvt-sync      in openvas8
$ sudo greenbone-scapdata-sync     ## openvas-scapdata-sync in openvas8
$ sudo greenbone-certdata-sync     ## openvas-certdata-sync in openvas8

redis (no sql)のinstall & start

$ sudo apt-get install redis-server
$ sudo sh -c 'echo "unixsocket /tmp/redis.sock" >> /etc/redis/redis.conf'
$ sudo service redis-server restart

start scanner service

$ sudo openvassd

$ ps -ef | grep openvas
root  22805     1 77 19:36 ? 00:01:41 openvassd: Reloaded 6900 of 54606 NVTs (12% /
root  22806 22805  0 19:36 ? 00:00:00 openvassd (Loading Handler)

# ↓上記の Loading Handler が Waiting for incoming connections となるまで、数10分?待つ
$ ps -ef | grep openvas
root  22805     1 74 19:36 ? 00:19:38 openvassd: Waiting for incoming connections

create web-admin

後で、ブラウザでのログインに使用します

$ sudo openvasmd --create-user=admin --role=Admin
User created with password 'ないしょ'.

start openvas-manager & web-service

「--rebuild」の影響でしょうか、数10分待ちました

$ sudo openvasmd --rebuild --progress
Rebuilding NVT cache... done.
$ sudo openvasmd
$ sudo gsad --http-only

openvas-check-setup

最後にチェックツールで問題なければ、ブラウザを起動し、先程のweb-adminで利用できます

$ wget https://svn.wald.intevation.org/svn/openvas/trunk/tools/openvas-check-setup --no-check-certificate
$ chmod 755 openvas-check-setup
$ sudo ./openvas-check-setup --v9

scan実行後、すぐにDONEとなる場合

診断対象が ping に応答しない為、「host is dead」と判断されている可能性があります。 openvasのメニューバーから Configuration → Targets へ画面遷移し、 その設定画面において、「Alive Test = Consider Alive」とすると ping応答なしでも診断を行うようになります。

install dasher to raspi ...無反応だったので、また今度

github.com

amazon dash button の検知までをtest

前準備 node.js npm

予めraspiにnode.jsがinstallされていますが、古いようですので、 nodejs.orgのdocumentに従いinstall.

Installing Node.js via package manager | Node.js

Installing Dasher on a Raspberry Pi · maddox/dasher Wiki · GitHub

$ sudo apt-get update  # パッケージ・リストを入手
$ sudo apt-get upgrade
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install -y nodejs

$ node -v
v8.3.0
$ nodejs -v
v8.3.0
$ npm -v
5.3.0

試しに install node-dash-button

dasherはnode-dash-buttonをwrapして、 http等でrequestするものですが、試しにnode-dash-buttonもinstall

github.com

手順は、ほぼ node-dash-button の github.com に記載の通りです。

前準備 libpcap

tcpdumpと同じsiteでも配布されています sudo apt-get install libpcap-dev

install node-dash-button

$ cd /home/endo/local
$ mkdir dash-button
$ cd dash-button
$ /usr/bin/npm init   #対話形式によるprojectの書式化
$ /usr/bin/npm install node-dash-button --save

dash buttonのmac address検知

手元にあるdash buttonのmacは 18:74:2e:04:f6:e2 のようです。

$ sudo node ~/dev/dash-button/node_modules/node-dash-button/bin/findbutton
Watching for arp & udp requests on your local network, please try to press your dash now
Dash buttons should appear as manufactured by 'Amazon Technologies Inc.' 

Possible dash hardware address detected: 18:74:2e:04:f6:e2 Manufacturer: unknown Protocol: udp

root権限やsudoなしで、動作させる方法ないかな?

dasher

install dasher

$ cd dev
$ git clone https://github.com/maddox/dasher.git
$ cd dasher
$ npm install
$ ls node_modules/
ajv              core-util-is    har-validator          jsprim            safe-buffer
asn1             cryptiles       hawk                   mime-db           sntp
assert-plus      dashdash        hoek                   mime-types        socketwatcher
asynckit         delayed-stream  http-signature         nan               sshpk
aws4             ecc-jsbn        isstream               node-dash-button  stringstream
aws-sign2        extend          is-typedarray          oauth-sign        tough-cookie
bcrypt-pbkdf     extsprintf      jsbn                   pcap              tunnel-agent
boom             forever-agent   jsonify                performance-now   tweetnacl
caseless         form-data       json-schema            punycode          underscore
co               getpass         json-stable-stringify  qs                uuid
combined-stream  har-schema      json-stringify-safe    request           verror

## dash buttonのmac address検知
当然、macは 18:74:2e:04:f6:e2

$ $ ~/dev/dasher/script/find_button Watching for arp & udp requests on your local network, please try to press your dash now Dash buttons should appear as manufactured by ‘Amazon Technologies Inc.’ Possible dash hardware address detected: 18:74:2e:04:f6:e2 Manufacturer: unknown Protocol: udp

## config dasher
config.example.json には、様々なサンプルがあるので、これをベースにするとよさそうです。

cp config.example.json config/config.json vi config/config.json {“buttons”:[ { “name”: “Debug Dash Button 1”, “address”: “18:74:2e:04:f6:e2”, “debug”: true }, { “name”: “Debug Dash Button 2”, “address”: “18:74:2e:04:f6:e2”, “url”: “http://192.168.0.12/”, “method”: “GET”, “debug”: true }, { “name”: “Debug Dash Button 3”, “address”: “18:74:2e:04:f6:e2”, “cmd”: “echo ‘ HOGE ’ > /home/endo/tmp/foo.log” } ]}

# test dasher

$ cd ~/dev/dasher $ sudo npm run start

dasher@1.4.1 start /home/endo/dev/dasher node app.js

[2017-08-16T00:30:01.177Z] TEST DASHER added. : :

あれ?、buttonを検知しないし、errorも吐かない...?
raspi or nodejsのinstallがおかしいのかな?
また、今度ですね。

# その他 - dasherの自動起動もdocumentに記載
試していませんが

[https://github.com/maddox/dasher/wiki:title]

install node.js ver.6.11.2 from src

$ wget https://nodejs.org/dist/v6.11.2/node-v6.11.2.tar.gz
$ tar -zxvf node-v6.11.2.tar.gz
$ ./configure --prefix=/usr/local/node_6
$ make
$ make check
make -C out BUILDTYPE=Release V=1
make[1]: Entering directory `/home/endo/tmp/node-v6.11.2/out'
  touch 03a5027d2619b4eab2b3565f4103c11129ae205b.intermediate
  LD_LIBRARY_PATH=/home/endo/tmp/node-v6.11.2/out/Release/lib.host:/home/endo/tmp/node-v6.11.2/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector; mkdir -p /home/endo/tmp/node-v6.11.2/out/Release/obj/gen/blink/platform/v8_inspector/public/protocol /home/endo/tmp/node-v6.11.2/out/Release/obj/gen/blink/platform/v8_inspector/protocol /home/endo/tmp/node-v6.11.2/out/Release/obj/gen/blink/platform/inspector_protocol; python ../inspector_protocol/CodeGenerator.py --output_base "/home/endo/tmp/node-v6.11.2/out/Release/obj/gen/blink/platform" --config inspector_protocol_config_stl.json
   :
[==========] Running 26 tests from 3 test cases.
[----------] Global test environment set-up.
[----------] 2 tests from Base64Test
[ RUN      ] Base64Test.Encode
[       OK ] Base64Test.Encode (0 ms)
  :
[ RUN      ] InspectorSocketTest.ErrorCleansUpTheSocket
[       OK ] InspectorSocketTest.ErrorCleansUpTheSocket (1 ms)
[----------] 18 tests from InspectorSocketTest (39 ms total)

[----------] Global test environment tear-down
[==========] 26 tests from 3 test cases ran. (39 ms total)
[  PASSED  ] 26 tests.
make[1]: Leaving directory `/home/endo/tmp/node-v6.11.2'
/usr/local/bin/python tools/test.py --mode=release -J \
    doctool inspector known_issues message pseudo-tty parallel sequential addons
[05:00|% 100|+ 1358|-   0]: Done                                               
make lint
make[1]: Entering directory `/home/endo/tmp/node-v6.11.2'
Linting is not available through the source tarball.
Use the git repo instead: git clone https://github.com/nodejs/node.git
exit 1
make[1]: *** [lint] Error 1
make[1]: Leaving directory `/home/endo/tmp/node-v6.11.2'
make: *** [test] Error 2
$ 

make checkの最後で errorと表示されましたが、 test自体は全てpassしているようでしたので、 そのまま make installしました。

$ su
# make install
$ ls -l /usr/local/node_6/bin
total 29060
-rwxrwxr-x 1 root root 29754894 Aug 15 04:47 node
lrwxrwxrwx 1 root root       38 Aug 15 06:48 npm -> ../lib/node_modules/npm/bin/npm-cli.js

npmのpath編集

PATHへの追加が面倒でしたので

# vi /usr/local/node_6/bin/npm
old) #!/usr/bin/env node
new) #!/usr/local/node_6/bin/node

wordPress ver.4.0.17 の 余計なサービスを停止する

wp-cron.php 無効化

そもそも、wordpressのcronjob登録方法を理解していませんが

$ vi wp-config.php
define('DISABLE_WP_CRON', 'true');

ただし、メール投稿、予約投稿、XML-Sitemapも利用できなくなります

wp-mail.php

管理画面( wp-admin/options-writing.php )から メール関連の設定を空欄にすれば、OKな気がします。

feedの停止

$ vi functions.php
remove_action('do_feed_rdf', 'do_feed_rdf');
remove_action('do_feed_rss', 'do_feed_rss');
remove_action('do_feed_rss2', 'do_feed_rss2');
remove_action('do_feed_atom', 'do_feed_atom');

xmlrpc.php

$ vi functions.php
add_filter(‘xmlrpc_enabled’, ‘__return_false’);

その他、ググると、.htaccessでxmlrpc.phpへのアクセスを 禁止にしても同様の効果が得られるようです。 となると、wp-comments-post.php や wp-trackback.php も無効化できますね。

ログ出力

$ vi wp-config.php
define('WP_DEBUG', true); // デバッグモードを有効化

if ( WP_DEBUG ) {
    define( 'WP_DEBUG_LOG', true );      // debug.log ファイルに記録
    define( 'WP_DEBUG_DISPLAY', false ); // ブラウザ上に表示しない
    @ini_set( 'display_errors',0 );      // ブラウザ上に表示しない
}

らしいが、試していません。

wordPress ver.4.0.17 の source code reading

code readingと言いつつ、「読みながら & 動かしながら & ググりながら」という感じです。

が、流石 wordPress!! よくできてる!!

主要 file & dir

path note
1 wp-admin/ 管理画面
2 wp-includes/ wordpress core
3 wp-content/languages/
4 wp-content/plugins/ プラグイン
5 wp-content/themes/ テーマ
6 wp-content/upgrade/
7 index.php 1)call wp-blog-header.php 2)run wp() 3)call template-loader.php
8 wp-blog-header.php call wp-load.php
9 wp-load.php call wp-config.php
10 wp-config.php call wp-settings.php
11 wp-config-sample.php
12 wp-settings.php install時に自動生成
13 wp-activate.php install時以外は不要?
14 wp-signup.php
15 wp-login.php login
16 wp-comments-post.php comment処理
17 wp-trackback.php trackback処理
18 wp-links-opml.php opml形式でのexport?
19 wp-mail.php access triggerのmailで投稿
20 wp-cron.php access triggerの擬似cron
21 xmlrpc.php xml-rpc
  • ※詳しく見ていないphp scriptもありますが、それらは https://developer.wordpress.org/reference/ 等をご覧下さい
  • ※要件にもよりますが、NO.16以降は、攻撃者に狙われやすい気がします

通常の処理の中心は、wp-blog-header.php

詳細は、次のurlがとっても分かりやすいです。

www.warna.info

wp-content/themes/ 以下の構成

主要構成

path note
1 themes/theme-name/ thema directory
2 themes/theme-name/style.css 要meta info
3 themes/theme-name/index.php main template
4 themes/theme-name/functions.php hookによるcustomize

themes/theme-name/style.css

Main Stylesheet (style.css) | Theme Developer Handbook | WordPress Developer Resources

テーマの作成 - WordPress Codex 日本語版

単なるcssではなく、wordpressが認識するメタ情報を コメント形式( //)で記載する必要があります。

最低限、以下のように「Theme Name」だけでもwordpressは認識するようです。

/*
Theme Name: endt0tknr's test
*/

themes/theme-name/index.php

実際はリクエストに応じた複数のtemplateを用意すると思いますが、 殆ど空の index.php を用意するだけでも、動作はするようです。

themes/theme-name/functions.php

プラグイン的なhook処理を追加できるようです。

functions.php

add_filter() と add_action() の2種類のhook関数

hook関数には、値を返すadd_filter()と、返す必要のないadd_actionがあります。

add_filter($tag, $function, $priority, $args_size);
add_action($tag, $function, $priority, $args_size);
変数 note default 必須
$tag hook名 - 必須
$function 自作の関数 - 必須
$priority 優先度. 小さい程、先に実行 10 -
$args_size 引数の数 1 -

function insert_feed_posts() {  //トップページのRSS表示用関数
    $showing_number = 4;// 表示件数設定
    $corporate_url         = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    $corporate_category_id = get_cat_ID('ニュース');
    $corporate_rss         = $corporate_url . 'category/news/feed/';
    :
}
add_action('feed_get_event', 'insert_feed_posts');



function custom_editor_settings( $initArray ){
    $initArray['body_class'] = 'entry-content';
    return $initArray;
}
add_filter( 'tiny_mce_before_init', 'custom_editor_settings' );

hook名一覧

次のurlの WordPress Hooks Database ように、非常に多くのhookがあります。

adambrown.info

プラグイン API/アクションフック一覧 - WordPress Codex 日本語版

override可能な関数一覧

wp-includes/pluggable.php にある 「if ( !function_exists(‘get_userdata’) ) :」 のように記載された関数はoverride okのようです。 (この場合、get_userdata)

テンプレート階層

wordpressは、使用するtemplateをリクエスト内容に応じて選択しますが、 選択されるtemplateが一意に決定されなくても階層構造になっています。 詳細は次のurlの通りで、これを読むと、テーマには最低限 index.phpだけで十分なことがわかります。

テンプレート階層 - WordPress Codex 日本語版

wordpressの主要グローバル変数

https://wpdocs.osdn.jp/%E3%82%B0%E3%83%AD%E3%83%BC%E3%83%90%E3%83%AB%E5%A4%89%E6%95%B0 wordpress codex 等に詳細がありますが、あまりに大量の為、抜粋します

変数 note
$wp main context? 大事!!
$wpdb db access if
$wp_rewrite routing
$current_user
$id 投稿id
$post 投稿data

wordPress ver.4.0.17 に触れてみた

wordPressのシェアや、豊富なテーマやプラグインは知っていますが、軽く触れてみた感想。(以下)

  • ◯レスポンシブ対応済(テーマによりますが)
  • ◯ブログ投稿も、固定ページ作成もOK
  • ◯エンジニア不要? (あまりに豊富なテーマやプラグインもそうだし、verupも自動)
  • △verupが頻繁過ぎ? (追従できないthemeやplug-inがあるのでは)

wordPress ver.4.0.17 をapache v2.2+php v.5.6.31環境へinstall

先日構築した apache v2.2+php v.5.6.31環境へwordPress ver.4.0.17 をinstall。

今回は、単にinstallするだけで、より深い調査は別途

end0tknr.hateblo.jp

wordpress の install

create database と download wordpress

$ /usr/local/mysql/bin/mysql -u root
mysql> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8;
$ cd /home/endo/dev/Test
$ wget https://wordpress.org/wordpress-4.0.17.tar.gz
$ tar -zxvf wordpress-4.0.17.tar.gz

ブラウザで wordpress/ を設定すれば完了

wordpress installによる変化点

fileの変化点

自動でinstallされるのは、楽チンですが、何が起こっているのか、 不安?ですので、diffとってみました。以下、diff抜粋です。

ver.4.0.17 -> 4.0.18 に自動updateされたみたい

$ diff -r wordpress_org wordpress
diff -r wordpress_org/readme.html wordpress/readme.html
<    <br /> Version 4.0.17
>    <br /> Version 4.0.18

なんだか、ゴチャゴチャ変更されていましたが、ver.4.0.17 -> 4.0.18 の影響のようですね。 changelogを読めば、詳細を理解できると思いますが、今回は割愛。

diff -r wordpress_org/wp-admin/about.php wordpress/wp-admin/about.php
<    <h3><?php echo _n( 'Maintenance and Security Release', 'Maintenance and Security Releases', 17 ); ?></h3>
>    <h3><?php echo _n( 'Maintenance and Security Release', 'Maintenance and Security Releases', 18 ); ?></h3>
  :
diff -r wordpress_org/wp-admin/includes/file.php wordpress/wp-admin/includes/file.php
  :
<    $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? wp_unslash( $_POST['hostname'] ) : $credentials['hostname']);
<    $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? wp_unslash( $_POST['username'] ) : $credentials['username']);
<    $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? wp_unslash( $_POST['password'] ) : '');
---
>    $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($submitted_form['hostname']) ? $submitted_form['hostname'] : $credentials['hostname']);
>    $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($submitted_form['username']) ? $submitted_form['username'] : $credentials['username']);
>    $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($submitted_form['password']) ? $submitted_form['password'] : '');
:
diff -r wordpress_org/wp-includes/class-wp-customize-manager.php wordpress/wp-includes/class-wp-customize-manager.php
  :
diff -r wordpress_org/wp-includes/class-wp-xmlrpc-server.php wordpress/wp-includes/class-wp-xmlrpc-server.php
  :
diff -r wordpress_org/wp-includes/version.php wordpress/wp-includes/version.php
< $wp_version = '4.0.17';
> $wp_version = '4.0.18';

Only in wordpress/wp-content: upgrade

jsもゴチャゴチャ変更されていましたが、こちらもver.4.0.17 -> 4.0.18 の影響のようですね。

diff -r wordpress_org/wp-admin/js/customize-controls.js wordpress/wp-admin/js/customize-controls.js
  :
diff -r wordpress_org/wp-admin/js/customize-controls.min.js wordpress/wp-admin/js/customize-controls.min.js
  :
diff -r wordpress_org/wp-includes/js/plupload/handlers.js wordpress/wp-includes/js/plupload/handlers.js
 :
diff -r wordpress_org/wp-includes/js/plupload/handlers.min.js wordpress/wp-includes/js/plupload/handlers.min.js
 :

ブラウザで日本語を選択すると、言語packも wordpressが自動downloadするみたい

Only in wordpress/wp-content: languages

db接続情報等は、 wp-config.php に記載されていました。

Only in wordpress: wp-config.php

databaseの変化点

$ /usr/local/mysql/bin/mysql -u root wordpress;

mysql> show tables;
+-----------------------+
| Tables_in_wordpress   |
+-----------------------+
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
+-----------------------+

mysql> desc wp_commentmeta;
+------------+---------------------+------+-----+---------+----------------+
| Field      | Type                | Null | Key | Default | Extra          |
+------------+---------------------+------+-----+---------+----------------+
| meta_id    | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| comment_id | bigint(20) unsigned | NO   | MUL | 0       |                |
| meta_key   | varchar(255)        | YES  | MUL | NULL    |                |
| meta_value | longtext            | YES  |     | NULL    |                |
+------------+---------------------+------+-----+---------+----------------+

↓サンプルのコメントが登録されています

mysql> desc wp_comments;
+----------------------+---------------------+------+-----+---------------------+----------------+
| Field                | Type                | Null | Key | Default             | Extra          |
+----------------------+---------------------+------+-----+---------------------+----------------+
| comment_ID           | bigint(20) unsigned | NO   | PRI | NULL                | auto_increment |
| comment_post_ID      | bigint(20) unsigned | NO   | MUL | 0                   |                |
| comment_author       | tinytext            | NO   |     | NULL                |                |
| comment_author_email | varchar(100)        | NO   | MUL |                     |                |
| comment_author_url   | varchar(200)        | NO   |     |                     |                |
| comment_author_IP    | varchar(100)        | NO   |     |                     |                |
| comment_date         | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| comment_date_gmt     | datetime            | NO   | MUL | 0000-00-00 00:00:00 |                |
| comment_content      | text                | NO   |     | NULL                |                |
| comment_karma        | int(11)             | NO   |     | 0                   |                |
| comment_approved     | varchar(20)         | NO   | MUL | 1                   |                |
| comment_agent        | varchar(255)        | NO   |     |                     |                |
| comment_type         | varchar(20)         | NO   |     |                     |                |
| comment_parent       | bigint(20) unsigned | NO   | MUL | 0                   |                |
| user_id              | bigint(20) unsigned | NO   |     | 0                   |                |
+----------------------+---------------------+------+-----+---------------------+----------------+
15 rows in set (0.00 sec)

mysql> select * from wp_comments\G
*************************** 1. row ***************************
          comment_ID: 1
     comment_post_ID: 1
      comment_author: Mr WordPress
comment_author_email: 
  comment_author_url: https://wordpress.org/
   comment_author_IP: 
        comment_date: 2017-08-14 05:30:05
    comment_date_gmt: 2017-08-14 05:30:05
     comment_content: これはコメントです。
コメントを削除するには、ログインして投稿編集画面でコメントを表示してください。編集または削除するオプションが用意されています。
       comment_karma: 0
    comment_approved: 1
       comment_agent: 
        comment_type: 
      comment_parent: 0
             user_id: 0
1 row in set (0.00 sec)
mysql> desc wp_links;
+------------------+---------------------+------+-----+---------------------+----------------+
| Field            | Type                | Null | Key | Default             | Extra          |
+------------------+---------------------+------+-----+---------------------+----------------+
| link_id          | bigint(20) unsigned | NO   | PRI | NULL                | auto_increment |
| link_url         | varchar(255)        | NO   |     |                     |                |
| link_name        | varchar(255)        | NO   |     |                     |                |
| link_image       | varchar(255)        | NO   |     |                     |                |
| link_target      | varchar(25)         | NO   |     |                     |                |
| link_description | varchar(255)        | NO   |     |                     |                |
| link_visible     | varchar(20)         | NO   | MUL | Y                   |                |
| link_owner       | bigint(20) unsigned | NO   |     | 1                   |                |
| link_rating      | int(11)             | NO   |     | 0                   |                |
| link_updated     | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| link_rel         | varchar(255)        | NO   |     |                     |                |
| link_notes       | mediumtext          | NO   |     | NULL                |                |
| link_rss         | varchar(255)        | NO   |     |                     |                |
+------------------+---------------------+------+-----+---------------------+----------------+

tbl:wp_optionsは、selectもしましたが、様々なrecordがありましたので、 ここでは記載していません。なんだろう…

mysql> desc wp_options;
+--------------+---------------------+------+-----+---------+----------------+
| Field        | Type                | Null | Key | Default | Extra          |
+--------------+---------------------+------+-----+---------+----------------+
| option_id    | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| option_name  | varchar(64)         | NO   | UNI |         |                |
| option_value | longtext            | NO   |     | NULL    |                |
| autoload     | varchar(20)         | NO   |     | yes     |                |
+--------------+---------------------+------+-----+---------+----------------+
mysql> desc wp_postmeta;
+------------+---------------------+------+-----+---------+----------------+
| Field      | Type                | Null | Key | Default | Extra          |
+------------+---------------------+------+-----+---------+----------------+
| meta_id    | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| post_id    | bigint(20) unsigned | NO   | MUL | 0       |                |
| meta_key   | varchar(255)        | YES  | MUL | NULL    |                |
| meta_value | longtext            | YES  |     | NULL    |                |
+------------+---------------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> select * from wp_postmeta;
+---------+---------+-------------------+------------+
| meta_id | post_id | meta_key          | meta_value |
+---------+---------+-------------------+------------+
|       1 |       2 | _wp_page_template | default    |
+---------+---------+-------------------+------------+

サンプル投稿やサンプル固定ページが登録されているようです

mysql> desc wp_posts;
+-----------------------+---------------------+------+-----+---------------------+----------------+
| Field                 | Type                | Null | Key | Default             | Extra          |
+-----------------------+---------------------+------+-----+---------------------+----------------+
| ID                    | bigint(20) unsigned | NO   | PRI | NULL                | auto_increment |
| post_author           | bigint(20) unsigned | NO   | MUL | 0                   |                |
| post_date             | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| post_date_gmt         | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| post_content          | longtext            | NO   |     | NULL                |                |
| post_title            | text                | NO   |     | NULL                |                |
| post_excerpt          | text                | NO   |     | NULL                |                |
| post_status           | varchar(20)         | NO   |     | publish             |                |
| comment_status        | varchar(20)         | NO   |     | open                |                |
| ping_status           | varchar(20)         | NO   |     | open                |                |
| post_password         | varchar(20)         | NO   |     |                     |                |
| post_name             | varchar(200)        | NO   | MUL |                     |                |
| to_ping               | text                | NO   |     | NULL                |                |
| pinged                | text                | NO   |     | NULL                |                |
| post_modified         | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| post_modified_gmt     | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| post_content_filtered | longtext            | NO   |     | NULL                |                |
| post_parent           | bigint(20) unsigned | NO   | MUL | 0                   |                |
| guid                  | varchar(255)        | NO   |     |                     |                |
| menu_order            | int(11)             | NO   |     | 0                   |                |
| post_type             | varchar(20)         | NO   | MUL | post                |                |
| post_mime_type        | varchar(100)        | NO   |     |                     |                |
| comment_count         | bigint(20)          | NO   |     | 0                   |                |
+-----------------------+---------------------+------+-----+---------------------+----------------+
23 rows in set (0.00 sec)

mysql> select * from wp_posts\G
*************************** 1. row ***************************
                   ID: 1
          post_author: 1
            post_date: 2017-08-14 05:30:05
        post_date_gmt: 2017-08-14 05:30:05
         post_content: WordPress へようこそ。これは最初の投稿です。編集もしくは削除してブログを始めてください !
           post_title: Hello world!
         post_excerpt: 
          post_status: publish
       comment_status: open
          ping_status: open
        post_password: 
            post_name: hello-world
              to_ping: 
               pinged: 
        post_modified: 2017-08-14 05:30:05
    post_modified_gmt: 2017-08-14 05:30:05
post_content_filtered: 
          post_parent: 0
                 guid: http://cent7.a5.jp:8081/wordpress/?p=1
           menu_order: 0
            post_type: post
       post_mime_type: 
        comment_count: 1
*************************** 2. row ***************************
                   ID: 2
          post_author: 1
            post_date: 2017-08-14 05:30:05
        post_date_gmt: 2017-08-14 05:30:05
         post_content: これはサンプルページです。同じ位置に固定され、(多くのテーマでは) サイトナビゲーションメニューに含まれるため、ブログ投稿とは異なります。サイト訪問者に対して自分のことを説明する自己紹介ページを作成するのが一般的です。たとえば以下のようなものになります。 

<blockquote>はじめまして。昼間はバイク便のメッセンジャーとして働いていますが、俳優志望でもあります。これは僕のブログです。ロサンゼルスに住み、ジャックという名前のかわいい犬を飼っています。好きなものはピニャコラーダ (通り雨に濡れるのも) 。</blockquote>

または、このようなものでもよいでしょう。

<blockquote>XYZ 小道具株式会社は1971年の創立以来、高品質の小道具を皆様にご提供させていただいています。ゴッサム・シティに所在する当社では2,000名以上の社員が働いており、様々な形で地域のコミュニティへ貢献しています。</blockquote>

新しく WordPress ユーザーになった方は、<a href="http://cent7.a5.jp:8081/wordpress/wp-admin/">ダッシュボード</a>へ行ってこのページを削除し、独自のコンテンツを含む新しいページを作成してください。それでは、お楽しみください !
           post_title: サンプルページ
         post_excerpt: 
          post_status: publish
       comment_status: open
          ping_status: open
        post_password: 
            post_name: sample-page
              to_ping: 
               pinged: 
        post_modified: 2017-08-14 05:30:05
    post_modified_gmt: 2017-08-14 05:30:05
post_content_filtered: 
          post_parent: 0
                 guid: http://cent7.a5.jp:8081/wordpress/?page_id=2
           menu_order: 0
            post_type: page
       post_mime_type: 
        comment_count: 0
*************************** 3. row ***************************
                   ID: 3
          post_author: 1
            post_date: 2017-08-14 14:30:14
        post_date_gmt: 0000-00-00 00:00:00
         post_content: 
           post_title: 自動下書き
         post_excerpt: 
          post_status: auto-draft
       comment_status: open
          ping_status: open
        post_password: 
            post_name: 
              to_ping: 
               pinged: 
        post_modified: 2017-08-14 14:30:14
    post_modified_gmt: 0000-00-00 00:00:00
post_content_filtered: 
          post_parent: 0
                 guid: http://cent7.a5.jp:8081/wordpress/?p=3
           menu_order: 0
            post_type: post
       post_mime_type: 
        comment_count: 0
3 rows in set (0.00 sec)
mysql> desc wp_term_relationships;
+------------------+---------------------+------+-----+---------+-------+
| Field            | Type                | Null | Key | Default | Extra |
+------------------+---------------------+------+-----+---------+-------+
| object_id        | bigint(20) unsigned | NO   | PRI | 0       |       |
| term_taxonomy_id | bigint(20) unsigned | NO   | PRI | 0       |       |
| term_order       | int(11)             | NO   |     | 0       |       |
+------------------+---------------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> select * from wp_term_relationships;
+-----------+------------------+------------+
| object_id | term_taxonomy_id | term_order |
+-----------+------------------+------------+
|         1 |                1 |          0 |
+-----------+------------------+------------+

taxonomy = 分類?

mysql> desc wp_term_taxonomy;
+------------------+---------------------+------+-----+---------+----------------+
| Field            | Type                | Null | Key | Default | Extra          |
+------------------+---------------------+------+-----+---------+----------------+
| term_taxonomy_id | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| term_id          | bigint(20) unsigned | NO   | MUL | 0       |                |
| taxonomy         | varchar(32)         | NO   | MUL |         |                |
| description      | longtext            | NO   |     | NULL    |                |
| parent           | bigint(20) unsigned | NO   |     | 0       |                |
| count            | bigint(20)          | NO   |     | 0       |                |
+------------------+---------------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)

mysql> select * from wp_term_taxonomy;
+------------------+---------+----------+-------------+--------+-------+
| term_taxonomy_id | term_id | taxonomy | description | parent | count |
+------------------+---------+----------+-------------+--------+-------+
|                1 |       1 | category |             |      0 |     1 |
+------------------+---------+----------+-------------+--------+-------+
mysql> desc wp_terms;
+------------+---------------------+------+-----+---------+----------------+
| Field      | Type                | Null | Key | Default | Extra          |
+------------+---------------------+------+-----+---------+----------------+
| term_id    | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| name       | varchar(200)        | NO   | MUL |         |                |
| slug       | varchar(200)        | NO   | UNI |         |                |
| term_group | bigint(10)          | NO   |     | 0       |                |
+------------+---------------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> select * from wp_terms;
+---------+-----------+-----------------------------+------------+
| term_id | name      | slug                        | term_group |
+---------+-----------+-----------------------------+------------+
|       1 | 未分類    | %e6%9c%aa%e5%88%86%e9%a1%9e |          0 |
+---------+-----------+-----------------------------+------------+
1 row in set (0.00 sec)

nickname=adminは、私が管理者として入力したidです

mysql> desc wp_usermeta;
+------------+---------------------+------+-----+---------+----------------+
| Field      | Type                | Null | Key | Default | Extra          |
+------------+---------------------+------+-----+---------+----------------+
| umeta_id   | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| user_id    | bigint(20) unsigned | NO   | MUL | 0       |                |
| meta_key   | varchar(255)        | YES  | MUL | NULL    |                |
| meta_value | longtext            | YES  |     | NULL    |                |
+------------+---------------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> select * from wp_usermeta;
+----------+---------+---------------------------------------+---------------------------------------------------------------------------------------------+
| umeta_id | user_id | meta_key                              | meta_value                                                                                  |
+----------+---------+---------------------------------------+---------------------------------------------------------------------------------------------+
|        1 |       1 | nickname                              | admin                                                                                       |
|        2 |       1 | first_name                            |                                                                                             |
|        3 |       1 | last_name                             |                                                                                             |
|        4 |       1 | description                           |                                                                                             |
|        5 |       1 | rich_editing                          | true                                                                                        |
|        6 |       1 | comment_shortcuts                     | false                                                                                       |
|        7 |       1 | admin_color                           | fresh                                                                                       |
|        8 |       1 | use_ssl                               | 0                                                                                           |
|        9 |       1 | show_admin_bar_front                  | true                                                                                        |
|       10 |       1 | wp_capabilities                       | a:1:{s:13:"administrator";b:1;}                                                             |
|       11 |       1 | wp_user_level                         | 10                                                                                          |
|       12 |       1 | dismissed_wp_pointers                 | wp350_media,wp360_revisions,wp360_locks,wp390_widgets                                       |
|       13 |       1 | show_welcome_panel                    | 1                                                                                           |
|       14 |       1 | session_tokens                        | a:1:{s:64:"b37504ae3e92ef97a98b2f0e34324081b42498e66f90872d23d34b21739445da";i:1502861411;} |
|       15 |       1 | wp_user-settings                      | editor=html&wplink=1                                                                        |
|       16 |       1 | wp_user-settings-time                 | 1502688609                                                                                  |
|       17 |       1 | wp_dashboard_quick_press_last_post_id | 3                                                                                           |
+----------+---------+---------------------------------------+---------------------------------------------------------------------------------------------+
17 rows in set (0.00 sec)
mysql> desc wp_users;
+---------------------+---------------------+------+-----+---------------------+----------------+
| Field               | Type                | Null | Key | Default             | Extra          |
+---------------------+---------------------+------+-----+---------------------+----------------+
| ID                  | bigint(20) unsigned | NO   | PRI | NULL                | auto_increment |
| user_login          | varchar(60)         | NO   | MUL |                     |                |
| user_pass           | varchar(64)         | NO   |     |                     |                |
| user_nicename       | varchar(50)         | NO   | MUL |                     |                |
| user_email          | varchar(100)        | NO   |     |                     |                |
| user_url            | varchar(100)        | NO   |     |                     |                |
| user_registered     | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| user_activation_key | varchar(60)         | NO   |     |                     |                |
| user_status         | int(11)             | NO   |     | 0                   |                |
| display_name        | varchar(250)        | NO   |     |                     |                |
+---------------------+---------------------+------+-----+---------------------+----------------+
10 rows in set (0.00 sec)

mysql> select * from wp_users\G
*************************** 1. row ***************************
                 ID: 1
         user_login: admin
          user_pass: $P$BqSk6XN58YkpWWUILgkrS2Ulshibp51
      user_nicename: admin
         user_email: ないしょ
           user_url: 
    user_registered: 2017-08-14 05:30:05
user_activation_key: 
        user_status: 0
       display_name: admin
1 row in set (0.01 sec)

install apache 2.4.27 & mod_perl 2.0.10 ...なぜなら、Apache httpd 2.2.34 Released End-of-Life 2017-07-11

2017/7/11にapache 2.2系のEOLとなるver.2.2.34がreleaseされました。

過去、apache2.2+mod_perlベースのサービス提供していましたが、 apache2.4+mod_perlのbuildを自身では行ったことがない為、メモ。

Apache httpd 2.2.34 Released End-of-Life 2017-07-11

The Apache HTTP Server Project announces the release of version 2.2.34, the final release of the Apache httpd 2.2 series. This version will be the last release of the 2.2 legacy branch. (Version number 2.2.33 was not released.)

The Apache HTTP Server Project has long committed to providing maintenance releases of the 2.2.x flavor through June of 2017, and may continue to publish some security source code patches beyond this date through December of 2017. No further maintenance patches nor releases of 2.2.x are anticipated. Any final security patches will be published to www.apache.org/dist/httpd/patches/apply_to_2.2.34/

Welcome! - The Apache HTTP Server Project

動的module (DSO)でinstall

以前は「安定している」という噂で、apachemod_perlをまとめてbuildする 「静的module」でinstallしていましたが、 いつだったか、buildに失敗してからは、動的module (DSO)でinstallしています。

今回もDSOでinstallしますが、静的moduleでのinstall方法は次のurlをご覧下さい。

end0tknr.hateblo.jp

apacheのinstall

※最近は、aprapr-utilは、apache本体とは別に配布されています

$ wget http://ftp.meisei-u.ac.jp/mirror/apache/dist/httpd/httpd-2.4.27.tar.gz

$ tar -xvf httpd-2.4.27.tar.gz
$ cd httpd-2.4.27/srclib

$ wget http://ftp.kddilabs.jp/infosystems/apache/apr/apr-1.6.2.tar.gz
$ tar -zxvf apr-1.6.2.tar.gz
$ mv apr-1.6.2 apr

$ wget http://ftp.kddilabs.jp/infosystems/apache/apr/apr-util-1.6.0.tar.gz
$ tar -zxvf apr-util-1.6.0.tar.gz
$ mv apr-util-1.6.0 apr-util

$ cd ..
$ ./configure --prefix=/sing/local/httpd \
            --enable-mpms-shared=all \
            --enable-proxy \
            --enable-modules=all \
            --enable-so

    :
configure: summary of build options:
    Server Version: 2.4.27
    Install prefix: /home/endo/local/apache24
    C compiler:     gcc -std=gnu99
    CFLAGS:          -g -O2 -pthread
    LDFLAGS:         
    LIBS:           
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE
    C preprocessor: gcc -E

$ make
$ make install

mod_perlのinstall

wget http://ftp.jaist.ac.jp/pub/apache/perl/mod_perl-2.0.10.tar.gz
tar -zxvf mod_perl-2.0.10.tar.gz
cd mod_perl-2.0.10
$ /usr/local/bin/perl Makefile.PL MP_APXS=/home/endo/local/apache24/bin/apxs
$ make
$ make test
   :
Test Summary Report
-------------------
t/apache/read.t                       (Wstat: 0 Tests: 1 Failed: 1)
  Failed test:  1
t/filter/in_bbs_inject_header.t       (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 36 tests but ran 0.
Files=245, Tests=4679, 130 wallclock secs ( 1.23 usr  0.70 sys + 87.24 cusr 22.99 csys = 112.16 CPU)
Result: FAIL
Failed 2/245 test programs. 1/4679 subtests failed.
[warning] server localhost:8529 shutdown
[  error] error running tests (please examine t/logs/error_log)
+--------------------------------------------------------+
| Please file a bug report: http://perl.apache.org/bugs/ |
+--------------------------------------------------------+
make: *** [run_tests] Error 1
$

t/apache/read.t や t/filter/in_bbs_inject_header.t のtestでfailしましたが、無視しました。 ググると、t/apache/read.t の方は 「for my $string ("POST $location http/1.0",」→「for my $string ("POST $location http/1.0",」 のように修正することでpassしますが、「passさせてよいのやら」という気もします。

$ su
# make install

edit httpd.conf & startup.pl

$ vi /home/endo/local/apache24/conf/httpd.conf
  :
LoadModule perl_module modules/mod_perl.so
PerlRequire /home/endo/local/apache24/conf/startup.pl

PerlSetEnv XING_CONF     /home/endo/dev/xing/etc/config.yaml

<Directory "/home/endo/dev/xing/app">
    AllowOverride All
    Order allow,deny
    Allow from all

    AuthType BASIC
    AuthUserFile /home/endo/dev/htpasswd
    AuthName "COLINUX MEMBERS"
    require valid-user

    <Files "*.pl">
       Options ExecCGI
       AddHandler cgi-script .pl
       SetHandler perl-script
       PerlHandler ModPerl::Registry
       PerlSendHeader On
    </Files>
</Directory>
Alias /Xing /home/endo/dev/xing/app
$ vi /home/endo/local/apache22/conf/startup.pl
  :
#/usr/local/bin/perl

BEGIN {
    use lib qw(.
               /home/endo/dev/xing/lib
             );
}

use SDW::Template;
$SDW::Template::ENCODING = 'utf8';
@SDW::Template::template_path=('/home/endo/dev/xing/tmpl');

use CGI;
$CGI::LIST_CONTEXT_WARN = 0;

#use Devel::Cover;
#$DEVEL_COVER_OPTIONS='-dir,/home/endo/tmp';

1;

install php ver.5.6.31 , and setup apache httpd 2.2

wordpress ver.4.0.17が php ver.7.1 に未対応でしたので、 懲りずに、php 5.6.31 をinstall。

end0tknr.hateblo.jp

end0tknr.hateblo.jp

end0tknr.hateblo.jp

php前準備

openssl以外は、前回、php ver.7.1 のエントリと同様ですので、割愛します。

end0tknr.hateblo.jp

openssl 1.0.2

php 5.6に対して、openssl 1.1.0は未対応のようでしたので、 openssl 1.0.2lをinstallしています。

$ wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz
$ tar -zxvf openssl-1.0.2l.tar.gz
$ cd openssl-1.0.2l
$ ./config --prefix=/usr/local/openssl_1_0_2 shared
$ make
$ make test
$ su
# make install

php

$ wget http://php.net/get/php-5.6.31.tar.gz
$ tar -zxvf php-5.6.31.tar.gz
$ cd php-5.6.31
$ ./configure \
  --with-apxs2=/home/endo/local/apache22/bin/apxs \
  --enable-mbstring \
  --with-mysqli=/usr/local/mysql/bin/mysql_config \
  --with-pdo-mysql=/usr/local/mysql \
  --with-openssl=/usr/local/openssl_1_0_2 \
  --with-zlib=/usr

$ make
$ make test
$ su
# make install

# cp php.ini-development /usr/local/lib/php.ini

apache 2.2 との連携

httpd.conf

phpのconfigure optionで 「with-apxs2=/home/endo/local/apache22/bin/apxs」指定してますので 「modules/libphp5.so」は自動追加されているはずです。

それ以外は、自身で追加して下さい。

LoadModule php5_module        modules/libphp5.so
AddType application/x-httpd-php .php

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

phpinfo.php による動作確認 <?php phpinfo(); ?> こちらも、前回のphp 7.1のエントリと同様です

end0tknr.hateblo.jp

install php ver.7.1.8 , and setup apache httpd 2.2

過去、phpは何度かinstallしていますが、今回は php ver.7.1.8

end0tknr.hateblo.jp

end0tknr.hateblo.jp

2017.8.11追記

このエントリを記載後、wordpress ver.4.0.17をinstallしましたが、wordpressのwed管理画面で 次のようなエラーが表示されました。 wordpress ver.4.0.17は、php ver.7.1に未対応のようですので、今回はココまでにします。

Warning: Parameter 1 to wp_default_styles() expected to be a reference, value given in wordpress/wp-includes/plugin.php on line 580

php前準備

php-7.1.8/INSTALL を参照したり、make中のerror messageを参照しながら、 以下を、install

re2c - lexer generator for C/C++

http://re2c.org/

$ wget https://github.com/skvadrik/re2c/releases/download/0.16/re2c-0.16.tar.gz
$ tar -zxvf re2c-0.16.tar.gz
$ cd re2c-0.16
$ ./configure
$ make
$ make check
$ su
# make install

flex - lexical analyser

https://sourceforge.net/projects/flex/files/

$ wget https://sourceforge.net/projects/flex/files/flex-2.6.0.tar.gz
$ tar -zxvf flex-2.6.0.tar.gz
$ cd flex-2.6.0
$ ./configure
$ make
$ make check
$ su
# make install

bison - general-purpose parser generator

https://www.gnu.org/software/bison/

$ wget http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz
$ tar -zxvf bison-3.0.4.tar.gz
$ cd bison-3.0.4
$ ./configure
$ make
$ make check
$ su
# make install

libxml2-devel

# yum install libxml2-devel

ICU - International Components for Unicode

$ wget http://download.icu-project.org/files/icu4c/59.1/icu4c-59_1-src.tgz
$ tar -zxvf icu4c-59_1-src.tgz
$ cd icu/source
$ ./configure
$ make
$ make check
$ su
# make install

openssl

以前、installしたものは 非sharedだったようですので

$ wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
$ tar -zxvf openssl-1.1.0f.tar.gz
$ cd openssl-1.1.0f
$ ./config --prefix=/usr/local/openssl_1_1_0 shared
$ make
$ make test
$ su
# make install

zlib-devel の install dirを調査

configureのoptionで指定しますので

# yum install zlib-devel
   Package zlib-devel-1.2.7-17.el7.x86_64 already installed and latest version
$ rpm -ql zlib-devel-1.2.7-17.el7.x86_64

php

$ tar -zxvf php-7.1.8.tar.gz
$ cd php-7.1.8
$ ./configure \
  --with-apxs2=/home/endo/local/apache22/bin/apxs \
  --enable-mbstring \
  --with-mysqli=/usr/local/mysql/bin/mysql_config \
  --with-pdo-mysql=/usr/local/mysql \
  --with-openssl=/usr/local/openssl_1_1_0 \
  --with-zlib=/usr

$ make
$ make test
   :
mysqli_release_savepoint() [ext/mysqli/tests/mysqli_release_savepoint.phpt]
mysqli_report() [ext/mysqli/tests/mysqli_report.phpt]
mysqli_report(), change user, MySQL 5.6+ [ext/mysqli/tests/mysqli_report_new.phpt]
mysqli_store_result() [ext/mysqli/tests/mysqli_store_result_buffered_c.phpt]
Bug #66141 (mysqlnd quote function is wrong with NO_BACKSLASH_ESCAPES after failed query) [ext/pdo_mysql/tests/bug66141.phpt]
Bug #70389 (PDO constructor changes unrelated variables) [ext/pdo_mysql/tests/bug70389.phpt]
Bug #61411 (PDO Segfaults with PERSISTENT == TRUE && EMULATE_PREPARES == FALSE) [ext/pdo_mysql/tests/bug_61411.phpt]
MySQL PDO->__construct() - Generic + DSN [ext/pdo_mysql/tests/pdo_mysql___construct.phpt]
PDO::ATTR_ORACLE_NULLS [ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt]
PDO MySQL specific class constants [ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt]
MySQL PDO->exec(), affected rows [ext/pdo_mysql/tests/pdo_mysql_exec.phpt]
=====================================================================

=====================================================================
WARNED TEST SUMMARY
---------------------------------------------------------------------
MySQL PDO->prepare(), emulated PS [ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt] (warn: XFAIL section but test passes)
=====================================================================
$ su
# make install

# cp php.ini-development /usr/local/lib/php.ini

apache 2.2 との連携

httpd.conf

phpのconfigure optionで 「with-apxs2=/home/endo/local/apache22/bin/apxs」指定してますので 「modules/libphp7.so」は自動追加されているはずです。

それ以外は、自身で追加して下さい。

LoadModule php7_module        modules/libphp7.so
AddType application/x-httpd-php .php

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

phpinfo.php による動作確認

<?php
phpinfo();
?>

↑このようなphp scriptを用意し、アクセスすると↓このように表示されます。

画像が長すぎて読めないかもしれませんが f:id:end0tknr:20170811105310p:plain