mkdir fdfs
GCC用来对C语言代码进行编译运行,使用yum命令安装:
sudo yum -y install gcc
unzip工具可以帮我们对压缩包进行解压
sudo yum install -y unzip zip
unzip xx
rm -fr libfastcommon-master.zip
./make.sh && ./make.sh install
tar xvf FastDFS_v5.08.tar.gz
sudo yum -y install libevent
yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
./make.sh && ./make.sh install
ll /etc/init.d/ | grep fdfs
mv tracker.conf.sample tracker.conf
# 编辑
vi tracker.conf
# 修改
base_path=/leyou/fdfs/tracker
mkdir -p /leyou/fdfs/tracker
service fdfs_trackerd start
# 查看是否启动
ps -ef | grep fdfs
chkconfig fdfs_trackerd on
mv storage.conf.sample storage.conf
vi storage.conf
base_path=/leyou/fdfs/storage # storage的数据和日志存放目录
store_path0=/leyou/fdfs/storage # storage的上传文件存放路径
tracker_server=192.168.25.128:22122 # tracker的地址
mkdir -p /leyou/fdfs/storage
sudo service fdfs_storaged start
开机自启
sudo chkconfig fdfs_storaged on
mv client.conf.sample client.conf
修改配置文件,路径和ip
测试
/usr/bin/fdfs_upload_file client.conf /tmp/1.jpg
rm -rf FastDFS_v5.08.tar.gz
tar xvf fastdfs-nginx-module_v1.16.tar.gz
# 删除
rm -rf fastdfs-nginx-module_v1.16.tar.gz
[root@localhost src]# vi config
# 执行下面命令(将配置中的/usr/local改为/usr):
:%s+/usr/local/+/usr/+g
cp mod_fastdfs.conf /etc/fdfs/
connect_timeout=10 # 客户端访问文件连接超时时长(单位:秒)
tracker_server=192.168.25.128:22122 # tracker服务IP和端口
url_have_group_name=true # 访问链接前缀加上组名
store_path0=/leyou/fdfs/storage # 文件存储路径
cd /home/leyou/fdfs/FastFDFS/conf
[root@localhost conf]# cp http.conf mime.types /etc/fdfs/
sudo ./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx --add-module=/home/leyou/fdfs/fastdfs-nginx-module/src
make
[root@localhost objs]# cp nginx /usr/bin/
添加image服务器配置文件
vi /etc/init.d/nginx
添加
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/bin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/opt/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -n "$user" ]; then
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
fi
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
# 修改权限
chmod 777 /etc/init.d/nginx
# 添加到服务列表
chkconfig --add /etc/init.d/nginx
chkconfig nginx on
[root@localhost nginx-1.14.2]# firewall-cmd --zone=public --add-port=9001/tcp --permanent
success
[root@localhost nginx-1.14.2]# firewall-cmd --zone=public --add-port=10010/tcp --permanent
success