| 1 | = php5 = |
| 2 | |
| 3 | == 初期設定 == |
| 4 | === Apache2モジュールを利用する場合 === |
| 5 | |
| 6 | VinePlusで提供しているphp5-apache2パッケージでは、Apacheをprefork MPMで起動していないと動作しません。 |
| 7 | |
| 8 | 1. 以下のパッケージをインストールする。 |
| 9 | * apache2 |
| 10 | * php5-apache2 |
| 11 | 1. Apacheをprefork MPMに切り替える。 |
| 12 | {{{ |
| 13 | $ sudo /sbin/update-alternatives --config apache2 |
| 14 | |
| 15 | 2 プログラムがあり 'apache2' を提供します。 |
| 16 | |
| 17 | 選択 コマンド |
| 18 | ----------------------------------------------- |
| 19 | + 1 /usr/sbin/apache2.worker |
| 20 | * 2 /usr/sbin/apache2.prefork |
| 21 | Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2 |
| 22 | }}} |
| 23 | |
| 24 | === Apache2でFastCGIを利用する場合 === |
| 25 | |
| 26 | こちらではApacheのMPM制限はなく、お好みのものを利用できます (worker推奨)。 |
| 27 | |
| 28 | 1. 以下のパッケージをインストールする。 |
| 29 | * apache2 |
| 30 | * mod_fcgid-apache2 |
| 31 | * php5 (php5-apache2は不要) |
| 32 | 1. /etc/apache2/conf.d/mod_fcgid.confを以下のように編集する。 |
| 33 | {{{ |
| 34 | <IfModule !mod_fcgid.c> |
| 35 | LoadModule fcgid_module modules/mod_fcgid.so |
| 36 | </IfModule> |
| 37 | <IfModule mod_fcgid.c> |
| 38 | FcgidIPCDir /tmp/fcgid_sock/ |
| 39 | </IfModule> |
| 40 | }}} |
| 41 | 1. httpd.confの必要な箇所(バーチャルホスト定義内、等)に以下の記述を追加する。 |
| 42 | {{{ |
| 43 | <IfModule mod_fcgid.c> |
| 44 | AddHandler fcgid-script .php |
| 45 | FcgidWrapper /usr/bin/php5-cgi .php |
| 46 | </IfModule> |
| 47 | }}} |
| 48 | |
| 49 | === nginxでFastCGIを利用する場合 === |
| 50 | |
| 51 | 1. 以下のパッケージをインストールする。 |
| 52 | * nginx |
| 53 | * php5-fpm |
| 54 | 2. /etc/nginx/php.confを以下の内容で作成する。 |
| 55 | {{{ |
| 56 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; |
| 57 | fastcgi_param SERVER_SOFTWARE nginx; |
| 58 | |
| 59 | fastcgi_param QUERY_STRING $query_string; |
| 60 | fastcgi_param REQUEST_METHOD $request_method; |
| 61 | fastcgi_param CONTENT_TYPE $content_type; |
| 62 | fastcgi_param CONTENT_LENGTH $content_length; |
| 63 | |
| 64 | fastcgi_split_path_info ^(.+\.php)(/.+)?$; |
| 65 | fastcgi_param PATH_INFO $fastcgi_path_info; |
| 66 | fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; |
| 67 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| 68 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; |
| 69 | fastcgi_param REQUEST_URI $request_uri; |
| 70 | fastcgi_param DOCUMENT_URI $document_uri; |
| 71 | fastcgi_param DOCUMENT_ROOT $document_root; |
| 72 | fastcgi_param SERVER_PROTOCOL $server_protocol; |
| 73 | |
| 74 | fastcgi_param REMOTE_ADDR $remote_addr; |
| 75 | fastcgi_param REMOTE_PORT $remote_port; |
| 76 | fastcgi_param SERVER_ADDR $server_addr; |
| 77 | fastcgi_param SERVER_PORT $server_port; |
| 78 | fastcgi_param SERVER_NAME $server_name; |
| 79 | |
| 80 | # PHP only, required if PHP was built with –enable-force-cgi-redirect |
| 81 | fastcgi_param REDIRECT_STATUS 200; |
| 82 | |
| 83 | fastcgi_pass unix:/tmp/php-fpm.sock; |
| 84 | fastcgi_ignore_client_abort on; |
| 85 | }}} |
| 86 | 1. nginx設定ファイルの必要な箇所(http, server, locationブロック)に以下の記述を追加する。 |
| 87 | {{{ |
| 88 | location ~ \.php |
| 89 | { |
| 90 | include php.conf; |
| 91 | } |
| 92 | }}} |
| 93 | 1. 必要に応じて/etc/php5/php-fpm.conf, /etc/php5/fpm.d/*の設定を変更する。 |