码迷,mamicode.com
首页 > 其他好文 > 详细

Wordpress3.9开启多站点配置配置nginx进行局域网测试.

时间:2014-08-04 11:05:57      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   使用   os   io   文件   数据   

因为需要帮staff迁移一些数据, 所以想到了使用wordpress的多站点. 这个功能在wordpress3.0后就有了.

软件系统等信息:  OS: linux debian wheezy

php:5.4.4-14

mysql:5.5.37

server:nginx1.2.1 /apache 2.2.2

首先下载wordpress3.9, 安装的时候, 需要注意一下 我的www目录是/home/www, 所在把wordpress的路径是 /home/www/wordpress 

我的nginx默认没有配置任何东西, 所以直接浏览器输入

127.0.0.1/wordpress/wp-admin/install.php 就可以安装了. 但是这里不能这样, 因为多站点基于localhost的nginx rewrite是无效的, 所以这里我们需要先配置nginx的虚拟主机.

在debian里面, nginx的配置文件是/etc/nginx/nginx.conf 来管理全局的. 在/etc/nginx/site-available 和/etc/nginx/conf.d 是用来管理虚拟主机的

这里我们新建一个叫wp的文件 在/etc/nginx/site-available/wp

#touch /etc/nginx/site-available/wp

加入下面的内容, 注意这里我们是实用的基于域名的.

{
    listen 80;
    server_name wp.com www.wp.com *.wp.com;
    charset utf-8;
    index index.html index.htm index.php;
    root /home/www/wordpress;

    location / {
        autoindex on;
        autoindex_exact_size on;
        autoindex_localtime on;
        index index.php index.html;
        if (!-f $request_filename) {
            rewrite ^(.*)$ /index.php?_rp_=$1 last;
            break;
        }
    }

    location ~ .*\.(git|jpg|jpeg|png|bmp|swf)$ {
        expires 1d;
    }
    location ~ .*\.(js|css)?$ {
        expires 12h;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /home/www/wordpress$fastcgi_script_name;
        include fastcgi_params;
    }

    location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        allow ::1;
        deny all;
    }
}
然后因为是本地测试, 所以需要修改上面的server name的hosts

#vim /etc/hosts

增加下面一行在hosts里面

127.0.0.1 *.wp.com www.wp.com wp.com

接着重加载下nginx

#nginx -t 测试通过然后重加载

#/etc/init.d/nginx reload

现在用wp.com 就可以访问初始的wordpress安装界面了








Wordpress3.9开启多站点配置配置nginx进行局域网测试.,布布扣,bubuko.com

Wordpress3.9开启多站点配置配置nginx进行局域网测试.

标签:style   blog   color   使用   os   io   文件   数据   

原文地址:http://blog.csdn.net/rainysia/article/details/32150615

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!