CentOS Installation Fastdfs+nginx

Source: Internet
Author: User
Tags crc32 file url install openssl openssl iptables


First, the installation of Fastdfs must be installed before libevent, installation libevent steps as follows:



1. Download Libevent:



wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
2. Decompression Libevent:



TAR-ZXVPF libevent-2.0.21-stable.tar.gz



3. Into the Decompression directory:



CD libevent-2.0.21-stable



4. Specify the installation directory:



./configure--prefix=/usr/local/libevent-2.0.21



5. Install Libevent:



Make



Make install



Second, the installation Fastdfs steps are as follows:



1. Download Fastdfs:



wget http://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz



2. Decompression Fastdfs:



Tar xvf fastdfs_v4.06.tar.gz



3. Into the Decompression directory:



CD Fastdfs
4. Modify the Fastdfs installation files:



VI make.sh



TARGET_PREFIX=/USR/LOCAL/FASTDFS---installation path



Target_conf_path=/etc/fdfs---configuration file path



With_linux_service=1---for LINUX services



5. Specify the Lib directory for Libevent:



./make.sh C_include_path=/usr/local/libevent-2.0.21/include Library_path=/usr/local/libevent-2.0.21/lib
6. Install Fastdfs:



./make.sh Install



7. Set up soft connection (otherwise compile Nginx error)
Ln-sv/usr/local/fastdfs/include/fastcommon/usr/local/include/fastcommon
Ln-sv/usr/local/fastdfs/include/fastdfs/usr/local/include/fastdfs
Ln-sv/usr/local/fastdfs/lib/libfastcommon.so/usr/local/lib/libfastcommon.so
Ln-sv/usr/local/fastdfs/lib/libfastcommon.so.1/usr/local/lib/libfastcommon.so.1
Ln-sv/usr/local/fastdfs/lib/libfdfsclient.so/usr/local/lib/libfdfsclient.so
Ln-sv/usr/local/fastdfs/lib/libfdfsclient.so.1/usr/local/lib/libfdfsclient.so.1






Before installing Nginx, you need to install the GCC, openssl-devel, Pcre-devel, and Zlib-devel software libraries, as follows:



Yum Install gcc-c++



Yum Install Openssl-devel



Yum Install Pcre-devel



Yum Install Zlib-devel






Iv. installation of Nginx and Fastdfs-nginx-module



wget http://nginx.org/download/nginx-1.6.0.tar.gz



wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz



Upload the installation package file to/usr/local to perform the following actions:



1. Access to file directory:



Cd/usr/local



2. Unpack the installation package:



Tar-zxv-f nginx-1.6.0.tar.gz



TAR-XVF fastdfs-nginx-module_v1.15.tar.gz



3. Modify the installation package directory name:



MV nginx-1.6.0 Nginx



4. Enter the installation package directory:



Cd/usr/local/nginx



5. Configure installation directory:



./configure--prefix=/usr/local/nginx--conf-path=/usr/local/nginx/nginx.conf--add-module=/usr/local/ Fastdfs-nginx-module/src
6. Install Nginx:



Make
Make install



7. Modify the firewall:



VI +/etc/sysconfig/iptables



8. Add Configuration Items
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT



9. Reboot the firewall:



Service Iptables Restart



10. Copy libfastcommon.so, Libfastcommon.so.1, libfdfsclient.so, libfdfsclient.so.1 to/usr/lib,



Otherwise the Nginx boot will complain.



Nginx Operations:



Start:



/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf
Or



Cd/usr/local/nginx/sbin
./nginx






Stop service:



#Query nginx main process number
Ps-ef | grep nginx
#Stop process
Kill-quit Main process Number
#Quick stop
Kill-term Main process Number
#Force stop
Pkill-9 Nginx






Reboot:



/usr/local/nginx/sbin/nginx-s Reload






V. Configure Tracker Server:



1. vi/etc/fdfs/tracker.conf
bind_addr=192.168.227.128
Base_path=/home/tracker/fastdfs



2. Configure the firewall:



