CentOS6.9部署Redis3.2.9+FastDFS_4.06+Nginx1.5.0
CentOS6.9部署Redis3.2.9+FastDFS_4.06+Nginx1.5.0
原文链接:https://www.toutiao.com/i6481931577499582990/
一、上传Redis工具包
二、安装Redis
1、编译安装
解压redis: tar -zxvf redis-3.2.9.tar.gz
重命名redis:mv redis-3.2.9 /usr/local/redis
编译安装redis
make MALLOC=libc
问题:gcc找不到的错误
解决: yum install gcc 命令安装gcc
make install
2、修改配置文件
(1)修改配置文件 redis.conf
只允许本机客户端连接
使用保护模式
bind 127.0.0.1
......
protected-mode yes
修改:
1、# bind 127.0.0.1
2、 protected-mode no
或者
bind 192.168.8.159 //指定IP访问
bind 0.0.0.0 //任意IP都能访问
3、启动redis
nohup redis-server &
四、安装FastDFS
在CentOS安装软件的时候,可能缺少一部分支持库,而报错。这里首先安装系统常用的支持库。那么在安装的时候就会减少很多的错误的出现。
# yum install -y gcc gdb strace gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs patch e2fsprogs-devel krb5-devel libidn libidn-devel openldap-devel nss_ldap openldap-clients openldap-servers libevent-devel libevent uuid-devel uuid mysql-devel
1、上传FastDFS
2、安装FastDFS
tar -zxvf FastDFS_4.06.tar.gz
mv FastDFS /usr/local/fastDFS
vim make.sh
去掉注释
WITH_LINUX_SERVICE=1
./make.sh
./make.sh install
3、配置tracker
(1)创建与配置tracker数据目录
mkdir -p /data0/fastdfs/tracker
vim /etc/fdfs/tracker.conf
base_path=/data0/fastdfs/tracker
(2)启动tracker
service fdfs_trackerd start
4、配置storage
(1)创建与配置storage目录
mkdir -p /data0/fastdfs/storage/storage0
vim /etc/fdfs/storage.conf
http.server_port=80
group_name=group1
base_path=/data0/fastdfs
store_path0=/data0/fastdfs/storage/storage0
tracker_server=127.0.0.1:22122
(2)启动storage
service fdfs_storaged start
出现问题:127.0.0.1:22122 无效
解决问题:更改为静态IP 192.168.225.105:22122
查看是否启动
-
安装Nginx
1、安装pcre-8.12.tar.gz
cd /usr/local/src/nginx
tar zxvf pcre-8.12.tar.gz
cd pcre-8.12
./configure
make && make install
2、安装Nginx
(1) 解压fastdfs-nginx-module_v1.15.tar.gz
cd /usr/local/src/nginx
tar zxvf fastdfs-nginx-module_v1.15.tar.gz
(2) 添加用户组、创建日志目录、解压nginx-1.5.0.tar.gz
groupadd www 添加www组
useradd -g www www -s /bin/false #创建nginx运行账户www并加入到www组,不允许www用户直接登录系统
mkdir /data0/logs/nginx
chown www:www /data0/logs/nginx -R
cd /usr/local/src/nginx
tar zxvf nginx-1.5.0.tar.gz
cd nginx-1.5.0
1、配置、编译、安装
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --add-module=/usr/local/src/nginx/fastdfs-nginx-module/src
make && make install
./nginx –t 检查安装是否成功
3、配置mod_fastdfs.conf
cp /usr/local/src/nginx/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
base_path=/data0/fastdfs
tracker_server=192.168.225.105:22122
group_name=group1
url_have_group_name = true
store_path0=/data0/fastdfs/storage/storage0
4、配置nginx.conf
vim /usr/local/nginx/conf/nginx.conf
location /group1/M00 {
root /data0/fastdfs/storage/storage0/data;
ngx_fastdfs_module;
}
5、启动Nginx
cd /usr/local/nginx/sbin/
./nginx
6、测试
(1)配置client.conf
vim /etc/fdfs/client.conf
base_path=/tmp
tracker_server=192.168.225.105:22122
http.tracker_server_port=80
(2)上传
/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /data/test/test1.txt
所有进程