RedHat7 FastDFS + Nginx安装libeventlibfastcommonWord格式.docx
《RedHat7 FastDFS + Nginx安装libeventlibfastcommonWord格式.docx》由会员分享,可在线阅读,更多相关《RedHat7 FastDFS + Nginx安装libeventlibfastcommonWord格式.docx(12页珍藏版)》请在冰豆网上搜索。
上传到/softwares
cd/softwares
tar
-zxvpf
libevent-2.0.14-stable.tar.gz
cd
libevent-2.0.14-stable
./configure--prefix=/usr/local/libevent-2.0.14&
&
make&
makeinstall
四、安装FastDFS
FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:
文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。
特别适合以文件为载体的在线服务,如相册网站、视频网站等等。
FastDFS为互联网量身定制,充分考虑了冗余备份、负载均衡、线性扩容等机制,并注重高可用、高性能等指标,使用FastDFS很容易搭建一套高性能的文件服务器集群提供文件上传、下载等服务。
1,安装依赖包,添加fastDFS运行用户
yuminstall-yzlibzlib-develpcrepcre-develgccgcc-c++opensslopenssl-devellibeventlibevent-develperlunzip
useradd-s/sbin/nologinfastdfs
2,创建数据存储目录
mkdir
-p
/softwares/export/fastdfs/{storage,tracker}
#storage目录保存运行日志及其data数据
#tracker目录保存运行日志
3,安装libfastcommon
wget
unzip
master.zip
libfastcommon-master/
./make.sh
./make.sh
install
安装Fastdfs
zxf
fastdfs-5.05.tar.gz
/softwares/fastdfs-5.05
cp
pa
conf/*.conf
/etc/fdfs/
rm
-rf
*.sample
chown
-R
fastdfs:
/softwares/export/fastdfs
5,配置tracker和storage配置文件,对应修改
cd/etc/fdfs
vim
storage.conf
group_name=group1
base_path=/softwares/export/fastdfs/storage
store_path0=/softwares/export/fastdfs/storage
tracker_server=192.168.18.214:
22122
tracker_server=192.168.18.217:
http.server_port=80
tracker.conf
base_path=/softwares/export/fastdfs/tracker
把/softwares/fastdfs-nginx-module/src下的
mod_fastdfs.conf复制到/etc/fdfs
cd/softwares/fastdfs-nginx-module/src
mod_fastdfs.conf
url_have_group_name
=
true
#是true
不是ture
修改完copy到/etc/fdfs下
client.conf
把##includehttp.conf改为#includehttp.conf
http.conf
http.mime_types_filename=
http.anti_steal.token_check_fail=
改为实际mime.types和anti-steal.jpg存在的路径
6,安装nginx和fastdfs-nginx-module模块
http:
//nginx.org/download/nginx-1.8.0.tar.gz
fastdfs-nginx-module_v1.16.tar.gz
nginx-1.8.0.tar.gz
#修改模块中对应的路径,要不然模块不能正确安装加载
/softwares/fastdfs-nginx-module/src
config
#更改如下,
去掉CORE_INCS中的local,并指定lib64(64系统)
CORE_INCS="
$CORE_INCS
/usr/include/fastdfs
/usr/include/fastcommon/"
CORE_LIBS="
$CORE_LIBS
-L/usr/lib64
-lfastcommon
-lfdfsclient"
ulimit
-SHn
102400
useradd
-s
/sbin/nologin
www
/softwares/nginx-1.8.0
./configure
--user=www
--group=www
--add-module=/softwares/fastdfs-nginx-module/src
--prefix=/usr/fdfs/nginx
--with-http_stub_status_module
--with-http_ssl_module
--with-http_realip_module
make
clean
make-B
7,配置nginx
cd/usr/fdfs/nginx/conf
vimnginx.conf
open_file_cachemax=102400inactive=20s;
server{
listen80;
server_name192.168.18.214;
#root/softwares/export/fastdfs/storage/data;
#indexindex.htmlindex.htm;
#if(!
-e$request_filename){
#rewrite^(.*)$/index.htmllast;
#}
location^~/group1/M00/{
alias/softwares/export/fastdfs/storage/data/;
ngx_fastdfs_module;
}
location~.*\.(gif|jpg|jpeg|png|bmp|swf|js|sql)${
#fastcgi_cachecache_one;
#nginx.conf开启cache才行,要不然启动报错
fastcgi_cache_valid20010m;
fastcgi_cache_valid3043m;
fastcgi_cache_valid3013021h;
fastcgi_cache_validany1m;
fastcgi_cache_min_uses1;
fastcgi_cache_use_staleerrortimeoutinvalid_headerhttp_500;
fastcgi_cache_key$host$request_uri;
access_logoff;
}
*************************************************************************************************************************
配置知识扩展
[root]
语法:
rootpath
默认值:
roothtml
配置段:
http、server、location、if
root实例:
如果一个请求的URI是/t/a.html时,web服务器将会返回服务器上的/www/root/html/t/a.html的文件。
[alias]
aliaspath
location
alias实例:
如果一个请求的URI是/t/a.html时,web服务器将会返回服务器上的/www/root/html/new_t/a.html的文件。
注意这里是new_t,因为alias会把location后面配置的路径丢弃掉,把当前匹配到的目录指向到指定的目录。
注意:
1.使用alias时,目录名后面一定要加"
/"
。
3.alias在使用正则匹配时,必须捕捉要匹配的内容并在指定的内容处使用。
4.alias只能位于loca