在nginx下启用wordpress multisite

http://codex.wordpress.org/Nginx
http://rtcamp.com/wordpress-nginx/tutorials/multisite/create-a-network/
http://wpmu.org/wordpress-multisite-wordpress-nginx/
http://wiki.nginx.org/WordPress

不同的文档有不同的解决方案。

http://wiki.nginx.org/WordPress 的方案有这么几点:

首先要加map指令

<a href="http://wiki.nginx.org/NginxHttpMapModule#map">map</a> $http_host $blogid {
    default       -999;

    #Ref: http://wordpress.org/extend/plugins/nginx-helper/
    #include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;

}

这个的作用是手工定义了网站名$http_host和网站id$blogid之间的对应关系。比如

We use Nginx’s map {..} section to hold site-names and site-ids pairs as you can see in following example:

<code>map $http_host $blogid {
    default               0;

    example.com           1;
    site1.example.com 	  2;
    site1.com 	   	  2;
}</code>

Using it, Nginx can map a request for file:

<code>http://site1.com/files/2012/09/somefile.png</code>

to file-system path:

<code>/var/www/example.com/htdocs/wp-content/blogs.dir/2/2012/09/somefile.png
</code>

这个里面 site1.com 就和 2 对应了。有了这个手工对应就不需要再进行数据库查询。换句话说,这个指令不用multisite也可以正常运作。

然后就是server{}里面的配置。

<a href="http://wiki.nginx.org/NginxHttpCoreModule#server_name">server_name</a> example.com *.example.com ;
<a href="http://wiki.nginx.org/NginxHttpCoreModule#root">root</a> /var/www/example.com/htdocs;
<a href="http://wiki.nginx.org/NginxHttpCoreModule#index">index</a> <a href="http://wiki.nginx.org/NginxHttpCoreModule#index">index</a>.php;

这些是基本配置了,没什么特别。

<a href="http://wiki.nginx.org/NginxHttpCoreModule#location">location</a> / {
		<a href="http://wiki.nginx.org/NginxHttpCoreModule#try_files">try_files</a> $uri $uri/ /<a href="http://wiki.nginx.org/NginxHttpCoreModule#index">index</a>.php?$args ;
	}
 这个指令将$uri内部转向到 /<a href="http://wiki.nginx.org/NginxHttpCoreModule#index">index</a>.php?$args

<a href="http://wiki.nginx.org/NginxHttpCoreModule#location">location</a> ~ \.php$ {
		<a href="http://wiki.nginx.org/NginxHttpCoreModule#try_files">try_files</a> $uri =404;
		<a href="http://wiki.nginx.org/NginxHttpCoreModule#include">include</a> fastcgi_params;
		<a href="http://wiki.nginx.org/NginxHttpFcgiModule#fastcgi_pass">fastcgi_pass</a> php;
	}

	#WPMU Files
        <a href="http://wiki.nginx.org/NginxHttpCoreModule#location">location</a> ~ ^/files/(.*)$ {
                <a href="http://wiki.nginx.org/NginxHttpCoreModule#try_files">try_files</a> /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1 ;
                <a href="http://wiki.nginx.org/NginxHttpLogModule#access_log">access_log</a> off; <a href="http://wiki.nginx.org/NginxHttpCoreModule#log_not_found">log_not_found</a> off;      <a href="http://wiki.nginx.org/NginxHttpHeadersModule#expires">expires</a> max;
        }

	#WPMU x-sendfile to avoid php readfile()
	<a href="http://wiki.nginx.org/NginxHttpCoreModule#location">location</a> ^~ /blogs.dir {
		<a href="http://wiki.nginx.org/NginxHttpCoreModule#internal">internal</a>;
		<a href="http://wiki.nginx.org/NginxHttpCoreModule#alias">alias</a> /var/www/example.com/htdocs/wp-content/blogs.dir;
		<a href="http://wiki.nginx.org/NginxHttpLogModule#access_log">access_log</a> off;	<a href="http://wiki.nginx.org/NginxHttpCoreModule#log_not_found">log_not_found</a> off;	<a href="http://wiki.nginx.org/NginxHttpHeadersModule#expires">expires</a> max;
	}

Apache2.4.2下的403Forbidden问题

今天安装最新版本的Apache2.4.2。配置虚拟主机后,一直是403Forbidden,但localhost正常。反复检查Directory无误:


Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all

后在此发现解决方法http://stackoverflow.com/questions/89118/apache-gives-me-403-access-forbidden-when-documentroot-points-to-two-different-d

根据http://httpd.apache.org/docs/2.4/upgrading.html, 原来2.4用来控制访问的方式已经不同。

Access control
In 2.2, access control based on client hostname, IP address, and other characteristics of client requests was done using the directives Order, Allow, Deny, and Satisfy.

