FastDFS安装、安装fastdfs-nginx-module插件、安装nginx、配置开机启动

----------------------------------FastDFS安装------------------------------------
一、安装FastDFS

0、克隆并修改
     端口号  vim /etc/sysconfig/network-scripts/ifcfg-ens33  
     更新     systemctl restart network
1、安装c语言环境
    yum -y install gcc
2、安装c函数库
    cd /usr/upload
    unzip libfastcommon-master.zip
    cd libfastcommon-master
    ./make.sh
    ./make.sh install
3、安装FastDFS
    cd /usr/upload
    tar -zxvf FastDFS_v5.08.tar.gz
    cd FastDFS
    ./make.sh
    ./make.sh install
4、配置并启动tracker服务
    cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
    vim /etc/fdfs/tracker.conf:
        base_path=/powershop/tracker
    mkdir -p /powershop/tracker
    service fdfs_trackerd start
    ps -ef | grep fdfs
    chkconfig fdfs_trackerd on
5、配置并启动storage服务
    cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
    vim /etc/fdfs/storage.conf:
        base_path=/powershop/storage                 # 日志文件存储根目录
        store_path0=/powershop/storage           # 文件存储目录
        tracker_server=192.168.204.131:22122       #  tracker服务器IP和端口
    mkdir -p  /powershop/storage
    service fdfs_storaged start
    ps -ef | grep fdfs
    chkconfig fdfs_storaged on

二、安装fastdfs-nginx-module插件

1、解压
   cd /usr/upload
   tar -zxvf fastdfs-nginx-module_v1.16.tar.gz

2、修改config
    cd fastdfs-nginx-module/src
    vim config:
        :%s+/usr/local/+/usr/+g

3、配置fastdfs-nginx-module与FastDFS的关联
    cp /usr/upload/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
    vim /etc/fdfs/mod_fastdfs.conf:
        connect_timeout=10                       # 客户端访问文件连接超时时长(单位:秒)
        tracker_server=192.168.204.131:22122    # tracker服务IP和端口
        url_have_group_name=true                # 访问链接前缀加上组名
        store_path0=/powershop/storage            # 文件存储路径
    cd /usr/upload/FastDFS/conf/
    cp http.conf mime.types /etc/fdfs/

三、安装nginx

1、安装nginx
    yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
    cd /usr/upload
    tar -zxvf nginx-1.10.0.tar.gz
    cd nginx-1.10.0
    ./configure --prefix=/usr/local/nginx --add-module=/usr/upload/fastdfs-nginx-module/src
    make && make install
2、配置并启动
    vim /usr/local/nginx/conf/nginx.conf:
        server {
            listen       80;
            server_name  image.powershop.com;

            # 监听域名中带有group的,交给FastDFS模块处理
            location ~/group([0-9])/ {
                ngx_fastdfs_module;
            }
        }
3、配置开机启动
    vim /lib/systemd/system/nginx.service:
        [Unit]
        Description=nginx
        After=network.target

        [Service]
        Type=forking
        ExecStart=/usr/local/nginx/sbin/nginx
        ExecReload=/usr/local/nginx/sbin/nginx -s reload
        ExecStop=/usr/local/nginx/sbin/nginx -s stop
        PrivateTmp=true

        [Install]
        WantedBy=multi-user.target
    systemctl daemon-reload        #重新加载服务配置
    systemctl start nginx.service  #启动服务
    systemctl status nginx.service #查看服务状态
    systemctl enable nginx.service #设置为开机启动
    systemctl stop nginx.service   #停止服务

你可能感兴趣的:(nginx,vim,linux)