不可思議的 網站設計

手機, 電腦, 平板 三個願望一次滿足,

畫面內容隨心所欲,卻如此簡單迅速。

立即體驗不可思議 的感覺吧!

Symfony2 是一個頂尖,且傑出的 PHP 框架,

預設的網頁伺服器是使用現在最多人使用的重兵器 Apache2,

但有時為了特殊網站架設需求,如高流量網站,PHP fpm 模式

或其他各種實際或非實際的應用層面,我們會改用輕量化的 Nginx,

這時我們就需要重新撰寫 rewrite 的設定檔了。

而在 Nginx 官方的文件中,也專門為了 Symfony2 撰寫了一份範例。

upstream phpfcgi {
    server 127.0.0.1:9000;
    # server unix:/var/run/php5-fpm.sock; #for PHP-FPM running on UNIX socket
}
server {
    listen 80;
 
    server_name symfony2;
    root /var/www/symfony2/web;
 
    error_log /var/log/nginx/symfony2.error.log;
    access_log /var/log/nginx/symfony2.access.log;
 
    # strip app.php/ prefix if it is present
    rewrite ^/app\.php/?(.*)$ /$1 permanent;
 
    location / {
        index app.php;
        try_files $uri @rewriteapp;
    }
 
    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
    }
 
    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app|app_dev|config)\.php(/|$) {
        fastcgi_pass phpfcgi;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS off;
    }
}
 
 
server {
    listen 443;
 
    server_name symfony2;
    root /var/www/symfony2/web;
 
    ssl on;
    ssl_certificate /etc/ssl/certs/symfony2.crt;
    ssl_certificate_key /etc/ssl/private/symfony2.key;
 
    error_log /var/log/nginx/symfony2.error.log;
    access_log /var/log/nginx/symfony2.access.log;
 
    # strip app.php/ prefix if it is present
    rewrite ^/app\.php/?(.*)$ /$1 permanent;
 
    location / {
        index app.php;
        try_files $uri @rewriteapp;
    }
 
    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
    }
 
    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app|app_dev|config)\.php(/|$) {
        fastcgi_pass phpfcgi;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS on;
    }
}

原始連結 : http://wiki.nginx.org/Symfony


新增回應


安全碼
更新