NGINX配合FASTDFS使用的安装与配置及编译遇到错误:cc1: all warnings being treated as errors
安装所需要的文件可在这里下载:https://github.com/Lincoln77/fdfs-with-nginx
- 解压缩nginx-1.8.1.tar.gz
- 解压缩fastdfs-nginx-module-master.zip
- 安装nginx的依赖包
sudo apt-get install build-essential
sudo apt-get install libtool
sudo apt-get install openssl
sudo apt-get install libssl-dev
- 进入nginx-1.8.1目录中
sudo ./configure --prefix=/usr/local/nginx/ --add-module='fastdfs-nginx-module-master解压后的目录的绝对路径'/src
- 编译
sudo make
sudo make install
在第5步可能会编译失败,错误如下
cc1: all warnings being treated as errors
objs/Makefile:440: recipe for target 'objs/src/core/ngx_murmurhash.o' failed
make[1]: *** [objs/src/core/ngx_murmurhash.o] Error 1
make[1]: 离开目录“/home/nginx/nginx-1.8.1”
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2
解决办法:
在对应的makefile文件夹中(如本文中在 /nginx-1.8.1/objs/Makefile)
找到 -Werrori
并删除 在重新make即可
---> /Werror <---
在vim模式下快速定位
-Werror 项视警告为错误;出现任何警告即放弃编译.
sudo cp 'fastdfs-nginx-module-master解压后的目录'/src/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf
sudo vim /etc/fdfs/mod_fastdfs.conf
修改内容:
connect_timeout=10
tracker_server=自己ubuntu虚拟机的ip地址:22122
url_have_group_name=true
store_path0=/home/python/fastdfs/storage
sudo cp '解压缩的fastdfs-master目录'/conf/http.conf /etc/fdfs/http.conf
sudo cp '解压缩的fastdfs-master目录'/conf/mime.types /etc/fdfs/mime.types
sudo vim /usr/local/nginx/conf/nginx.conf
在http部分中添加配置信息如下:
server {
listen 8888;
server_name localhost;
location ~/group[0-9]/ {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
- 启动nginx
sudo /usr/local/nginx/sbin/nginx