nginx的設定 - Linux

Edward Lewis avatar
By Edward Lewis
at 2014-12-17T19:13

Table of Contents


以下是我nginx的設定
我想要做成一台機器上有兩個不同的網站
然後靠url第一層的path去區分
以下例來說就是 127.0.0.1/kaoru 與 127.0.0.1/test 分別是兩個不同的站台
但我現在遇到的問題是網站開起來了但是 assets 裡頭的東西都無法存取,所以js與css都
不能用
我分別建立兩個靜態檔案 public/1.html 與 public/assets/2.html
發現 127.0.0.1/kaoru/1.html 是可以正常讀取的
但是 127.0.0.1/kaoru/assets/2.html 會回傳 404
權限設定沒有問題
請問還有那裏沒有做對嗎


版本是
nginx version: nginx/1.6.2
built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-http_ssl_module
--with-http_gzip_static_module --with-http_stub_status_module
--with-cc-opt=-Wno-error
--add-module=/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.55/ext/nginx


nginx的設定如下
worker_processes 3;

events {
worker_connections 1024;
}


http {
passenger_root /usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.55;
passenger_ruby /usr/local/rvm/gems/ruby-2.1.2/wrappers/ruby;

include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

server {
listen 80;
server_name localhost;

location ~ ^/kaoru(/.|$) {
alias /var/kaoru_home/public$1;
passenger_base_uri /kaoru;
passenger_app_root /var/kaoru_home;
passenger_document_root /var/kaoru_home/public;
passenger_enabled on;
}

location /test {
passenger_base_uri /test;
alias /var/www;
}
}
}




--
Tags: Linux

All Comments

Jessica avatar
By Jessica
at 2014-12-20T14:10
assets本來就要有location去處理啊 要alias到資料夾
Franklin avatar
By Franklin
at 2014-12-24T16:06
乍看之下location ~ ^/kaoru(/.*|$) 這你少個'*'
Ingrid avatar
By Ingrid
at 2014-12-26T21:34
但我拿掉*就甚麼都讀不出來了...感覺跟你情形不同

Win 8 Ubuntu 雙系統問題

Belly avatar
By Belly
at 2014-12-17T11:20
先跟各位說抱歉 我知道這是月經文-.- 我的筆電是Acer S3 391 目前的狀況是 在BIOS設定UEFI會直接進Win 8.1 但是如果設定Legacy則會直接進Ubuntu 12.04 (都沒有開機選單) 我爬了前面某個大大的教學文 但是我的筆電根本不能在UEFI中進Ubuntu (連boot f ...

CentOS安裝jmgaick問題

David avatar
By David
at 2014-12-16T20:14
./configure -prefix=/usr/local/jmagick/ --enable-shared--without-perl checking build system type... x86_64-redhat-linux-gnu checking host system type... x8 ...

學習嵌入式Linux需要上課嗎?

Gilbert avatar
By Gilbert
at 2014-12-16T09:13
我離開學校很久很久了 上次讀/寫C程式已經是十幾年前(不過我現在正重念Kandamp;R) 請問這種背景如果還想學embedded Linux 一定得去上課嗎? 自己念自己摸索行得通嗎? 坊間上課好像也沒有玩開發板吧? 用Rasbperry Pi不知道合不合適? 另外想請教 除了C之外 還有沒有其他的語言可 ...

WIN7 Ubuntu 14.04 的開機選單

Daph Bay avatar
By Daph Bay
at 2014-12-15T18:08
不好意思請教一下板上眾高手 小弟我是Linux系統的新手 在原本就有WIN7的硬碟上安裝Ubuntu 14.04 之後開機選單就變成 Ubuntu 的紫色背景選單,而且預設是進入Ubuntu 由於我主要的工作還是在windows下做 不知道能不能把開機選單改回預設進入WIN7 不然有時候在其他地方 ...

Git教學文件

Tom avatar
By Tom
at 2014-12-15T15:57
Hi 版上各位大大好, 小弟利用閒暇時間用 sphinx-doc 寫了一份 Git 教學。 但不知道哪裡還有不足,畢竟小弟沒有太多利用 Git 的開發經驗, 所以放上來請各位大大給些建議,希望各位大大不吝指教。 在此放上文件的 GitHub 連結: htt ...