VPS侦探论坛

 找回密码
 注册
查看: 8014|回复: 14

lnmp二级目录伪静态问题

[复制链接]
发表于 2012-11-27 22:02:43 | 显示全部楼层 |阅读模式

我在安装LNMP的时候,安装的时候用的域名ceshi.taogirl.com.cn;现在在/home/wwwroot/建立了一个文件夹wordpress,网站放在这个目录下面了,路径为/home/wwwroot/wordpress/,这个目录绑定的域名是www.banduo.com.cn;这个伪静态用的是banduo.conf;网站伪静态正常;现在又在wordpress文件夹下面建立了一个文件夹名字是go,目录是/home/wwwroot/wordpress/go/,在这个目录下面放了另一个网站程序。这里做伪静态应该怎么做呢。伪静态规则应该放在哪里呢。谢谢军哥解答一下。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-11-28 10:16:10 | 显示全部楼层


和bandou.conf一个目录,go的伪静态要是二级目录的伪静态才行
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-11-28 10:17:39 | 显示全部楼层

军哥响应速度真快!
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-11-28 11:47:30 | 显示全部楼层



那军哥 我这个伪静态应该怎么弄才能让这个在go目录下面安装的网站 实现伪静态呢 能提供下步骤吗
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2012-11-28 11:50:38 | 显示全部楼层

已经伪静态的网站目录:/home/wwwroot/banduo/  绑定的域名:www.banduo.com.cn

伪静态不成功的网站目录:/home/wwwroot/banduo/go/ 域名还是:www.banduo.com.cn 这个伪静态规则设置步骤可以提供下吗






原帖由 licess 于 2012-11-28 10:16 发表
和banduo.conf一个目录,go的伪静态要是二级目录的伪静态才行

军哥运维代购:http://shop63846532.taobao.com/

发表于 2012-11-28 12:10:44 | 显示全部楼层

修改你那个域名的虚拟主机配置文件,参考里面的include域名include 上go的伪静态
 楼主| 发表于 2012-11-28 22:28:29 | 显示全部楼层

log_format  banduo  '$remote_addr - $remote_user [$time_local] $request '
             '$status $body_bytes_sent $http_referer '
             '$http_user_agent $http_x_forwarded_for';
server

{

listen       80;

server_name www.banduo.com.cn banduo.com.cn;

index index.html index.htm index.php default.html default.htm default.php;

root  /home/wwwroot/banduo;


include banduo.conf;
                include go.conf;

location ~ .*\.(php|php5)?$

{

try_files $uri =404;

fastcgi_pass  unix:/tmp/php-cgi.sock;

fastcgi_index index.php;

include fcgi.conf;

}


location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires      30d;

}


location ~ .*\.(js|css)?$

{

expires      12h;

}


access_log  /home/wwwlogs/banduo.log  banduo;

}




其中红色的是include的虚拟主机配置文件www.banduo.com.cn.conf; 这样配置后我进行了 /root/lnmp restart 然后进行了/usr/local/nginx/sbin/nginx -t 测试
结果提示:nginx: [emerg] invalid number of arguments in "location" directive in /usr/local/nginx/conf/banduo.conf:1这个错误,这个是什么原因导致的呢

其中banduo.conf的配置代码如下:
location / {
if (-f $request_filename/index.html){
                rewrite (.*) $1/index.html break;
        }
if (-f $request_filename/index.php){
                rewrite (.*) $1/index.php;
        }
if (!-f $request_filename){
                rewrite (.*) /index.php;
        }
}


这个banduo.conf的代码配置和wordpress的伪静态代码配置一样的

如果我去掉www.banduo.com.cn.conf里面的include go.conf;这个代码的话  /root/lnmp restart 然后进行/usr/local/nginx/sbin/nginx -t 测试,就不会出现错误提示

这个应该怎么修改虚拟主机配置文件呢?

谢谢军哥告诉下




原帖由 licess 于 2012-11-28 12:10 发表
修改你那个域名的虚拟主机配置文件,参考里面的include域名include 上go的伪静态
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-11-29 00:21:49 | 显示全部楼层

顺便补充下 go.conf的伪静态规则:

location /
{
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/([0-9A-Za-z]+)/?$ /yourls-go.php?id=$1 last;
}
rewrite ^/([0-9A-Za-z]+)\+/?$ /yourls-infos.php?id=$1 last;
rewrite ^/([0-9A-Za-z]+)\+all/?$ /yourls-infos.php?id=$1&all=1 last;
}
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-11-29 09:33:06 | 显示全部楼层


二级目录的话,go伪静态应该如下:
  1. location /go/ {
  2. if (!-f $request_filename){
  3. set $rule_0 1$rule_0;
  4. }
  5. if (!-d $request_filename){
  6. set $rule_0 2$rule_0;
  7. }
  8. if ($rule_0 = "21"){
  9. rewrite ^/go/([0-9A-Za-z]+)/?$ /go/yourls-go.php?id=$1 last;
  10. }
  11. rewrite ^/go/([0-9A-Za-z]+)\+/?$ /go/yourls-infos.php?id=$1 last;
  12. rewrite ^/go/([0-9A-Za-z]+)\+all/?$ /go/yourls-infos.php?id=$1&all=1 last;
  13. }
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-11-29 12:57:03 | 显示全部楼层



用了下面的代码放置在go.conf里面。在www.banduo.com.cn.conf里面include go.conf;
现在访问http://banduo.com.cn/go/taobao  出现404 这个什么情况呢




原帖由 licess 于 2012-11-29 09:33 发表
二级目录的话,go伪静态应该如下:
location /go/ {
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/go/([0-9A-Za-z] ...
发表于 2012-11-29 13:16:49 | 显示全部楼层

重启过了没,有错误信息没?
 楼主| 发表于 2012-11-29 14:24:59 | 显示全部楼层

重启过了 配置测试/usr/local/nginx/sbin/nginx -t 没有错误信息 打开http://banduo.com.cn/go/taobao 出现404
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-11-29 15:13:07 | 显示全部楼层

回复 12# 的帖子

那就只有可能是伪静态的问题了
网上再找找这个程序的nginx的伪静态试试
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-11-29 15:16:14 | 显示全部楼层
这个我用二级域名的话伪静态是正常的,应该说明伪静态规则没有问题的。




原帖由 licess 于 2012-11-29 15:13 发表
那就只有可能是伪静态的问题了
网上再找找这个程序的nginx的伪静态试试

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2012-12-2 01:15:37 | 显示全部楼层
军哥  这个有方法解决吗
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-24 03:26 , Processed in 0.030158 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表