VPS侦探论坛

 找回密码
 注册
查看: 14950|回复: 13

Nginx下如何开启伪静态功能啊?

[复制链接]
发表于 2011-3-11 19:22:55 | 显示全部楼层 |阅读模式

本菜鸟第一次使用这个系统。
CentOS下用LNMP一键安装包安装的系统,
我现在网站程序是DISCUZ X1.5
想开启伪静态功能,
请问各位老师:Nginx下如何开启伪静态功能啊?
请指点。
我看到Nginx里面带有discuzx.conf文件,
怎么才能调用这个啊?怎么设置???

谢谢!!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2011-3-11 19:56:07 | 显示全部楼层


我是菜鸟, 希望能帮到你 。。添加虚拟主机就可以了

/root/vhost.sh

1 输入域名 ,点击y确定,回车.

2 绑定网站目录,默认在home/wwwroot里面

3 allow rewrte rule

允许伪静态,点击y确定

4 please input the rewrite of progrname

输入伪静态文件名字

默认已经有了Discuz、Wordpress、Sablog、emlog、dabr,可直接输入以上名称即可。程序会自动创建伪静态文件

5 allow access log
是否增加日志,点击n


第四步是你问题关键

[ 本帖最后由 mm111111 于 2011-3-11 20:08 编辑 ]
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2011-3-11 20:29:34 | 显示全部楼层

多谢兄弟指点.
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2011-3-11 21:48:27 | 显示全部楼层



兄弟:你说的是添加虚拟主机.
问题是我现在的域名直接指向的根目录home/wwwroot,
怎么调用伪静态规则啊??
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2011-3-11 23:35:15 | 显示全部楼层

添加虚拟主机, 过程中会教你输入域名和绑定目录的, 你可能说的是修改nginx.conf
增加伪静态
include  xxx.conf;  

备注xxx是程序名称  应该和Nginx里面带有xxx.conf文件名称一致

DISCUZ X1.5的伪静态规则我不知道

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

发表于 2011-3-12 07:30:09 | 显示全部楼层

回复 5# 的帖子


如果是/home/wwwroot 修改/usr/local/nginx/conf/nginx.conf,找到虚拟主机,discuzx的程序直接
include discuzx.conf;
重启nginx就行了。
 楼主| 发表于 2011-3-12 08:06:51 | 显示全部楼层

回复 6# 的帖子


军哥:
是不是在/usr/local/nginx/conf/nginx.conf 这段里面这么加
--------------------------------------------
server
        {
                listen       80;
                server_name bbs.xxx.com;
                index index.html index.htm index.php;
                root  /home/wwwroot;

                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                                include discuzx.conf;
                        }

                location /status {
                        stub_status on;
                        access_log   off;
                }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

                log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
                access_log  /home/wwwlogs/access.log  access;
        }