In 2.4, such access control is done in the same way as other authorization checks, using the new module mod_authz_host. The old access control idioms should be replaced by the new authentication mechanisms, although for compatibility with old configurations, the new module mod_access_compat is provided.

Here are some examples of old and new ways to do the same access control.

In this example, all requests are denied.

2.2 configuration:

Order deny,allow
Deny from all
2.4 configuration:

Require all denied
In this example, all requests are allowed.

2.2 configuration:

Order allow,deny
Allow from all
2.4 configuration:

Require all granted
In the following example, all hosts in the example.org domain are allowed access; all other hosts are denied access.

2.2 configuration:

Order Deny,Allow
Deny from all
Allow from example.org
2.4 configuration:

Require host example.org

IBMX346安装2008R2的RAID驱动问题

老服务器,用来作为测试。原带的ServerRaid光盘已经丢失。2008和2012均需要raid驱动。但是IBM官网的raid驱动下载均失效。
经测试adaptec网站的Ultra320驱动可用。解压到U盘,安装时加载驱动即可。
Ultra320 32-bit HostRAID Drivers v2.0.0.212 for Windows Server 2008
Ultra320 HostRAID Drivers Ver. 2.0.0.213 for Windows 7 and Server 2008R2
搜索驱动的时候看到一个哥们的悲惨遭遇

越狱版ios5.0.1升级6.1的问题

之前不知道越狱版本不可直接升级6.1。
下载固件后用iTunes进行更新。提示未知问题6,iPhone进入恢复模式。使用iTools退出恢复模式,即进入无限循环的白苹果显示/黑屏。
Home+Power重新启动不管用。
可以重新进入恢复模式,但是还有很多未备份资料。
最后使用redsn0w重新越狱一遍,问题解决。

VShpere迁移CentOS6.X后eth0不可用的解决方式

为了避免mac地址冲突,迁移的时候vshpere自动更改了mac地址并增加了eth1。所以eth0就不可用了,centos认出一个eth1。

这时候可以把eth0的IP配置复制给eth1,但是我不喜欢这种没有0而又1之后迁移又变成2345的方式。

所以,vi /etc/udev/rules.d/70-persistent-net.rules,将etho0那行注释,将系统增加的eth1的名称改为eth0
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:0c:29:96:cc:5e”, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth0″

其次,编辑/etc/sysconfig/network-script/ifcfg-eth0 文件中的 HWADDR 地址,改为上面文件里面看到的 ATTR

reboot,完事。

centos6.3下安装nginx

根据 http://wiki.nginx.org/Install

To add nginx yum repository, create a file named /etc/yum.repos.d/nginx.repo and paste one of the configurations below:

CentOS:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

增加yum这个源之后即可yum install nginx

安装后需打开本地防火墙80端口。编辑/etc/sysconfig/iptables,加入

-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT

之后service iptables restart即可

vsphere下centos安装vmtools

centos并不能完全自动安装vmtools。

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2004754 指出,可以安装操作系统自带的包。但是在centos下的yum命令并找不到vmwaretools。

根据http://community.spiceworks.com/how_to/show/2805-vmware-tools-on-centos 所述进行手动安装。

1.
Open terminal and switch to the root user
su root

2.
Update the VM
yum update

3.
Reboot after the updates have completed
reboot

4.
Log back in, open terminal, and switch back to the root user
su root

5.
Install the GNU Compiler Collection (GCC)
yum install gcc kernel-devel

6.
Mount the VMWare Tools ISO
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom

7.
Copy VMware Tools to the hard drive
cp /mnt/cdrom/VMwareTools*.gz /tmp

8.
Navigate to the /tmp folder
cd /tmp

9.
Extract the VMware Tools tarball to /tmp
tar -C /tmp -zxvf VMwareTools*.gz

10.
Drill down into the extracted directory
cd vmware-tools-distrib

11.
Execute the installer
./vmware-install.pl

注意mount时要先创建/mnt/cdrom目录。其他的一路回车就行,有一些备份和磁盘管理方面的选项默认是no,如需要改为yes。

T410si升级1.8寸msata固态硬盘

前一阵子笔记本的硬盘频繁出现警告,win7检测到硬盘问题。重装了系统,警告依旧。把所有内容都备份后准备更换为固态硬盘,但是SKS那里居然没有盘卖,也不能告诉我哪里能拿到。
因为遵循旧的思路,想把原来插槽里面的1.8寸旧盘换掉,在京东及中关村寻觅多次均不可得。taobao上的有1000多,价格不能接受。
今天偶然又翻阅京东,看到http://www.360buy.com/product/565612.html的评论中讲到可以把这种小卡插到3G模块接口。但是评价msata接口的速度只是和原来的7200转持平,建议上光驱位转换器sata接口,可是转换器也得好几百!
一淘之后发现亚马逊更便宜。先买来看看,速度上不做太高要求了。等到货了上图。