下载相关依赖(依次执行如下命令)
cd ~
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz -O libfastcommonV1.0.7.tar.gz
wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz -O FastDFS.tar.gz
wget http://mirrors.sohu.com/nginx/nginx-1.8.0.tar.gz
yum install -y gcc gcc-c++
yum -y install libevent
开始部署
tar -zxvf libfastcommonV1.0.7.tar.gz -C /usr/local/
cd /usr/local/libfastcommon-1.0.7/
./make.sh && ./make.sh install
cp /usr/lib64/libfastcommon.so /usr/lib/
安装tracker
cd ~
tar -zxvf FastDFS.tar.gz -C /usr/local/
mv /usr/local/fastdfs-5.05 /usr/local/FastDFS
cd /usr/local/FastDFS/
./make.sh && ./make.sh install
/bin/cp -rf /usr/local/FastDFS/conf/* /etc/fdfs/
cd /etc/fdfs/
cp tracker.conf.sample tracker.conf
sed -i 's/base_path=\/home\/yuqing\/fastdfs/base_path=\/home\/fastdfs/g' tracker.conf
sed -i 's/http.server_port=8080/http.server_port=80/g' tracker.conf
mkdir -p /home/fastdfs
启动tracker
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
配置和启动storage
cd /etc/fdfs/
sed -i 's/192.168.209.121:22122/这里填你的ip/g' storage.conf
sed -i 's/8888/88/g' storage.conf
sed -i 's/store_path0=\/home\/yuqing\/fastdfs/store_path0=\/home\/fdfs_storage /g' storage.conf
sed -i 's/base_path=\/home\/yuqing\/fastdfs/base_path=\/home\/fastdfs/g' storage.conf
mkdir -p /home/fdfs_storage
启动storage
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
通过防火墙开启相关端口
firewall-cmd --zone=public --add-port=22122/tcp --permanent
firewall-cmd --zone=public --add-port=88/tcp --permanent
firewall-cmd --zone=public --add-port=23000/tcp --permanent
firewall-cmd --reload
配置fastdfs-nginx-module
cd ~
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz -C /usr/local
cd /usr/local/fastdfs-nginx-module/src/
sed -i 's/\/usr\/local/\/usr/g' config
cp mod_fastdfs.conf /etc/fdfs/
sed -i 's/base_path=\/tmp/base_path=\/home\/fastdfs/g' /etc/fdfs/mod_fastdfs.conf
sed -i 's/url_have_group_name = false/url_have_group_name = true/g' /etc/fdfs/mod_fastdfs.conf
sed -i 's/tracker_server=tracker:22122/tracker_server=你自己的ip:22122/g' /etc/fdfs/mod_fastdfs.conf
sed -i 's/store_path0=\/home\/yuqing\/fastdfs/store_path0=\/home\/fdfs_storage/g' /etc/fdfs/mod_fastdfs.conf
cp /usr/lib64/libfdfsclient.so /usr/lib/
mkdir -p /var/temp/nginx/client
安装nginx
cd ~
tar -zxvf nginx-1.8.0.tar.gz -C /usr/local/
yum -y install pcre && yum -y install pcre-devel && yum -y install zlib && yum -y install zlib-devel && yum -y install openssl && yum -y install openssl-devel
cd /usr/local/nginx-1.8.0/
./configure --prefix=/usr/local/nginx --pid-path=/var/run/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=/usr/local/fastdfs-nginx-module/src
make && make install
cd /usr/local/FastDFS/conf
/bin/cp -rf http.conf mime.types /etc/fdfs/
mkdir /usr/local/nginx/logs
cd /usr/local/nginx/conf/
vim nginx.conf
image.png
启动nginx
/usr/local/nginx/sbin/nginx
nginx + fastdfs 的开机自启动
1. 编辑文件
vim /etc/rc.d/rc.local
2. 增加如下
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
/usr/local/nginx/sbin/nginx
3、在centos7中, /etc/rc.d/rc.local 文件的权限被降低了,需要给rc.local 文件增加可执行的权限;
chmod +x /etc/rc.d/rc.local
网友评论