安装nginx 的目的是用来访问Fastdfs的存储文件(如图片),所以首先要安装 Fastdfs,请参考 FastDFS tracker storage 在同一台机器上的安装。
1.安装
wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.09.tar.gztar zxvf fastdfs-nginx-module_v1.09.tar.gz
wget http://nginx.org/download/nginx-1.1.9.tar.gz
tar zxvf nginx-1.1.9.tar.gz
cd nginx-1.1.9
./configure --add-module=../fastdfs-nginx-module/src
报错:
./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.
安装pcre-devel
yum -y install pcre-devel
继续
./configure --add-module=../fastdfs-nginx-module/srcmake
make install
cp ../fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
2.配制
ln -sf /usr/local/nginx/sbin/nginx /usr/sbin/cp /var/install/nginx/nginxd /etc/init.d/nginxd
chmod 755 /etc/init.d/nginxd
chkconfig --level 2345 nginxd on
vi /usr/local/nginx/conf/nginx.conf
server {listen 80;
server_name img1.doudang.com;
access_log off;
location /M00 {
root /var/fastdfs/storage/data;
ngx_fastdfs_module;
}
}
ln -s /var/fastdfs/storage/data /var/fastdfs/storage/data/M00
3.测试
nginx -t
[2011-12-21 14:05:01] INFO - fastdfs apache / nginx module v1.09, response_mode=redirect, base_path=/var/log/fastdfs, path_count=1, connect_timeout=2, network_timeout=30, tracker_server_count=2, storage_server_port=23000, group_name=group1, if_alias_prefix=, local_host_ip_count=3, need_find_content_type=0, default_content_type=, anti_steal_token=0, token_ttl=0s, anti_steal_secret_key length=0, token_check_fail content_type=, token_check_fail buff length=0, storage_sync_file_max_delay=86400snginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
4.启动
重启nginx
killall -1 nginx