只需執行一個Nginx,PHP的安裝,然後tutorial,一切正常。 輸入網址http://192.168.1.10顯示歡迎畫面。nginx與重寫
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
#root /usr/share/nginx/www;
root /var/www/;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location/{
# First attempt to serve request as file, then
# as directory, then fall back to index.html
#try_files $uri $uri/ /index.html;
}
location /test{
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)/$ /index.php?x=$1 last;
}
location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
location /images {
root /usr/share;
autoindex off;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
預期它不工作: 現在在進入http://192.168.1.10/test/my-test/電話index.php?x=my-test
修改後的sites-avaible/default
看起來像這樣創建一個名爲test
文件夾,要實現類似阿帕奇國防部重寫,這樣。如果我去http://192.168.1.10/test/my-test/會發生什麼情況,它顯示http://192.168.1.10/索引的值。
任何幫助或想法? – Alexd2 2012-01-08 18:31:45