nginx 部署 thinkphp3.2.3 遇到的问题

2016-01-27 22:41:59 +08:00
 linar

环境:阿里云 ubuntu 14.04 nginx 1.8.0 php 5.5.9 , 有虚拟主机,已经安装多个应用

安装 weiphp 的时候,查了很多,得知 nginx 不支持 phpinfo,rewrite,,,也不太懂。然后安装的时候可以打开安装页面,但是点击同意协议的时候,跳转路径不正常:
http://xx.cn.php/?s=/install/step1.html(但是如果手动改成 http://xx.cn/install.php?s=/install/step1.html 的话就可以看到检测环境页面,只不过下一步也失败)
情况就是这样,求教...大概设置了一下本应用的配置文件如下:

server {

listen       80;
server_name xx.cn  www.xx.cn;
root /var/www/xx/html/;
index  index.php index.html index.htm;
access_log /var/www/xx/logs/access.log;
error_log /var/www/xx/logs/error.log;

location / {
     try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
    include fastcgi_params;
    set $real_script_name $fastcgi_script_name;

    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
        set $real_script_name $1;
        set $path_info $2;
        }
    fastcgi_param  SCRIPT_FILENAME /var/www/xx/html$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $real_script_name;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 256 16k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_read_timeout 240;

}

}

5665 次点击
所在节点    NGINX
8 条回复
just1
2016-01-27 22:55:15 +08:00
phpinfo 什么时候和 htto 服务器有关了😓nginx 支持 rewrite 啊
just1
2016-01-27 22:55:29 +08:00
@just1 o –>p
squid157
2016-01-27 22:57:43 +08:00
@just1 支持的函数跟 nginx 确实没关系 但 rewrite 跟 Apache 很不一样,至少不能像以前那样搞个 htaccess 完事儿 而去 rewrite 规则也是配置好了改动只能重启
realpg
2016-01-27 23:14:51 +08:00
我觉得对于楼主来说还是回归 apache 能省事一些……
zeac
2016-01-27 23:20:36 +08:00
参考 TP 手册 url_rewrite 部分

也就是把你上面配置文件***location /***部分做修改
linar
2016-01-27 23:27:18 +08:00
@zeac 能否讲解一下原因,链接为何会成为这样: http://xx.cn.php/?s=/install/step1.html
zeac
2016-01-27 23:34:23 +08:00
@linar 搜索 rewrite 。
简单的说, location 那一部分就是修饰 url 的,可以说是为了好看。
你要是认真学了 tp 应该知道 tp 有三种 url 形式,其中有一种还是两种就是要靠重写规则实现。
再说简单点,很多 CMS 、 framework 什么的就是通过重写规则将 index.php 给隐藏的。

以上如有错误欢迎楼下指正。
withrock
2016-01-28 10:28:06 +08:00
我觉得你的 location 写的不对.
如果你是最终的请求路径是这样的:/xxx/demo.php/archive/1 ,
那么你的 location 应该这样写:
location ~ .*\.php(\/.*)*$ {
因为 demo.php 后面的东西是$2

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/253843

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX