centos:centos_nginx_php
差分
このページの2つのバージョン間の差分を表示します。
| 次のリビジョン | 前のリビジョン | ||
| centos:centos_nginx_php [2013/02/13 05:46] – 外部編集 127.0.0.1 | centos:centos_nginx_php [2025/02/16 13:53] (現在) – 外部編集 127.0.0.1 | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| ====== 即効 環境構築 | ====== 即効 環境構築 | ||
| - | ○ SELINUX 設定 | + | ===== SELINUX |
| + | |||
| + | {{page> | ||
| + | |||
| + | ===== iptables(ファイアウォール)===== | ||
| + | |||
| + | {{section> | ||
| + | {{section> | ||
| + | |||
| + | ===== nginx ===== | ||
| + | |||
| + | {{page> | ||
| + | |||
| + | ===== PHPと関連モジュール ===== | ||
| < | < | ||
| - | + | # yum -y --enablerepo=remi install php php-mbstring php-mysql php-pear php-devel | |
| - | # getenforce ← SELinux状態確認 | + | # vi / |
| - | Enforcing ← SELinux有効 | + | 869c869 |
| - | + | < date.timezone = " | |
| - | # setenforce 0 ← SELinux無効化 | + | --- |
| - | + | > ; | |
| - | # getenforce ← SELinux状態確認 | + | 1350c1350 |
| - | Permissive ← SELinux無効 | + | < session.save_path = "/ |
| - | + | --- | |
| - | # vi /etc/sysconfig/selinux ← SELinux設定ファイル編集 | + | > ; |
| - | SELINUX=enforcing | + | # ll /var/lib/php/ |
| - | ↓ | + | 合計 4 |
| - | SELINUX=disabled ← システム起動時にSELinuxを無効化 | + | drwxrwx---. 2 root apache 4096 10月 16 17:24 2014 session |
| - | + | # chown -R root.nginx / | |
| - | + | # ll / | |
| + | 合計 4 | ||
| + | drwxrwx---. 2 root nginx 4096 10月 16 17:24 2014 session | ||
| </ | </ | ||
| - | ○ iptables(ファイアウォール)設定 | ||
| + | ===== APC(PHP用アクセラレータ) ===== | ||
| < | < | ||
| - | # vi / | + | # yum -y --enablerepo=remi install gcc |
| - | + | # pecl install apc | |
| - | -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT | + | # echo " |
| - | + | ||
| - | # /etc/rc.d/init.d/iptables restart | + | |
| - | + | ||
| - | 起動確認 | + | |
| - | httpサーバ(nginxなど)を動かして、ブラウザからアクセス | + | |
| - | + | ||
| </ | </ | ||
| - | ○ nginx | + | |
| + | ===== PHP-FPM ===== | ||
| < | < | ||
| - | ● EPELリポジトリを登録 | + | # yum -y --enablerepo=remi install php-fpm |
| - | # rpm -Uvh http://download.fedora.redhat.com/ | + | # vi /etc/php-fpm.d/www.conf |
| - | + | 39c39 | |
| - | ● nginx インストール | + | < user = nginx |
| - | # yum -y install nginx | + | --- |
| - | + | > user = apache | |
| - | ● 設定 | + | 41c41 |
| - | デフォルトの document | + | < group = nginx |
| - | その他、設定ファイル確認 | + | --- |
| - | + | > group = apache | |
| - | # vi /etc/nginx/nginx.conf | + | |
| - | + | nginx への設定追加 | |
| - | ● nginx 起動 | + | # vi / |
| - | # /etc/init.d/nginx start | + | |
| - | + | 9,10c9,10 | |
| - | ● 自動起動設定 | + | < |
| - | # chkconfig nginx on | + | < |
| - | + | --- | |
| - | ● 本ドキュメント最下部に SSL の設定例あり | + | > root |
| - | + | > | |
| + | 30,36c30,36 | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < } | ||
| + | --- | ||
| + | > #location ~ \.php$ { | ||
| + | > # | ||
| + | > # | ||
| + | > # | ||
| + | > # | ||
| + | > # | ||
| + | > #} | ||
| + | PHP-FPM 起動 | ||
| + | # / | ||
| + | 自動起動設定 | ||
| + | # chkconfig php-fpm on | ||
| + | |||
| + | nginx 再起動(設定反映) | ||
| + | # / | ||
| </ | </ | ||
| - | ○ PHP 5.3 | + | |
| - | < | + | ===== TokyoCabinet/TokyoTyrant ===== |
| - | ● remiリポジトリを登録 | + | |
| - | # rpm -Uvh http:// | + | |
| - | + | ||
| - | ● PHP インストール | + | |
| - | # yum -y --enablerepo=remi install php | + | |
| - | + | ||
| - | + | ||
| - | </ | + | |
| - | ○ PDO | + | |
| - | < | + | |
| - | # yum -y --enablerepo=remi install php-pdo | + | |
| - | + | ||
| - | + | ||
| - | </ | + | |
| - | ○ pear | + | |
| - | < | + | |
| - | # yum -y --enablerepo=remi install php-pear | + | |
| - | + | ||
| - | + | ||
| - | </code> | + | |
| - | ○ APC(PHP用アクセラレータ) | + | |
| - | < | + | |
| - | # yum -y --enablerepo=remi install php-devel | + | |
| - | # yum -y --enablerepo=remi install httpd-devel | + | |
| - | # pecl install apc | + | |
| - | # echo " | + | |
| - | + | ||
| - | + | ||
| - | </ | + | |
| - | ○ FastCGI | + | |
| - | < | + | |
| - | ●参考サイト | + | |
| - | http:// | + | |
| - | + | ||
| - | http:// | + | |
| - | > fpm(FastCGI Process Manager)はphpでFastCGIを使うための実装の一つです。 | + | |
| - | > php 5.3.3でfpmが標準で使えるようになったので使ってみる。今まではphpに | + | |
| - | > パッチを当てる必要がありました。ただし、標準になったとはいえ、PHPのコ | + | |
| - | > ンパイル時にオプションの設定が必要なので、configureからやり直す必要が | + | |
| - | > ある。尚、fpmのコンパイルするにあたって予め1.4系のlibeventをインストール | + | |
| - | > しておく必要があります。 | + | |
| - | + | ||
| - | ⇒ 5.3.4 では全く作業しなくても動いている。。。 | + | |
| - | + | ||
| - | + | ||
| - | </ | + | |
| - | ○ PHP-FPM | + | |
| - | < | + | |
| - | ●参考サイト | + | |
| - | http:// | + | |
| - | + | ||
| - | ● PHP-FPM インストール | + | |
| - | # yum -y --enablerepo=remi install php-fpm | + | |
| - | + | ||
| - | ● nginx への設定追加 | + | |
| - | # vi / | + | |
| - | + | ||
| - | 108行目付近、以下の行を追加。 | + | |
| - | 101行目付近にコメントされている行があるので、「\.php」の「\」をはずし、 | + | |
| - | SCRIPT_FILENAE のパスを修正。 | + | |
| - | + | ||
| - | location ~ .php$ { | + | |
| - | root | + | |
| - | fastcgi_pass | + | |
| - | fastcgi_index | + | |
| - | fastcgi_param | + | |
| - | include | + | |
| - | } | + | |
| - | + | ||
| - | ● PHP-FPM 起動 | + | |
| - | # / | + | |
| - | + | ||
| - | ● nginx 再起動(設定反映) | + | |
| - | # / | + | |
| - | + | ||
| - | ● 自動起動設定 | + | |
| - | # chkconfig php-fpm on | + | |
| - | + | ||
| - | ● ブラウザからphpファイルにアクセスして表示されることを確認 | + | |
| - | + | ||
| - | + | ||
| - | </ | + | |
| - | ○ TokyoCabinet/ | + | |
| < | < | ||
| ●参考サイト | ●参考サイト | ||
| 行 244: | 行 194: | ||
| </ | </ | ||
| - | ○ nginx + SSL | + | ===== nginx + SSL ===== |
| - | < | + | |
| - | ● OpenSSL の鍵を作成 | + | |
| - | # cd / | + | |
| - | + | ||
| - | ■ RSA形式の秘密鍵を作成する | + | |
| - | # openssl genrsa -des3 -out server.key 1024 | + | |
| - | Generating RSA private key, 1024 bit long modulus | + | |
| - | ..............................................................................++++++ | + | |
| - | .......++++++ | + | |
| - | e is 65537 (0x10001) | + | |
| - | Enter pass phrase for server.key: | + | |
| - | Verifying - Enter pass phrase for server.key: | + | |
| - | + | ||
| - | ■ CSRファイルを作成する。 | + | |
| - | # openssl req -new -key server.key -out server.csr | + | |
| - | Enter pass phrase for server.key: | + | |
| - | You are about to be asked to enter information that will be incorporated | + | |
| - | into your certificate request. | + | |
| - | What you are about to enter is what is called a Distinguished Name or a DN. | + | |
| - | There are quite a few fields but you can leave some blank | + | |
| - | For some fields there will be a default value, | + | |
| - | If you enter ' | + | |
| - | ----- | + | |
| - | Country Name (2 letter code) [GB]:jp | + | |
| - | State or Province Name (full name) [Berkshire]: | + | |
| - | Locality Name (eg, city) [Newbury]: | + | |
| - | Organization Name (eg, company) [My Company Ltd]: | + | |
| - | Organizational Unit Name (eg, section) []:Main Section | + | |
| - | Common Name (eg, your name or your server' | + | |
| - | Email Address []: | + | |
| - | + | ||
| - | Please enter the following ' | + | |
| - | to be sent with your certificate request | + | |
| - | A challenge password []: | + | |
| - | An optional company name []: | + | |
| - | + | ||
| - | # cp server.key server.key.org | + | |
| - | + | ||
| - | # openssl rsa -in server.key.org -out server.key | + | |
| - | Enter pass phrase for server.key.org: | + | |
| - | writing RSA key | + | |
| - | + | ||
| - | ■ デジタル証明書(server.crt)の作成 | + | |
| - | # openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt | + | |
| - | Signature ok | + | |
| - | subject=/C=jp/ST=Osaka/L=Osaka/O=Aska-ltd./ | + | |
| - | Getting Private key | + | |
| - | + | ||
| - | ● nginx の SSL設定ファイルを設定 | + | |
| - | # vi / | + | |
| - | + | ||
| - | 5行目付近「sever {」以下のコメントをすべてはずす。 | + | |
| - | 10~11行目付近、鍵のパスを修正 | + | |
| - | # ssl_certificate | + | |
| - | # ssl_certificate_key | + | |
| - | ssl_certificate | + | |
| - | ssl_certificate_key | + | |
| - | + | ||
| - | 26行目付近、PHPを使うために以下を追加 | + | |
| - | location ~ .php$ { | + | |
| - | root | + | |
| - | fastcgi_pass | + | |
| - | fastcgi_index | + | |
| - | fastcgi_param | + | |
| - | include | + | |
| - | } | + | |
| - | + | ||
| - | ● SSL 有効化(nginx 再起動) | + | |
| - | # / | + | |
| - | + | ||
| - | ● ブラウザでアクセスして動作確認 | + | |
| - | http:// | + | |
| - | </ | + | |
| + | {{section> | ||
| + | {{section> | ||
centos/centos_nginx_php.1360734418.txt.gz · 最終更新: 2025/02/16 13:50 (外部編集)
