文章目录
-
- Yum方式安装Nginx整合FastDFS&问题解决——stat /etc/fdfs/mod_fastdfs.conf fail,error info: Permission denied
-
-
- 1.Yum方式安装Nginx并整合FastDFS
- 2.Permission denied问题解决
-
Yum方式安装Nginx整合FastDFS&问题解决——stat /etc/fdfs/mod_fastdfs.conf fail,error info: Permission denied
FasDFS完整搭建参考前文——一步步搭建FastDFS服务器&三种方式整合FastDFS和Nginx&依赖_错误解决
1.Yum方式安装Nginx并整合FastDFS
-
直接通过yum安装Nginx
yum install nginx
-
service nginx start
若发现启动失败-
cd /etc/nginx/conf.d
-
修改default.conf
vi default.conf
#将第二行注释 server { listen 80 default_server;#listen [::]:80 default_server;#注释server_name localhost;#修改root /usr/share/nginx/html;#...省略内容 }
-
-
再次启动nginx
service nginx start
查看启动状态service nginx status
-
访问(可能依旧访问不了,解决参考下文)
wget localhost
-
查看yum安装的nginx版本
#查看 whereis nginx #查看版本信息 /usr/sbin/nginx -V #以下都是版本信息 nginx version: nginx/1.10.3 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=' -Wl,-E'
-
准备相应版本的nginx Nginx所有版本下载地址
-
键入命令上传
rz
选择nginx-1.10.3.tar.gz
到 home目录- 或者直接下载
wget http://nginx.org/download/nginx-1.10.3.tar.gz
- 或者直接下载
-
解压
tar -zxvf nginx-1.10.3.tar.gz
-
准备 fastdfs-nginx-module 模块 fastdfs-nginx-module官方
-
在线下载
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz
-
解压(建议自己从git上下载最新版本的)
unzip fastdfs-nginx-module-master.zip
-
-
将解压的目录都放到到 /usr文件夹(为了确保路径的安全,只要不带中文或&之类的就行)
mv fastdfs-nginx-module-master nginx-1.10.3 /usr/
-
安装依赖的库(缺什么安什么)
-
PCRE
yum -y install pcre-devel
oryum -y install pcre pcre-devel
-
SSL
yum -y install openssl openssl-devel
-
gcc-c++
yum -y install gcc-c++ autoconf automake
-
zlib
yum install -y zlib-devel
-
libxml2
yum -y install libxml2 libxml2-dev yum -y install libxslt-devel
-
gd-devel(GD library)
yum -y install gd-devel
-
ExtUtils
yum -y install perl-devel perl-ExtUtils-Embed
-
GeoIP
yum -y install GeoIP GeoIP-devel GeoIP-data
-
-
进入目录
cd /usr/nginx-1.10.3/
-
配置Nginx的configure ,加载fastdfs-nginx-module模块
# --prefix=/usr/share/nginx代表安装目录,这里需要和yum安装的nginx相同 # 需要加上原先已有的内容 # --add-module=···表示添加的模块,这里就是fastdfs-nginx-module模块 ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=' -Wl,-E' --add-module=/usr/fastdfs-nginx-module-master/src
-
可能会报的错误
#错误 /usr/include/fastdfs/fdfs_define.h:15:27: fatal error: common_define.h: No such file or directory #解决 cd /usr/fastdfs-nginx-module-master cp src/config src/config.bak vi src/config #修改以下内容 ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/" CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
-
-
执行编译
make
注意:不要执行 make install -
替换nginx二进制文件
-
先关闭nginx
service nginx stop
-
备份
cp /usr/sbin/nginx /usr/sbin/nginx.bak
-
覆盖替换
cp ./objs/nginx /usr/sbin/nginx
-
查看nginx版本
/usr/sbin/nginx -V
-
启动/重启
service nginx start
orservice nginx restart
-
查看nginx进程是否有2个
ps -ef | grep nginx
-
-
重启所有服务
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart#重启tracker /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart#重启storage netstat -apn|grep fdfs#查看端口 /usr/bin/fdfs_monitor /etc/fdfs/storage.conf#查看启动状态 service nginx restart #重启nginx netstat -apn | grep nginx#查看端口 ps -ef | grep nginx#查看进程
-
2.Permission denied问题解决
PS:先确保所有防火墙/安全组策略/配置文件 都是正确设置!
-
查看日志
cd /var/log/nginx/
cat error.log
传统方式安装的话cat /usr/local/nginx/logs/error.log
-
发现错误日志显示Permission denied
ERROR - file: shared_func.c, line: 1073, stat /etc/fdfs/mod_fastdfs.conf fail, errno: 13, error info: Permission denied ERROR - file: /usr/fastdfs-nginx-module-master/src/common.c, line: 163, load conf file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 13
-
打开nginx配置文件
vi /etc/nginx/nginx.conf
传统方式vi /usr/local/nginx/conf/nginx.conf
-
在开头第一行修改
#原先 ##yum安装的情况user nginx; ##传统方式安装的情况#user nobody;#修改成 user root;
:wq
保存 -
重启nginx
yum方式
service nginx restart
传统方式/usr/local/nginx/sbin/nginx -s reload
-
查看进程
ps -ef | grep nginx
,如果是有两个nginx的相关进程,就没问题了。root 31503 1 0 16:49 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf root 31505 31503 0 16:49 ? 00:00:00 nginx: worker process