CentOS 6.4 i386 版本安装 FastDFS、使用Nginx作为文件访问WEB服务器
安裝環境:
1. CentOS-6.4-i386
2. FastDFS_v4.06
3. fastdfs-nginx-module_v1.15
4.?Nginx-1.5.6(安裝見此)
5.?libevent-2.0.21-stable
? ? #yum預裝常用的服務器軟件
? ? ? yum -y install gcc gcc-c++
2.?系統操作環境的設置
? ??#軟件安裝包存儲
? ? ? /usr/local/src
? ? #libevent安裝目錄
? ? ? /usr/local/libevent #fastdfs安裝目錄
? ? ? /usr/local/fastdfs
? ? #nginx安裝目錄
? ? ? /usr/local/nginx 3. 安裝libevent(?fastdfs在編譯源程序時fastdfs內部調用libevent的處理機制,,需要用到libevent一些依賴文件,否則編譯fastdfs會出錯)
? ??#卸載系統自帶libevent,自帶版本過低,安裝fastdfs會出錯
? ? ? 1> rpm -qa|grep libevent
? ? ? 2> yum remove libevent*
? ??#下載安裝libevent:
? ? ? 1> wget?https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
? ? ? 2> tar -zxvf?libevent-2.0.21-stable.tar.gz
? ? ? 3> cd?libevent-2.0.21-stable
? ? ? 4> ./configure --prefix=/usr/local/libevent
? ? ? 5> make && make install
? ??#為libevent創建軟鏈接到/lib庫下,64位系統對應/lib64
? ? ? ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
? ? ? ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5 4. 安裝FastDFS
? ??1> wget?http://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz
? ??2> tar -zxvf?FastDFS_v4.06.tar.gz
? ? 3> cd?FastDFS
? ? 4> #由于定義/usr/local/fastdfs為fastdfs安裝目錄,所以需要修改make.sh
? ? ? ? ? ?vi make.sh
? ? ? ? ? ?#內容更改如下 TARGET_PREFIX=/usr/local 修改為 /usr/local/fastdfs
? ? ? ? ? ?將/etc/fdfs 全部替換為 /usr/local/fastdfs/conf
? ? 5>?#安裝
? ? ? ? ? ?./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib
? ? ? ? ? ?./make.sh install 5. 配置Tracker
? ?#創建tracker目錄保存運行日志
? ? ?mkdir -m 777 -p /home/fastdfs/tracker
? ?#修改tracker.conf配置
? ? ?vim /usr/local/fastdfs/conf/tracker.conf
? ? ?#修改內容如下所示
# the tracker server port port=22122 # the base path to store data and log files base_path=/home/yuqing/fastdfs -> base_path=/home/fastdfs/tracker #日志目錄 #開啟自定義server ID取代ip形式,方便內部網絡服務器更換ip#**此方式要重點理解,4.0以后新特性 use_storage_id = true #使用server ID作為storage server標識 storage_ids_filename = storage_ids.conf #<id> <group_name> <ip_or_hostname> id_type_in_filename = id #文件名反解析中包含server ID,以前是ip View Code
? ?#移動storage_ids.conf文件
? ? ?cp -r /usr/local/src/FastDFS/conf/storage_ids.conf /usr/local/fastdfs/conf/
? ?#編輯storage服務器ID與IP地址的對應關系
? ? ?vim /usr/local/fastdfs/conf/storage_ids.conf
? ? ?#修改內容如下所示
? ?#編輯啟動腳本
? ? ?vim /etc/init.d/fdfs_trackerd
? ? ?#啟動腳本內容如下
? ?#給啟動腳本增加權限
? ? ?chmod 777 /etc/init.d/fdfs_trackerd
? ?#啟動tracker
? ? ?service fdfs_trackerd restart
? ?#啟動成功,加入開機啟動
? ? ?vim /etc/rc.d/rc.local
? ? ?#加入內容如下
? ? ?service fdfs_trackerd start
? ?#防火墻開啟tracker端口22122
? ? ?vim /etc/sysconfig/iptables
? ? ?#加入內容如下
? ? ?-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT
? ?#重啟防火墻
? ? ?service iptables restart
???#創建Storage目錄保存運行日志及其data數據
? ? ?mkdir -m 777 -p /home/fastdfs/storage
? ?#修改storage.conf配置
? ? ?vim /usr/local/fastdfs/conf/storage.conf
? ?#修改內容如下所示
vim /usr/local/fastdfs/conf/storage.conf # the name of the group this storage server belongs to group_name=group1 #設置組名 # the name of the group this storage server belongs to # the storage server port #the storage server port port=23000 # the base path to store data and log files #日志目錄 base_path=/home/yuqing/fastdfs -> /home/fastdfs/storage # store_path#, based 0, if store_path0 not exists, it's value is base_path #data數據存儲目錄 # the paths must be exist store_path0=/home/fastdfs/storage # tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address tracker_server=192.168.209.121:22122 ->192.168.1.11:22122 View Code
? ?#編輯啟動腳本
? ? ?vim /etc/init.d/fdfs_storaged
? ? ?#啟動腳本內容如下
? ?#給啟動腳本增加權限
? ? ?chmod 777 /etc/init.d/fdfs_storaged
? ?#啟動storage
? ? ?service fdfs_storaged restart
? ?#接下來會出現很多mkdir data path,這是系統在創建數據目錄,如下圖所示
? ?
? ?#啟動成功,加入開機啟動
? ? ?vim /etc/rc.d/rc.local
? ? ?#加入內容如下
? ? ?service fdfs_storaged start
7. 安裝nginx(僅Storage)
? ??#創建nginx日志目錄
? ? ??mkdir -m 777 -p /home/www/logs
? ? #安裝nginx必需的庫:zlib-devel openssl-devel pcre
? ? ??yum -y install zlib-devel openssl-devel
? ? ? #手動安裝pcre
? ? ? 1> wget?ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
? ? ? 2> tar -zxvf?pcre-8.33.tar.gz
? ? ? 3> cd?pcre-8.33
? ? ? 4> ./configure
? ? ? 5> make && make install
?? ? ?6> ln -s /usr/local/lib/libpcre.so.1 /lib
? ? #安裝nginx
? ? ??1> wget?http://nginx.org/download/nginx-1.5.6.tar.gz
? ? ? 2> tar -zxvf?nginx-1.5.6.tar.gz
? ? ? 3> cd?nginx-1.5.6
? ? ? 4> ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
? ? ? 5> make && make install
? ? ?#檢查nginx配置是否正確
? ? ? ?/usr/local/nginx/sbin/nginx -t
? ? ?#出現以下類似信息表示配置正確
? ? ?
? ? ?#查看nginx編譯選項
? ? ? ?/usr/local/nginx/sbin/nginx -V
? ? ?#編輯啟動腳本
? ? ? ?vim /etc/init.d/fdfs_storaged
? ? ? ?#啟動腳本內容如下
? ? ?#給啟動腳本增加權限
? ? ? ?chmod 777 /etc/init.d/nginxd
? ? ?#啟動nginx
? ? ? ?service nginxd restart
? ? ?#啟動成功,加入開機啟動
? ? ? ?vim /etc/rc.d/rc.local
? ? ? ?#加入內容如下
? ? ? ?service nginxd start
?
8.?安裝nginx-module模塊(僅Storage)
? ? 1>?wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz
? ? 2>?tar -zxvf fastdfs-nginx-module_v1.15.tar.gz;
? ? #修改插件配置文件
? ? ??vim /usr/local/src/fastdfs-nginx-module/src/config
? ? ? #修改內容如下
? ??#復制mod_fastdfs.conf到/usr/local/fastdfs/conf/目錄下
? ? ??cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /usr/local/fastdfs/conf/
? ? #將/usr/local/fastdfs/lib 加入系統文件/etc/ld.so.conf中(編譯時使用的動態鏈接庫)
? ? ??vim /etc/ld.so.conf
? ? ? #修改內容如下
? ? ??/usr/local/fastdfs/lib
? ??#更新庫文件緩存ld.so.cache
? ? ??/sbin/ldconfig
? ? #編譯fastdfs-nginx-module模塊
? ? ? 1>?cd nginx-1.1.19/
? ? ? 2>?./configure 此處加上nginx之前的編譯參數(使用 /usr/local/nginx/sbin/nginx -V 命令查看) --add-module=/usr/local/src/fastdfs-nginx-module/src
? ? ? 3>?make && make install
? ? #修改mod_fastdfs.conf配置
? ? ? vim /usr/local/fastdfs/conf/mod_fastdfs.conf
? ? ? #修改內容如下
? ? #修改nginx.conf配置
? ? ??vim /usr/local/nginx/conf/nginx.conf
? ? ? #修改內容如下
? ? #重啟nginx服務
? ? service nginxd restart
9. 測試FastDFS
? ??
? ? ??
?
轉載于:https://www.cnblogs.com/zengen/p/3425886.html
總結
以上是生活随笔為你收集整理的CentOS 6.4 i386 版本安装 FastDFS、使用Nginx作为文件访问WEB服务器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PHP之PHP文件引用详解
- 下一篇: 如何让U盘支持大于4G的文件