【WordPress】ワードプレスをローカルで設定するために... [2] PHPの設定 その2

■ はじめに

 * ワードプレスをローカルで設定するためには、以下「手順概要」のように行う必要がある
  => 今回は、『【2】 PHPの設定 その2』を行う
『【2】 PHPの設定 その1』は、以下の関連記事を参照のこと
https://blogs.yahoo.co.jp/dk521123/21462379.html
 * BitNami, XAMPPであれば、もっと簡単にできるみたいだが、とりあえず今回は一から自分で行ってみる。
  => XAMPP での構築は、以下の関連記事を参照のこと
ワードプレスを XAMPP で簡単にローカルに設定する
https://blogs.yahoo.co.jp/dk521123/33377152.html

設定環境

 * OS : Windows Xp
 * Web Server : Apache Ver2.2.17
 * PHP : PHP Ver5.3.4
 * DB : MySQL Ver5.5.8
 * WordPress : WordPress Ver3.0.4

手順概要

【1】 Webサーバ:Apacheの設定
https://blogs.yahoo.co.jp/dk521123/21460962.html
【2】 PHPの設定
https://blogs.yahoo.co.jp/dk521123/21462379.html
https://blogs.yahoo.co.jp/dk521123/21466481.html
【3】 MySQLの設定
https://blogs.yahoo.co.jp/dk521123/21467820.html
【4】 WordPressの設定
https://blogs.yahoo.co.jp/dk521123/21462088.html

【2】 PHPの設定 その2

php.iniの設定 その2

http://www.phpbook.jp/install/phpini/index3.html
を参考に設定する
1)「C:\php\php.ini」をテキストエディタで開き、L810付近に「extension_dir = "c:\php\ext";」を追記する(以下の「php.ini」を参考)

2)L790付近に「include_path = ".;c:\php\includes;c:\php\pear"」を追記する(以下の「php.ini」を参考)

3)日本語に対応するために、以下を設定する(以下の「php.ini」を参考)
・L959付近の「;extension=php_mbstring.dll」を「;」を削除して、「extension=php_mbstring.dll」に変更する
・L1751付近の「;mbstring.language = Japanese」を「;」を削除して、「mbstring.language = Japanese」に変更する
・L1757付近の「;mbstring.internal_encoding = ・・・」を「;」を削除して、「mbstring.internal_encoding = UTF-8」に変更する
・L1761付近の「;mbstring.http_input = ・・・」を「;」を削除して、「mbstring.http_input = pass」に変更する
・L1766付近の「;mbstring.http_output = ・・・」を「;」を削除して、「mbstring.http_output = pass」に変更する
・L1774付近の「;mbstring.encoding_translation = ・・・」を「;」を削除して、「mbstring.encoding_translation = Off」に変更する
・L1779付近の「;mbstring.detect_order = auto」を「;」を削除して、「mbstring.detect_order = UTF-8,SJIS,EUC-JP,JIS,ASCII」に変更する
・L1785付近の「;mbstring.substitute_character = none;」を「;」を削除して、「mbstring.substitute_character = none;」に変更する
・L1799付近の「;mbstring.strict_detection = Off」を「;」を削除して、「mbstring.strict_detection = Off」に変更する
・L1799付近の「;mbstring.strict_detection = Off」を「;」を削除して、「mbstring.strict_detection = Off」に変更する

■確認
4)ブラウザを起動し、URL欄に
http://localhost:8080/phpinfo.php
を入力し、Enter押下して、以下を確認すること。
※Apacheを再起動する必要があります。

・「extension_dir:c:\php\ext」が設定されていることが確認すること。
・「include_path:.;c:\php\includes;c:\php\pear」が設定されていることが確認すること。
・「mbstring」欄に「mbstring.detect_order:	UTF-8,SJIS,EUC-JP,JIS,ASCII」などが設定されていることが確認すること。

php.ini

・・・
; http://php.net/include-path
;↓を追記する(L790付近)
include_path = ".;c:\php\includes;c:\php\pear"

; The root of the PHP pages, used only if nonempty.
・・・
; extension_dir = "ext"
;↓を追記する(L810付近)
extension_dir = "c:\php\ext";

; Whether or not to enable the dl() function.  The dl() function does NOT work
・・・
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_exif.dll      ; Must be after mbstring as it depends on it
・・・
[mbstring]
; language for internal character representation.
; http://php.net/mbstring.language
mbstring.language = Japanese


・・・略・・・
; http://php.net/mbstring.internal-encoding
mbstring.internal_encoding = UTF-8

; http input encoding.
; http://php.net/mbstring.http-input
mbstring.http_input = pass


・・・略・・・
; http://php.net/mbstring.http-output
mbstring.http_output = pass

・・・略・・・
; http://php.net/mbstring.encoding-translation
mbstring.encoding_translation = Off

・・・略・・・
; http://php.net/mbstring.detect-order
mbstring.detect_order = UTF-8,SJIS,EUC-JP,JIS,ASCII

; substitute_character used when character cannot be converted
; one from another
; http://php.net/mbstring.substitute-character
mbstring.substitute_character = none;
・・・
; enable strict encoding detection.
mbstring.strict_detection = Off

Apacheの設定

http://www.adminweb.jp/apache/php/
を参考に設定する
1)以下のパスにある「httpd.conf」をテキストエディタで開く
C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf

2)L128付近の「#LoadModule vhost_alias_module modules/mod_vhost_alias.so」の下に、以下の内容を追記する

・「LoadModule php5_module c:/php/php5apache2_2.dll」を追記する
・「AddHandler application/x-httpd-php .php」を追記する
・「PHPIniDir "C:/php"」を追記する

3)L399付近の「AddHandler cgi-script .cgi」の下に、以下の内容を追記する

・「AddType application/x-httpd-php .php」を追記する
・「AddType application/x-httpd-php-source .phps」を追記する

■確認
4)ブラウザを起動し、URL欄に
http://localhost:8080/phpinfo.php
を入力し、Enter押下して、PHPに関する設定が表示されていることを確認する。
※Apacheを再起動する必要があります。

httpd.conf

#LoadModule vhost_alias_module modules/mod_vhost_alias.so

LoadModule php5_module c:/php/php5apache2_2.dll
AddHandler application/x-httpd-php .php

# php.ini へのパスを設定します
PHPIniDir "C:/php"
・・・
    AddHandler cgi-script .cgi
    # ↓追記する
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
・・・

関連記事

ワードプレスをローカルで設定するために... [1] Apacheの設定

https://blogs.yahoo.co.jp/dk521123/21460962.html

ワードプレスを XAMPP で簡単にローカルに設定する

https://blogs.yahoo.co.jp/dk521123/33377152.html