出于性能原因,我想从Apache更改为Nginx + Php-Fpm。目前我可以看到我的网站的主页(在测试环境中),但是在Apache中工作的任何友好网址现在都不起作用。
我已经将规则转换为nginx规则,但我没有办法测试它,因为每次点击网站的某个网址都会变成我的浏览器下载php文件!
例如
我点击www.misite.com/autentication,我的浏览器下载了一个php文件: - /
环境测试
PHP 5.3.17(cli)(建于:2012年9月13日06:45:07) 版权所有(c)1997-2012 PHP小组 Zend Engine v2.3.0,版权所有(c)1998-2012 Zend Technologies
nginx -v nginx版本:nginx / 1.0.15
这是我的nginx虚拟主机配置:
server {
server_name site.com www.site.com;
root /srv/www/site.com/httpdocs;
access_log /srv/www/site.com/log/access.log;
error_log /srv/www/site.com/log/error.log;
rewrite_log on;
location / {
index index.html index.htm index.php;
rewrite ^/([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2$3.jpg? break;
rewrite ^/([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2.jpg? break;
rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$1$2.jpg? break;
rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$1$2$3.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg? break;
rewrite ^/c/([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/c/$1$2.jpg? break;
rewrite ^/c/([a-zA-Z-]+)/[a-zA-Z0-9-]+\.jpg$ /img/c/$1.jpg? break;
rewrite ^/([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/c/$1$2.jpg? break;
rewrite ^/([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 break;
rewrite ^/[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 break;
rewrite ^/([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+ /category.php?id_category=$1&noredirect=1 break;
rewrite ^/([0-9]+)\-[a-zA-Z0-9-]* /category.php?id_category=$1 break;
rewrite ^/([0-9]+)__([a-zA-Z0-9-]*) /supplier.php?id_supplier=$1 break;
rewrite ^/([0-9]+)_([a-zA-Z0-9-]*) /manufacturer.php?id_manufacturer=$1 break;
rewrite ^/content/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms=$1 break;
rewrite ^/content/category/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms_category=$1 break;
rewrite ^/pagina-no-encuentra$ /404.php break;
rewrite ^/direccion$ /address.php break;
rewrite ^/direcciones$ /addresses.php break;
rewrite ^/autenticacion$ /authentication.php break;
rewrite ^/mas-vendidos$ /best-sales.php break;
rewrite ^/carro-de-la-compra$ /cart.php break;
rewrite ^/contactenos$ /contact-form.php break;
rewrite ^/descuento$ /discount.php break;
rewrite ^/estado-pedido$ /guest-tracking.php break;
rewrite ^/historial-de-pedidos$ /history.php break;
rewrite ^/identidad$ /identity.php break;
rewrite ^/fabricantes$ /manufacturer.php break;
rewrite ^/mi-cuenta$ /my-account.php break;
rewrite ^/nuevos-productos$ /new-products.php break;
rewrite ^/carrito$ /order.php break;
rewrite ^/devolucion-de-productos$ /order-follow.php break;
rewrite ^/pedido-rapido$ /order-opc.php break;
rewrite ^/vales$ /order-slip.php break;
rewrite ^/contrasena-olvidado$ /password.php break;
rewrite ^/promocion$ /prices-drop.php break;
rewrite ^/buscar$ /search.php break;
rewrite ^/mapa-del-sitio$ /sitemap.php break;
rewrite ^/tiendas$ /stores.php break;
rewrite ^/proveedores$ /supplier.php break;
error_page 404 = /404.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
最糟糕的问题是我没有一些调试问题的经验: - /非常新的Nginx 任何评论将不胜感激,
由于
答案 0 :(得分:4)
好的,我已经解决了自己的问题!顺便说一下,这只是改变规则的位置
我已经移动了
的所有规则location /{
.... rules...
}
到
server {
...here rules works...
}
然后我重新加载nginx,就是这样!
服务nginx重新加载
我希望这对像我这样绝望的人有用。
致以最诚挚的问候,
鲁