1 环境依赖库
Gcc安装命令
yum install gcc-c++ -y
Libevent安装命令
yum -y install libevent
Perl安装命令
yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
Pcre-devel安装命令zlib-devel安装命令
yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
2 安装步骤
A安装libfastcommon库
B安装fdfs(包括tracker和storage)
C配置tracker和storage
D配置nginx-fdfs插件
E配置nginx服务器,fdfs的web服务器
1 安装libfastcommon
cd /opt
chomd 777 *
解压安装 tar -zxvf libfastcommonV1.0.7.tar.gz
./make.sh
./make.sh install
将/usr/lib64/libfastcommon.so文件拷贝到/usr/lib下面
cp /usr/lib64/libfastcommon.so /usr/lib
2 安装fastdfs软件
cd /opt
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
tar -zxvf FastDFS_v5.05.tar.gz
cd FastDFS/
./make.sh
./make.sh install
安装完成后将conf下的配置文件拷贝到/etc/fdfs/目录下
ls
cd conf/
cp * /etc/fdfs/
mkdir /opt/fastdfs/fdfs_storage 存放图片文件
cd /local
mkdir fdfs
3 配置tracker
vi /etc/fdfs/tracker.conf
base_path=/opt/fastdfs
4 配置tracker启动
cd /usr/fdfs/
cp /opt/FastDFS/*.sh ./
修改7处
#!/bin/bash
PRG=/usr/bin/fdfs_trackerd
CONF=/etc/fdfs/tracker.conf
if [ ! -f $PRG ]; then
echo “file $PRG does not exist!”
exit 2
fi
if [ ! -f /usr/local/fdfs/stop.sh ]; then
echo "file /usr/local/fdfs/stop.sh does not exist!"
exit 2
fi
if [ ! -f /usr/local/fdfs/restart.sh ]; then
echo "file /usr/local/fdfs/restart.sh does not exist!"
exit 2
fi
if [ ! -f $CONF ]; then
echo “file $CONF does not exist!”
exit 2
fi
start() {
echo -n $"Starting FastDFS tracker server: "
KaTeX parse error: Expected 'EOF', got '&' at position 5: CMD &̲ RETVAL…?
echo
return $RETVAL
}
stop() {
/usr/local/fdfs/stop.sh
C
M
D
R
E
T
V
A
L
=
CMD RETVAL=
CMDRETVAL=?
return $RETVAL
}
rhstatus() {
status fdfs_trackerd
}
restart() {
/usr/local/fdfs/restart.sh $CMD &
}
启动
chkconfig --add fdfs_trackerd
service fdfs_trackerd start
5 配置storage
新建文件夹mkdir /opt/fastdfs/fdfs_storage
配置 vi /etc/fdfs/storage.conf
base_path=/opt/fastdfs
stora_path0=/opt/fastdfs/fdfs_storage
tracker_server=
6 配置storage启动 5处
vim /etc/init.d/fdfs_storaged
PRG=/usr/bin/fdfs_storaged
CONF=/etc/fdfs/storage.conf
if [ ! -f $PRG ]; then
echo “file $PRG does not exist!”
exit 2
fi
if [ ! -f /usr/local/fdfs/stop.sh ]; then
echo "file /usr/local/fdfs/stop.sh does not exist!"
exit 2
fi
if [ ! -f /usr/local/fdfs/restart.sh ]; then
echo "file /usr/local/fdfs/restart.sh does not exist!"
exit 2
fi
start() {
echo -n $"Starting FastDFS storage server: "
KaTeX parse error: Expected 'EOF', got '&' at position 5: CMD &̲ RETVAL…?
echo
return $RETVAL
}
stop() {
/usr/local/fdfs/stop.sh
C
M
D
R
E
T
V
A
L
=
CMD RETVAL=
CMDRETVAL=?
return $RETVAL
}
rhstatus() {
status fdfs_storaged
}
restart() {
/usr/local/bin/restart.sh $CMD &
}
chkconfig --add fdfs_storaged
service fdfs_storaged start
ps -ef|grep fdfs
注意:配置6处
测试
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/bizhi.jpg
整合nginx服务器
[root@a opt]# tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
[root@a opt]# vi fastdfs-nginx-module/src/config
修改3处
CORE_INCS=“
C
O
R
E
I
N
C
S
/
u
s
r
/
i
n
c
l
u
d
e
/
f
a
s
t
d
f
s
/
u
s
r
/
i
n
c
l
u
d
e
/
f
a
s
t
c
o
m
m
o
n
/
"
C
O
R
E
L
I
B
S
=
"
CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/" CORE_LIBS="
COREINCS/usr/include/fastdfs/usr/include/fastcommon/"CORELIBS="CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient”
将FastDFS-nginx-module/src下的mod_fastdfs.conf拷贝至/etc/fdfs/下
[root@a opt]# cd fastdfs-nginx-module/src
[root@a src]# cp mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
修改4处
base_path=/opt/fastdfs
tracker_server=192.168.39.100:22122
url_have_group_name = true
store_path0=/opt/fastdfs/fdfs_storage
将libfdfsclient.so文件从64目录下拷贝到lib下
cp /usr/lib64/libfdfsclient.so /usr/lib/
安装nginx
cd /opt
tar -zxvf nginx-1.12.2.tar.gz
[root@a src]# mkdir -p /var/temp/nginx/client
安装pcre库
yum -y install pcre-devel
安装zlib库
yum install -y zlib-devel
[root@a nginx-1.12.2]#
./configure
–prefix=/usr/local/nginx
–pid-path=/usr/local/nginx/nginx.pid
–lock-path=/var/lock/nginx.lock
–error-log-path=/var/log/nginx/error.log
–http-log-path=/var/log/nginx/access.log
–with-http_gzip_static_module
–http-client-body-temp-path=/var/temp/nginx/client
–http-proxy-temp-path=/var/temp/nginx/proxy
–http-fastcgi-temp-path=/var/temp/nginx/fastcgi
–http-uwsgi-temp-path=/var/temp/nginx/uwsgi
–http-scgi-temp-path=/var/temp/nginx/scgi
–add-module=/opt/fastdfs-nginx-module/src
[root@a nginx-1.12.2]# make
[root@a nginx-1.12.2]# make install
[root@a nginx-1.12.2]# vi /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name 192.168.39.100;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
ngx_fastdfs_module ;
}
[root@a opt]# cd /usr/local/nginx/sbin
[root@a sbin]# ./nginx
[root@a sbin]# ps -ef|grep nginx
root 27093 1 0 11:03 ? 00:00:00 nginx: master process ./nginx
nobody 27094 27093 0 11:03 ? 00:00:00 nginx: worker process
root 27098 23685 0 11:03 pts/0 00:00:00 grep --color=auto nginx