您尚未登录。

#1 2014-07-05 10:40:02

dryland718
会员
所在地: 3.1415926535897932384626433832
注册时间: 2011-10-30
帖子: 66
个人网站

问一个nginx子目录的问题

我的arm板上弄了个nginx服务器,放了个typecho博客程序,想再装一个linux-dash(https://github.com/afaqurk/linux-dash)
原先,typecho直接放在/home/....../www下面,直接http://xxx.com/就可以访问
现在想把这俩弄在一起,这样访问:http://xxx.com/typecho  和 http://xxx.com/linux-dash

然后发现都有问题

具体说,就是主页访问(http://xxx.com/typecho/index.php)没问题,但是点击链接,本应该是http://xxx.com/typecho/yyy.php,链接却变成了http://xxx.com/yyy.php,中间的二级目录typecho没了,导致链接错误打不开
linux-dash也有这个问题
linux-dash我用的作者推荐的配置(https://gist.github.com/sergeifilippov/8909839 ,把19-21uncomment了),但是也存在这个问题

放在根目录是完全没有问题的,就是二级目录有这个问题,但这是两个网站程序,不能都直接放在根目录

昨天谷歌了一整天,本来就菜,试了一堆方法都不行
还在一个nginx群里找人远程ssh看了下,也不会弄
虽然我不懂服务器,但我觉得不至于这么难吧,应该是有个小地方没解决好

无奈只能来这里求助各位了。
有需要的我可以提供ssh。先谢过了。

离线

#2 2014-07-05 11:37:08

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,384
个人网站

Re: 问一个nginx子目录的问题

这个不是 nginx 的问题,是你那两个程序以为自己在根上的问题。看看它们能不能配置吧。

另外,使用不同的域名访问不同的站点也可以的。

离线

#3 2014-07-05 11:42:42

dryland718
会员
所在地: 3.1415926535897932384626433832
注册时间: 2011-10-30
帖子: 66
个人网站

Re: 问一个nginx子目录的问题

百合仙子 说:

这个不是 nginx 的问题,是你那两个程序以为自己在根上的问题。看看它们能不能配置吧。

另外,使用不同的域名访问不同的站点也可以的。

linux-dash的nginx配置中:
# if hosting in a sub folder, setup a new location
# replace `/linus-dash` with the folder name eg. `/folder_name`
#location /linux-dash {
# index index.html index.php;
#}

是不是说 我放在/linux-dash目录里,只要把这几行启用就可以了?

离线

#4 2014-07-05 13:17:07

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,384
个人网站

Re: 问一个nginx子目录的问题

dryland718 说:
百合仙子 说:

这个不是 nginx 的问题,是你那两个程序以为自己在根上的问题。看看它们能不能配置吧。

另外,使用不同的域名访问不同的站点也可以的。

linux-dash的nginx配置中:
# if hosting in a sub folder, setup a new location
# replace `/linus-dash` with the folder name eg. `/folder_name`
#location /linux-dash {
# index index.html index.php;
#}

是不是说 我放在/linux-dash目录里,只要把这几行启用就可以了?

你的完整配置及其问题贴出来。

离线

#5 2014-07-05 15:25:31

dryland718
会员
所在地: 3.1415926535897932384626433832
注册时间: 2011-10-30
帖子: 66
个人网站

Re: 问一个nginx子目录的问题

百合仙子 说:
dryland718 说:
百合仙子 说:

这个不是 nginx 的问题,是你那两个程序以为自己在根上的问题。看看它们能不能配置吧。

另外,使用不同的域名访问不同的站点也可以的。

linux-dash的nginx配置中:
# if hosting in a sub folder, setup a new location
# replace `/linus-dash` with the folder name eg. `/folder_name`
#location /linux-dash {
# index index.html index.php;
#}

是不是说 我放在/linux-dash目录里,只要把这几行启用就可以了?

你的完整配置及其问题贴出来。

/home/dryland/mnt/nanda/www这是根目录
/home/dryland/mnt/nanda/www/linux-dash 这里存放着linux-dash
配置源自这里(https://gist.github.com/sergeifilippov/8909839),几乎没改
[dryland@alarm ~]$ cat /etc/nginx/nginx.conf

#user html;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  dryland.oicp.net;
        root /home/dryland/mnt/nanda/www;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
       
        # Cache static files for as long as possible
        location ~* \.(?:xml|ogg|mp3|mp4|ogv|svg|svgz|eot|otf|woff|ttf|css|js|jpg|jpeg|gif|png|ico)$ {
            try_files $uri =404;
            expires max;
            access_log off;
            add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        }

        # if hosting in a sub folder, setup a new location
        # replace `/linus-dash` with the folder name eg. `/folder_name`
        location /linux-dash {
            index index.html index.php;
        }

        # Pass PHP requests on to PHP-FPM using sockets
        location ~ \.php(/|$) {
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;
            fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
            # fastcgi_pass localhost:9000; # using TCP/IP stack
            if (!-f $document_root$fastcgi_script_name) {
                return 404;
            }
            try_files $uri $uri/ /index.php?$args;
            include fastcgi_params;
        }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
nginx 1.6.0 php 5.5.14
php.ini 中cgi.fix_pathinfo=0

FluxBB
这是截图,下方显示的链接地址缺少了/linux-dash/。

离线

#6 2014-07-05 16:01:07

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,384
个人网站

Re: 问一个nginx子目录的问题

你的 linux-dash 是最新版本的吗?我看到网页代码里没有指定 / 呀: https://github.com/afaqurk/linux-dash/b … x.html#L92 (但是演示页面是有指定的)

git blame 表明是在这里提交里修正的: https://github.com/afaqurk/linux-dash/c … 41180de292

离线

#7 2014-07-05 17:17:19

dryland718
会员
所在地: 3.1415926535897932384626433832
注册时间: 2011-10-30
帖子: 66
个人网站

Re: 问一个nginx子目录的问题

百合仙子 说:

你的 linux-dash 是最新版本的吗?我看到网页代码里没有指定 / 呀: https://github.com/afaqurk/linux-dash/b … x.html#L92 (但是演示页面是有指定的)

git blame 表明是在这里提交里修正的: https://github.com/afaqurk/linux-dash/c … 41180de292

我用的两天前的版本,现在换成新的后终于没问题了,我还以为是配置的问题T_T
页面空白也解决了,我再看一下typecho是不是也有这个问题
多谢啦!!

离线

页脚