Ngnix - 使app.php可执行

时间:2015-04-28 10:46:14

标签: symfony

我希望app.php是可执行的,就像index.php一样。我该怎么设置呢?

这是symfony,因为symfony没有index.php。

2 个答案:

答案 0 :(得分:0)

它已经可执行了!我认为你的意思是让apache寻找app.php而不是index.php,为此你应该配置你的.htaccess文件并添加一些类似的想法:

DirectoryIndex app.php

答案 1 :(得分:0)

使用php5-fpm

的本地虚拟主机的示例
server {
    listen 80;

    server_name your.site.lan;

    root /var/www/your.site.lan/web;

    error_log /var/log/nginx/site.error.log;
    access_log /var/log/nginx/site.access.log;

    # strip app.php/ prefix if it is present
    rewrite ^/app\.php/?(.*)$ /$1 permanent;

    location / {
        index app.php;
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
    }

    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app|app_dev|index|app_test|config|info|apc)\.php(/|$) {
        fastcgi_pass phpfcgi;
        fastcgi_read_timeout 600;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS off;
    }
}

其中phpfcgi是在http部分

的nginx.conf配置的别名
upstream phpfcgi {
        server unix:/var/run/php5-fpm.sock;
}