Tag Archives : Nginx

WordPress在Nginx中启用Apache的mod_rewrite

其实不是真的可以另到 Nginx 支持 Apache 的 mod_rewrite 的.因为如果你的web服务器是 Nginx ,那么你的 WordPress 就会提示你的服务器环境不支持 mod_rewrite 了,但实际上是支持的,例如安装了 WP Super Cache 这插件就有这样的提示了,现在我们只要添加一行代码就可以关闭这个提示,欺骗WordPress ,让它认为是支持 mod_rewrite 方法是在主题的 functions.php 文件添加下面的代码:

add_filter('got_rewrite', 'nginx_has_rewrites');
function nginx_has_rewrites() {
    return true;
}

另外,因为Nginx运行PHP是用PHP-FPM的,所以有时会导致WordPress认为php没有写权限,表现为无法自动升级,和升级插件等,下面这个代码可以修改这个错误.

add_filter('filesystem_method', 'nginx_make_filesystem_direct');
function nginx_make_filesystem_direct() {
    return 'direct';
}
Filed in: WordPress
6

简单配置Nginx前端处理静态文件,LiteSpeed后端处理动态文件

因为我用的LiteSpeed是免费版,连接数只有150的限制,虽然这150的链接也能应付日IP1W的 WordPress 的博客 ,但是网站的流量慢慢增加,不得不提准备,用Nginx 来跑静态文件,减少一些连接请求,何况用Nginx前端的话,负载能力都高点,速度应该也快点吧,所以,我又折腾起来了,然后做个简单记录,防止以后忘记啊,这个就不算什么教程了.
第一步,当然是安装LiteSpeed啦,请看这里:http://imcat.in/litespeed-mysql-php-install/

然后就是安装Nginx了

wget -c http://catlnmp.googlecode.com/files/pcre-8.01.tar.gz
tar zxvf pcre-8.01.tar.gz
cd pcre-8.01/
./configure
make && make install
cd ../

Read more...

Filed in: Linux
30

LNMP 一键安装包平滑升级 Nginx 到最新版本

nginx现在的最新开发版本是0.8.40 ,一些网友就是喜欢最新版本,都问我的LNMP一键安装包怎么升级 Nginx 到最新版本 ,现在,只要你简单的执行几句命令,就可以将 Nginx 升级到最新版本 ,只适合我的LNMP一键安装包,如果你知道你的LNMP安装启动的路径,也可以用这个方法的.

首先下最新版本,解压缩编译

wget http://nginx.org/download/nginx-0.8.40.tar.gz
tar zxvf nginx-0.8.40.tar.gz
cd nginx-0.8.40
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ld-opt='-ltcmalloc_minimal'
make

一定不要make install !!!!!
Read more...

Filed in: Linux
10

nginx 下的 wordpress 3.0 rewrite规则

wordpress 3.0已经出到beta2了,我是版本爱好者,所以早就升级到3.0了,并且也启用多站点功能,但由于我用的web环境是nginx,所以要更新下 wordpress 3.0 rewrite的规则,如下:

#on server block
##necessary if using a multi-site plugin
server_name_in_redirect off;
##necessary if running Nginx behind a reverse-proxy
port_in_redirect off;

rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*.php)$ $1 last;
rewrite ^ /index.php last;
}

已经测试通过了

Filed in: WordPress
13

nginx 的 wordpress rewrite 和WP Super Cache rewrite规则

wordpress.conf

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;
}

supercache.conf

location /
{
autoindex off;
gzip_static on;

set $wp_super_cache_file '';
set $wp_super_cache_uri $request_uri;

if ( $request_method = POST )
{
set $wp_super_cache_uri '';
}

if ( $query_string )
{
set $wp_super_cache_uri '';
}

if ( $http_cookie ~* "comment_author_|wordpress|wp-postpass_" )
{
set $wp_super_cache_uri '';
}

if ( $wp_super_cache_uri ~ ^(.+)$ )
{
set $wp_super_cache_file /wp-content/cache/wp_super_cache/$http_host/$1index.html;
}

if ( -f $document_root$wp_super_cache_file )
{
rewrite ^(.*)$ $wp_super_cache_file break;
}

if (-f $request_filename)
{
expires 30d;
break;
}

if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
Filed in: WordPress
16

一步一步教你安装Nginx+PHP+Mysql

发现很多VPS用LNMP一键安装包都 失败,有不能排错,唯有给出教程,一步一步教你安装,所谓授人于鱼不如授人于渔嘛,本文是在CentOS 5.4 操作系统下测试通过的,用的是DiaHosting上 的32位系统,为什么要用32位系统?就是为了节省内存,VPS内存都不是很多的,纯32位系统比X86_X64兼用32位系统更省内存.

安装步骤:
Read more...

Filed in: Linux
56
© 2007-2010 猫言猫语. All rights reserved. Powered by WordPress. 5 queries in 0.112 seconds.
Proudly designed by Theme Junkie.