Iptables-i input-p tcp-m State--state new-m TCP--dport 22122-j



3. Save the configuration:



/etc/init.d/iptables Save
4. Start Tracker
/usr/local/fastdfs/bin/fdfs_trackerd/etc/fdfs/tracker.conf



In the starting times wrong:



/usr/local/bin/fdfs_trackerd:error while loading shared libraries:libevent-2.0.so.5:cannot open Shared object File:no Such file or directory



You can start normally by executing the following command:



Echo '/usr/local/libevent-2.0.21/include/' >>/etc/ld.so.conf
Echo '/usr/local/libevent-2.0.21/lib/' >>/etc/ld.so.conf
Ldconfig
5. View Listener:



Netstat-ntpl | grep Fdfs



6. View Log file:



Cat/home/tracker/fastdfs/logs/trackerd.log
7. Add boot Start command line:



Vim/etc/rc.d/rc.local
/usr/local/fastdfs/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart






VI. Configuring Storage Server
1. vi/etc/fdfs/storage.conf
Group_name=group1
bind_addr=192.168.227.130
Base_path=/home/storage/fastdfs
Store_path0=/home/storage/fastdfs
tracker_server=192.168.227.130:22122
Http.server.port=80



2. cp/usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/



3. vi/etc/fdfs/mod_fastdfs.conf
Base_path=/home/storage1/fastdfs
Group_name=group1



Store_path0=/home/stroage1/fastdfs



tracker_server=192.168.227.128:22122



Url_have_group_name = True
Group_count = 0



4. vi/usr/local/nginx/conf/nginx.conf
location/group1/m00 {
Root/home/storage1/fastdfs/data;
Ngx_fastdfs_module;
}



5. Configure the firewall:



Iptables-i input-p tcp-m State--state new-m TCP--dport 23000-j ACCEPT



6. Save the configuration:



/etc/init.d/iptables Save



7. Start Storage
/usr/local/fastdfs/bin/fdfs_storaged/etc/fdfs/storage.conf



8. View Listener:



Netstat-ntpl | grep Fdfs



9. View Log file:



Cat/home/storage/fastdfs/logs/storaged.log



Seven, test:



/usr/local/fastdfs/bin/fdfs_test/etc/fdfs/client.conf upload/etc/passwd
The results are as follows:



This is FASTDFS the client test program v4.06



Copyright (C) 2008, Happy fish/yuqing



Fastdfs May is copied only under the terms of the GNU general
Public License V3, which May is found in the FASTDFS source kit.
Please visit the Fastdfs home Page http://www.csource.org/
For more detail.



[2014-06-03 20:26:21] Debug-base_path=/home/client/fastdfs, connect_timeout=30, network_timeout=60, Tracker_server_count=1, Anti_steal_ Token=0, Anti_steal_secret_key length=0, Use_connection_pool=0, g_connection_pool_max_idle_time=3600s, Use_storage_ Id=0, storage server ID count:0



Tracker_query_storage_store_list_without_group:
Server 1. Group_name=, ip_addr=192.168.227.130, port=23000



Group_name=group1, ip_addr=192.168.227.130, port=23000
Storage_upload_by_filename
Group_name=group1, remote_filename=m00/00/00/wkjjglookd2adziiaaafng0nczs9728851
Source IP address:192.168.227.130
File timestamp=2014-06-03 20:26:21
File size=1438
File crc32=218985275
File url:http://192.168.227.130/group1/m00/00/00/wkjjglookd2adziiaaafng0nczs9728851
Storage_upload_slave_by_filename
Group_name=group1, Remote_filename=m00/00/00/wkjjglookd2adziiaaafng0nczs9728851_big
Source IP address:192.168.227.130
File timestamp=2014-06-03 20:26:21
File size=1438
File crc32=218985275
File Url:http://192.168.227.130/group1/m00/00/00/wkjjglookd2adziiaaafng0nczs9728851_big



Open Http://192.168.227.130/group1/M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851_big on the browser



Test success ...






Reference: http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html



            http://blog.csdn.net/yl_wh/article/ details/8784569


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.