ユーザ用ツール

サイト用ツール


centos:centos_nginx_php

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
centos:centos_nginx_php [2013/02/13 05:46] – 外部編集 127.0.0.1centos:centos_nginx_php [2025/02/16 13:53] (現在) – 外部編集 127.0.0.1
行 1: 行 1:
 ====== 即効 環境構築  ====== ====== 即効 環境構築  ======
  
-○ SELINUX 設定+===== SELINUX ===== 
 + 
 +{{page>centos:selinux&noheader}} 
 + 
 +===== iptables(ファイアウォール)===== 
 + 
 +{{section>centos:iptables#設定ファイル&noheader}}{{section>centos:iptables#http_port80&noheader}} 
 +{{section>centos:iptables#サービス再起動_設定反映&noheader&showmdate=nomdate}} 
 + 
 +===== nginx ===== 
 + 
 +{{page>nginx:install_centos6&noheader}} 
 + 
 +===== PHPと関連モジュール =====
 <code> <code>
-  +# yum -y --enablerepo=remi install php php-mbstring php-mysql php-pear php-devel 
-getenforce ← SELinux状態確認 +vi /etc/php.ini /etc/php.ini.org 
- Enforcing ← SELinux有効 +869c869 
-  +< date.timezone = "Asia/Tokyo" 
- # setenforce 0 ← SELinux無効化 +--- 
-  +> ;date.timezone = 
- # getenforce ← SELinux状態確認 +1350c1350 
- Permissive ← SELinux無効 +< session.save_path = "/var/lib/php/session/" 
-  +--- 
-vi /etc/sysconfig/selinux ← SELinux設定ファイル編集 +> ;session.save_path = "/tmp" 
- 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 /var/lib/php/session 
- +# ll /var/lib/php/ 
 +合計 4 
 +drwxrwx---. 2 root nginx 4096 10月 16 17:24 2014 session
 </code> </code>
-○ iptables(ファイアウォール)設定 
  
 +===== APC(PHP用アクセラレータ) =====
 <code> <code>
- vi /etc/sysconfig/iptables +yum ---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 "extension=apc.so" | sudo tee /etc/php.d/apc.ini
-  +
- # /etc/rc.d/init.d/iptables restart +
-  +
- 起動確認 +
- httpサーバ(nginxなど)を動かして、ブラウザからアクセス +
- +
   
 </code> </code>
-○ nginx+ 
 +===== PHP-FPM =====
 <code> <code>
- ● EPELリポジトリを登録 +yum -y --enablerepo=remi install php-fpm 
-  rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/x86_64/epel-release-5-4.noarch.rpm +# vi /etc/php-fpm.d/www.conf 
-   +39c39 
- ● nginx インストール +< user = nginx 
-  # yum -y install nginx +--- 
-   +> user = apache 
- ● 設定 +41c41 
-  デフォルトの document root は /usr/share/nginx/html +< group = nginx 
-  その他、設定ファイル確認 +--- 
-   +> group = apache 
-  # vi /etc/nginx/nginx.conf + 
-   +nginx への設定追加 
- ● nginx 起動 +# vi /etc/nginx/conf.d/default.conf 
-  # /etc/init.d/nginx start + 
-  +9,10c9,10 
- ● 自動起動設定 +<         root   /var/www/html; 
-chkconfig nginx on +<         index  index.php; 
-  +--- 
- ● 本ドキュメント最下部に SSL の設定例あり +>         root   /usr/share/nginx/html; 
- +>         index  index.html index.htm; 
 +30,36c30,36 
 +<     location ~ \.php$ { 
 +<         root           /var/www/html; 
 +<         fastcgi_pass   127.0.0.1:9000; 
 +<         fastcgi_index  index.php; 
 +<         fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name; 
 +<         include        fastcgi_params; 
 +<     } 
 +--- 
 +>     #location ~ \.php$ { 
 +>     #    root           html; 
 +>     #    fastcgi_pass   127.0.0.1:9000; 
 +>     #    fastcgi_index  index.php; 
 +>     #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name; 
 +>     #    include        fastcgi_params; 
 +>     #}
   
 +PHP-FPM 起動
 +# /etc/init.d/php-fpm start
 +自動起動設定
 +# chkconfig php-fpm on
 +
 +nginx 再起動(設定反映)
 +# /etc/init.d/nginx restart
 </code> </code>
-○ PHP 5.3 + 
-<code> +===== TokyoCabinet/TokyoTyrant =====
- ● remiリポジトリを登録 +
-  # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm +
-   +
- ● PHP インストール +
-  # yum -y --enablerepo=remi install php +
-  +
-  +
-</code> +
-○ PDO +
-<code> +
- # yum -y --enablerepo=remi install php-pdo +
-  +
-  +
-</code> +
-○ pear +
-<code> +
- # yum -y --enablerepo=remi install php-pear +
-  +
-  +
-</code> +
-○ APC(PHP用アクセラレータ) +
-<code> +
- # yum -y --enablerepo=remi install php-devel +
- # yum -y --enablerepo=remi install httpd-devel +
- # pecl install apc +
- # echo "extension=apc.so" | sudo tee /etc/php.d/apc.ini +
-  +
-  +
-</code> +
-○ FastCGI +
-<code> +
- ●参考サイト +
- http://ja.wikipedia.org/wiki/FastCGI +
-  +
- http://d.hatena.ne.jp/IT7C/20101003/1286082204 +
- > fpm(FastCGI Process Manager)はphpでFastCGIを使うための実装の一つです。 +
- > php 5.3.3でfpmが標準で使えるようになったので使ってみる。今まではphpに +
- > パッチを当てる必要がありました。ただし、標準になったとはいえ、PHPのコ +
- > ンパイル時にオプションの設定が必要なので、configureからやり直す必要が +
- > ある。尚、fpmのコンパイルするにあたって予め1.4系のlibeventをインストール +
- > しておく必要があります。 +
-  +
- ⇒ 5.3.4 では全く作業しなくても動いている。。。 +
-  +
-  +
-</code> +
-○ PHP-FPM +
-<code> +
- ●参考サイト +
- http://php.net/manual/ja/install.fpm.php +
-  +
- ● PHP-FPM インストール +
- # yum -y --enablerepo=remi install php-fpm +
-  +
- ● nginx への設定追加 +
- # vi /etc/nginx/nginx.conf +
-  +
- 108行目付近、以下の行を追加。 +
- 101行目付近にコメントされている行があるので、「\.php」の「\」をはずし、 +
- SCRIPT_FILENAE のパスを修正。 +
-  +
- location ~ .php$ { +
-     root           html; +
-     fastcgi_pass   127.0.0.1:9000; +
-     fastcgi_index  index.php; +
-     fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name; +
-     include        fastcgi_params; +
-+
-  +
- ● PHP-FPM 起動  +
- # /etc/rc.d/init.d/php-fpm start +
-  +
- ● nginx 再起動(設定反映) +
- # /etc/init.d/nginx restart +
-  +
- ● 自動起動設定 +
- # chkconfig php-fpm on +
-  +
- ● ブラウザからphpファイルにアクセスして表示されることを確認 +
-  +
-  +
-</code> +
-○ TokyoCabinet/TokyoTyrant+
 <code> <code>
  ●参考サイト  ●参考サイト
行 244: 行 194:
   
 </code> </code>
-○ nginx + SSL +===== nginx + SSL =====
-<code> +
- ● OpenSSL の鍵を作成 +
- # cd /etc/nginx/ +
-  +
- ■ 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:aaaaaaaaaa +
- Verifying - Enter pass phrase for server.key:aaaaaaaaaa +
-  +
- ■ CSRファイルを作成する。 +
- # openssl req -new -key server.key -out server.csr +
- Enter pass phrase for server.key:aaaaaaaaaa +
- 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 '.', the field will be left blank. +
- ----- +
- Country Name (2 letter code) [GB]:jp +
- State or Province Name (full name) [Berkshire]:Osaka +
- Locality Name (eg, city) [Newbury]:Osaka +
- Organization Name (eg, company) [My Company Ltd]:Aska-ltd. +
- Organizational Unit Name (eg, section) []:Main Section +
- Common Name (eg, your name or your server's hostname) []:testsv +
- Email Address []:testsv@aska-ltd.jp +
-  +
- Please enter the following 'extra' attributes +
- 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./OU=Main Section/CN=testsv/emailAddress=testsv@aska-ltd.jp +
- Getting Private key +
-  +
- ● nginx の SSL設定ファイルを設定 +
- # vi /etc/nginx/conf.d/ssl.conf +
-  +
- 5行目付近「sever {」以下のコメントをすべてはずす。 +
- 10~11行目付近、鍵のパスを修正 +
- #    ssl_certificate      cert.pem; +
- #    ssl_certificate_key  cert.key; +
-     ssl_certificate      server.crt; +
-     ssl_certificate_key  server.key; +
-  +
- 26行目付近、PHPを使うために以下を追加 +
-     location ~ .php$ { +
-         root           html; +
-         fastcgi_pass   127.0.0.1:9000; +
-         fastcgi_index  index.php; +
-         fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name; +
-         include        fastcgi_params; +
-     } +
-  +
- ● SSL 有効化(nginx 再起動) +
- # /etc/init.d/nginx restart +
-  +
- ● ブラウザでアクセスして動作確認 +
- http://www.example.com +
-</code>+
  
 +{{section>centos:ssl_self_certificate#自己証明書を作成する&noheader}}
 +{{section>centos:ssl_self_certificate#nginxで利用する&noheader}}
centos/centos_nginx_php.1360734418.txt.gz · 最終更新: 2025/02/16 13:50 (外部編集)