2016年3月2日 星期三

Codeigniter 搭配 Nginx + PHP-FPM 設定檔


/etc/nginx/sites-available/xxxx
server {
    listen       80;
    server_name  laravel.wuboy.twbbs.org;
    root         /usr/home/git/laravel/public;
 
    access_log /var/log/nginx/laravel_access.log;
    error_log /var/log/nginx/laravel_error.log;
 
    location / {
        index  index.php index.html index.htm;
    }
 
    if ($request_uri ~* index/?$)
    {
        rewrite ^/(.*)/index/?$ /$1 permanent;
    }
 
    # removes trailing slashes (prevents SEO duplicate content issues)
    if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }
 
    # removes access to "system" folder, also allows a "System.php" controller
    if ($request_uri ~* ^/system)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }
 
    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }
 
    # catch all
    error_page 404 /index.php;
 
    # use fastcgi for all php files
    location ~ \.php$
    {
        fastcgi_pass unix:/tmp/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /usr/local/etc/nginx/fastcgi_params;
        fastcgi_param HTTPS off;
    }
 
    # deny access to apache .htaccess files
    location ~ /\.ht
    {
        deny all;
    }
}



參考資料:
https://blog.wu-boy.com/2012/10/php-mvc-framework-nginx-php-fpm/  PHP MVC Framework 搭配 Nginx + PHP-FPM 設定檔


沒有留言:

張貼留言