include vhost/*.conf;
}

--------------------------------------------
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2011-3-12 08:08:39 | 显示全部楼层

另外一个问题:
如何才能重启nginx??
是不是这个语句:
# /usr/local/nginx/sbin/nginx -s reload

先谢了,第一次用这个系统,什么都不懂.呵呵,麻烦各位兄弟了.
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2011-3-12 08:30:44 | 显示全部楼层


如上所说:我在/usr/local/nginx/conf/nginx.conf 这段里面增加伪静态
include discuzx.conf;
然后在PUTTY里面执行这个指令 # /usr/local/nginx/sbin/nginx -s reload
重新启动的nginx.
然而还是不行啊.
出现的404 Not Found错误提示.
军哥帮忙啊.
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2011-3-12 08:37:56 | 显示全部楼层



安装你的描述,你应该加

include vhost/discuzx.conf;
 楼主| 发表于 2011-3-12 09:16:06 | 显示全部楼层

军哥我把我的nginx.conf 贴出来:请指点是不是这样的 ?(我的站放在根目录下的)

user  www www;

worker_processes 1;

error_log  /home/wwwlogs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
        {
                use epoll;
                worker_connections 51200;
        }

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

                server_names_hash_bucket_size 128;
                client_header_buffer_size 32k;
                large_client_header_buffers 4 32k;
                client_max_body_size 50m;

                sendfile on;
                tcp_nopush     on;

                keepalive_timeout 60;

                tcp_nodelay on;

                fastcgi_connect_timeout 300;
                fastcgi_send_timeout 300;
                fastcgi_read_timeout 300;
                fastcgi_buffer_size 64k;
                fastcgi_buffers 4 64k;
                fastcgi_busy_buffers_size 128k;
                fastcgi_temp_file_write_size 256k;

                gzip on;
                gzip_min_length  1k;
                gzip_buffers     4 16k;
                gzip_http_version 1.0;
                gzip_comp_level 2;
                gzip_types       text/plain application/x-javascript text/css application/xml;
                gzip_vary on;

                #limit_zone  crawler  $binary_remote_addr  10m;

server
        {
                listen       80;
                server_name bbs.quutoo.com;
                index index.html index.htm index.php;
                root  /home/wwwroot;

                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                                include discuzx.conf;
                        }

                location /status {
                        stub_status on;
                        access_log   off;
                }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

                log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
                access_log  /home/wwwlogs/access.log  access;
        }
include vhost/*.conf;
}
发表于 2011-3-12 10:06:06 | 显示全部楼层

试试这个
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwlogs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 server_names_hash_bucket_size 128;
  17.                 client_header_buffer_size 32k;
  18.                 large_client_header_buffers 4 32k;
  19.                 client_max_body_size 50m;

  20.                 sendfile on;
  21.                 tcp_nopush     on;

  22.                 keepalive_timeout 60;

  23.                 tcp_nodelay on;

  24.                 fastcgi_connect_timeout 300;
  25.                 fastcgi_send_timeout 300;
  26.                 fastcgi_read_timeout 300;
  27.                 fastcgi_buffer_size 64k;
  28.                 fastcgi_buffers 4 64k;
  29.                 fastcgi_busy_buffers_size 128k;
  30.                 fastcgi_temp_file_write_size 256k;

  31.                 gzip on;
  32.                 gzip_min_length  1k;
  33.                 gzip_buffers     4 16k;
  34.                 gzip_http_version 1.0;
  35.                 gzip_comp_level 2;
  36.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  37.                 gzip_vary on;

  38.                 #limit_zone  crawler  $binary_remote_addr  10m;

  39. server
  40.         {
  41.                 listen       80;
  42.                 server_name bbs.quutoo.com;
  43.                 index index.html index.htm index.php;
  44.                 root  /home/wwwroot;
  45.                 include discuzx.conf;

  46.                 location ~ .*\.(php|php5)?$
  47.                         {
  48.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  49.                                 fastcgi_index index.php;
  50.                                 include fcgi.conf;
  51.                         }

  52.                 location /status {
  53.                         stub_status on;
  54.                         access_log   off;
  55.                 }

  56.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  57.                         {
  58.                                 expires      30d;
  59.                         }

  60.                 location ~ .*\.(js|css)?$
  61.                         {
  62.                                 expires      12h;
  63.                         }

  64.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  65.              '$status $body_bytes_sent "$http_referer" '
  66.              '"$http_user_agent" $http_x_forwarded_for';
  67.                 access_log  /home/wwwlogs/access.log  access;
  68.         }
  69. include vhost/*.conf;
  70. }
复制代码

[ 本帖最后由 im163 于 2011-3-13 02:42 编辑 ]
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2011-3-12 11:46:05 | 显示全部楼层
root  /home/wwwroot;
下面加上include discuzx.conf;
再/usr/local/nginx/sbin/nginx -s reload
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2011-3-12 23:12:56 | 显示全部楼层

回复 13# 的帖子

root  /home/wwwroot;
下面加上include discuzx.conf;
OK了.
谢谢.

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

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-20 00:09 , Processed in 0.031023 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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