首页 技术 正文
技术 2022年11月20日
0 收藏 582 点赞 3,082 浏览 2176 个字

由于须要帮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安装界面了

附上子域名和子文件夹的apache配置

define(‘SUBDOMAIN_INSTALL’, false); false是子文件夹, true是子域名 (子文件夹訪问是通过http://xxx.com/网站2 网站来的, 子域名是通过http://网站2.www.com来訪问的)

子域名的

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

子文件夹的 

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,086
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,561
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,410
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,183
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,820
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,903