ホームページ  >  記事  >  バックエンド開発  >  CentOS6 システムでの Yii/Yii2/Nginx/PHP-FPM 構成例

CentOS6 システムでの Yii/Yii2/Nginx/PHP-FPM 構成例

WBOY
WBOYオリジナル
2016-08-08 09:28:01975ブラウズ

Yii アプリケーション Apache の設定は比較的単純です。nginx 設定は主に、Apache 設定の次の文に対応する単一のエントリ ファイルの問題に対処する必要があります。

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
は、対応する Nginx 命令に変換する必要があります。例は次のとおりです。

server {
    listen 80;
    server_name www.techbrood.com;
    access_log logs/techbrood.access.log;

    root /var/www/html/techbrood/web;

    location / {
        index index.php;
        if (!-e $request_filename){
          rewrite ^/(.*) /index.php last;
        }
    }
    location ~ \.php(?|$) {
        #fastcgi(php-fpm) listening on 127.0.0.1:9000
        root /var/www/html/techbrood/web;
        #your path to fastcgi_params file
        include /etc/nginx/conf/fastcgi_params; 
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:9000;
        #fastcgi_pass unix: /var/run/php-fpm.sock
    }

    location ~ \.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
        root /var/www/html/techbrood/web;
    }
}

by iefreer

上記では、CentOS6 システムでの Yii/Yii2/Nginx/PHP-FPM の構成例を、関連する内容も含めて紹介しています。PHP チュートリアルに興味のある友人の参考になれば幸いです。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。