需要安装的软件:pcre-8.30、nginx、nginx-gridfs-0.8.tar.gz、mongo-c-driver-0.3.1.tar.gz、mongodb
安装步骤:
for packages in patch make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap; do yum -y install $packages; done
tar zxvf pcre-8.30.tar.gz
cd pcre-8.30
./configure
make && make install
vi /etc/ld.so.conf
增加一行:/usr/local/lib
ldconfig
nginx安装:
groupadd www
useradd -s /sbin/nologin -g www www
tar xvfz nginx-1.7.0.tar.gz
tar -xzvf ./nginx-gridfs-0.8.tar.gz
tar -xzvf ./mongo-c-driver-0.3.1.tar.gz
mv ./mongo-c-driver-0.3.1/* ./nginx-gridfs-0.8/mongo-c-driver
cd nginx-1.7.0
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 --add-module=../nginx-gridfs-0.8
make && make install
cd ..
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
tar xvfz nginx-conf.tgz
cp -f nginx-conf/nginx.conf /usr/local/nginx/conf/nginx.conf
cp nginx-conf/init.d.nginx /etc/init.d/nginx
chmod +x /etc/init.d/nginx
chkconfig --level 345 nginx on
cp nginx-conf/vhost.sh /root
chmod +x /root/vhost.sh
mkdir -p /data/wwwroot/default
chmod +w /data/wwwroot/default
mkdir -p /data/wwwlogs
chmod 777 /data/wwwlogs
chown -R www:www /data/wwwroot/default
cp nginx-conf/index.html /data/wwwroot/default/
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 443 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/rc.d/init.d/iptables status
启动nginx(需要先启动mongodb): service nginx start
停止nginx:service nginx stop
验证mongodb图片服务:
图片测试数据库迁移:
mongodump -d yb_pics
数据库恢复:
tar xvfz ybpics150801.tgz
cd ybpic
/opt/mongodb/bin/mongorestore -d yb_pics dump/*
nginx增加配置:
location /ybpics/ {
gridfs yb_pics field=filename type=string;
mongo XXX.XXX.XXX.XXX:27017;
}
测试图片:
wget 127.0.0.1/ybpics/cysz.jpg
测试地址:
http://127.0.0.1/ybpics/2f051464e6714ee99457e8ba65344118.jpg
开机启动:
1. vi /etc/init.d/nginx
原文:http://www.cnblogs.com/FCWORLD/p/5118078.html