NGINX-二級域名
阿新 • • 發佈:2019-01-04
先給二級域名新增到DNS解析再配置nginx
server { #偵聽80埠 listen 80; #定義使用 www.nginx.cn訪問 server_name ~^(?<subdomin>.+).kongciyuan.com$; #定義伺服器的預設網站根目錄位置 root /var/www/$subdomin; index index.php index.html index.htm; #設定本虛擬主機的訪問日誌 #access_log logs/nginx.access.log main; #預設請求 location / { try_files $uri $uri/ /index.php; } # 定義錯誤提示頁面 error_page 500 502 503 504 /50x.html; location = /50x.html { } #靜態檔案,nginx自己處理 location ~ ^/(images|javascript|js|css|flash|media|static)/ { #過期30天,靜態檔案不怎麼更新,過期可以設大一點, #如果頻繁更新,則可以設定得小一點。 expires 30d; } #PHP 指令碼請求全部轉發到 FastCGI處理. 使用FastCGI預設配置. location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } #禁止訪問 .htxxx 檔案 location ~ /.ht { deny all; } }