網站開發基本教學
  • Introduction
  • 基本元素
  • Nginx (伺服器)
    • Config 基本配置
    • Regular Expression 正規化
  • Codeigniter (程式語言框架)
    • Config
    • Controller
    • View
    • Model
      • Question
    • Helper
    • MVC
  • MySQL
Powered by GitBook
On this page

Was this helpful?

  1. Nginx (伺服器)

Config 基本配置

PreviousNginx (伺服器)NextRegular Expression 正規化

Last updated 5 years ago

Was this helpful?

設定檔預設路徑

$ 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 預設首頁檔名