1、准备工作
在nginx运行前我们需要拷贝文件,把windows服务器上的静态文件拷贝到linux服务器上,同时将文件和目录全部转换为小写,可以按如下方法做:
将windows目标目录共享,在linux下mount,(在192.168.18.241上操作)如:
[root@vm4 ~]# mount -o username=username,password=pwd
//192.168.18.249/c/tmp/webroot /mnt
开始拷贝
[root@vm4 ~]# find /mnt/ | xargs -n1|while read s_name do d_name=$(echo /data/webroot/${s_name#/mnt/}|tr 'A-Z' 'a-z') [ -d "$s_name" ] && install -d "$d_name" && continue cp $s_name $d_name chmod 644 $d_name done
如果没有错误的话,现在本地的文件和目录应该都是小写的了,如有更高效的拷贝方法请朋友告知!3ks
2、安装nginx模块ngx_http_lower_upper_case(在192.168.18.240上操作)
[root@vm3 ~]# git clone http://github.com/replay/ngx_http_lower_upper_case.git [root@vm3 ~]# cd nginx-1.2.6 [root@vm3 ~]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --add-module=../ngx_http_lower_upper_case/ [root@vm3 ~]# make [root@vm3 ~]# make install
3、配置nginx(在192.168.18.240上操作)
[root@vm3 ~]# grep -v '^[[:space:]]*#|^$' /usr/local/nginx/conf/nginx.conf 或 [root@vm3 ~]# egrep -v '^[[:space:]]*#|^$' /usr/local/nginx/conf/nginx.conf user apache; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; root html; index index.html index.htm; location ~* ".php$" { fastcgi_pass 127.0.0.1:9000; include fastcgi.conf; } location / { lower $lower_uri "$request_uri"; rewrite .* $lower_uri break; proxy_pass http://192.168.18.241; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
用-t测试配置文件,启动或重启nginx
[root@vm3 ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf