1、首先去官網下載 nginx1.0.11的Windows版本,官網下載:http://nginx.org/download/nginx-1.0.11.zipphp
下載到軟件包後,解壓 nginx-nginx1.0.11.zip 包到你喜歡的根目錄,並將目錄名改成nginx。css
而後,執行下列操做:html
cd nginxnginx
start nginxapache
這樣,nginx 服務就啓動了。打開任務管理器,查看 nginx.exe 進程,有二個進程會顯示,佔用系統資源,那是至關的少。而後再打開瀏覽器,輸入 http://127.0.0.1/ 就能夠看到nginx的歡迎頁面了,很是友好瀏覽器
nginx -s stop // 中止nginx
nginx -s reload // 從新加載配置文件
nginx -s quit // 退出nginx服務器
今天搞了N久的虛擬目錄配置,在幾乎要放棄的時侯偶然看到一篇文章,將個人問題搞定ui
個人需求是這樣的,系統有一個專門的文件夾用於存放圖片,css,js或者附件,如:server
http://www.test.com/resources/images/a.jpghtm
http://www.test.com/resources/css/a.css
http://www.test.com/resources/js/a.js
http://www.test.com/resources/attach/a.doc
這樣的配置對於apache來講那至關容易,
須要經過location uri規則匹配訪問到該文件夾,我使用以下配置:
location ^~ /resources/ {
root d:/www/;
}
試了N屢次都能訪問不到,一直報404,無比杯具!最後拜讀了上面提供的blog才解決,發現跟原博主同樣,沒有真正搞清楚,location中root和alias的區別,最後修改爲:
location ^~ /resources/ {
alias d:/www/;
}
成功實現了個人需求。
原貼以下:
niginx 彷佛沒有虛擬目錄的說法,可是能夠指定請求路徑時nginx訪問的路徑,也算是一個解決辦法。
(原文連接 http://ddbiz.com/?p=187)
server {
listen 80 default;
server_name _;
location / {
root html;
index 403.html;
}
location ~ //.ht {
deny all;
}
location /phpadmin/ {
alias /opt/www/phpadmin/;
index index.php;
}
location ~ /.php$ {
include httpd.conf;
}
}
要注意的是, location /phpadmin/ {} 和 location /phpadmin {} 是徹底不一樣的。
前者能夠訪問到目錄,然後者將被重定向到服務器,如: http://127.0.0.1/phpadmin ,將被重定向到 http://_/phpadmin
下面這個配置和上面基本相似,惟一的不一樣是,全部對 /phpadmin/的訪問將正確解析,而其餘訪問則返回頁面不存在(404)的信息。
server {
listen 80 default;
server_name _;
location / {
root html;
#index 403.html;
return 404;
}
location ~ //.ht {
deny all;
}
location /phpadmin/ {
alias /opt/www/phpadmin/;
index index.php;
}
location ~ /.php$ {
include httpd.conf;
}
}
原貼地址:http://blog.sina.com.cn/s/blog_6c2e6f1f0100l92h.html