Config 基本配置

設定檔預設路徑

$ cat /etc/nginx/conf.d/default.conf

server { ... } 為一個網站配置單位,Nginx要支援 PHP 需要另外安裝php5-fpm

server {

    client_max_body_size 10M;
    server_name dev.unicloud.com.tw;
    root   /var/www/gpd.admin/public;
    index  index.php index.html index.htm;

    location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
        #expires max;
        expires 0;
        log_not_found off;
    }

    location / {
        try_files $uri $uri/ /index.php;
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}
  • server_name 指定的網域名稱

  • root 網站根目錄

  • index 預設首頁檔名

Last updated

Was this helpful?