安装详情查看
链接:https://pan.baidu.com/s/1lcO7OO-Lntz63NeCmOa3yg
提取码:2015
./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with
原因依赖不完整:
- ## pcre-devel 环境
- [root@localhost nginx-1.15.2]# yum install -y pcre pcre-devel
- ## zlib-devel 环境
- [root@localhost nginx-1.15.2]# yum install -y zlib zlib-devel
- ## openssl-devel 环境
- [root@localhost nginx-1.15.2]# yum install -y openssl openssl-devel
/usr/local/fastdfs-nginx-module/src/common.c:21:25: 致命错误:fdfs_define.h:没有那个文件或目录
原因:
编译中断。
原因:编译安装nginx的fastdfs插件的头文件没有找到,由于编译nginx时候系统会到/usr/local /include,
而编译安装fastdfs-nginx-module时则默认保存在了/usr/include目录。
修复:ln -s /usr/include/fast* /usr/local/include/
解决:
将配置文件/usr/local/fastdfs-nginx-module/src/config中的local删除(修改保存路径)
- HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
- NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
- ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
- CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
- CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"
- CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
端口被占用
nginx: [emerg] still could not bind()
解决:
换个端口
nginx: [emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or director)
配置文件里没设置nginx.pid
解决(完整配置在下面)

pid /usr/local/nginx/logs/nginx.pid;
在执行./nginx ‐c /usr/local/nginx/conf/nginx‐fdfs.conf时,出现 ……optional -c错误时因为配置文件错误
按照下面完整配置文件配置即可
自己在配置文件中写的路径文件是否存在(注意文件名的大小写)
当mod_FastDFS.conf文件被修改时需要再此执行configure
不用管linux中的nginx.conf配置文件用不到()
安装tracker和storage
安装FastDFS-nginx-module
修改mod_FastDFS.conf内容
在linux中安装nginx,执行configure命令时,注意大小写
修改自己建的nginx-fdfs.conf文件
在window上的nginx配置图片代理服务
- #图片服务
- upstream img_server_pool{
- #server 192.168.101.64:80 weight=10;
- server 192.168.101.65:80 weight=10;
- }
-
- #学成网图片服务
- server {
- listen 80;
- server_name img.gaoxuecheng.com;
- #个人中心
- location /group1 {
- proxy_pass http://img_server_pool;
- }
- location /group2 {
- proxy_pass http://img_server_pool;
- }
- }
host文件:127.0.0.1 img.gaoxuecheng.com
启动
- 查看使用80端口的服务
- netstat -tunlp |grep 80
-
- 查看fdfs服务
- ps aux|grep fdfs
-
- 杀死所有nginx服务
- killall -9 nginx
-
- 刷新DNS解析缓存
- ipconfig /flushdns
-
- 重启nginx(window)
- .\nginx.exe -s reload
- user nobody;
- worker_processes 1;
-
- #error_log logs/error.log;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
-
- #不写此句, 重启虚拟机后再启动Nginx时会报错:nginx: [emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory))
- pid /usr/local/nginx/logs/nginx.pid;
-
-
- events {
- worker_connections 1024;
- }
-
-
- http {
- include mime.types;
- default_type application/octet-stream;
-
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
-
- #access_log logs/access.log main;
-
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
- #gzip on;
-
- upstream storage_server_group1{
- # 填写Storage所在的电脑ip, 即leapfrog-sub
- server 192.168.218.133:80 weight=10;
- #server 192.168.101.6:80 weight=10;
- }
-
- server {
- listen 80;
- server_name 192.168.218.133;
- location /group1/M00/{
- root /home/fastdfs/fdfs_storage/data;
- ngx_fastdfs_module;
- }
-
- }
- }
- # connect timeout in seconds
- # default value is 30s
- connect_timeout=2
-
- # network recv and send timeout in seconds
- # default value is 30s
- network_timeout=30
-
- # the base path to store log files
- base_path=/home/fastdfs
-
- # if load FastDFS parameters from tracker server
- # since V1.12
- # default value is false
- load_fdfs_parameters_from_tracker=true
-
- # storage sync file max delay seconds
- # same as tracker.conf
- # valid only when load_fdfs_parameters_from_tracker is false
- # since V1.12
- # default value is 86400 seconds (one day)
- storage_sync_file_max_delay = 86400
-
- # if use storage ID instead of IP address
- # same as tracker.conf
- # valid only when load_fdfs_parameters_from_tracker is false
- # default value is false
- # since V1.13
- use_storage_id = false
-
- # specify storage ids filename, can use relative or absolute path
- # same as tracker.conf
- # valid only when load_fdfs_parameters_from_tracker is false
- storage_ids_filename = storage_ids.conf
-
- # FastDFS tracker_server can ocur more than once, and tracker_server format is
- # "host:port", host can be hostname or ip address
- # valid only when load_fdfs_parameters_from_tracker is true
- tracker_server=192.168.218.133:22122
-
- # the port of the local storage server
- # the default value is 23000
- storage_server_port=23000
-
- # the group name of the local storage server
- group_name=group1
-
- # if the url / uri including the group name
- # set to false when uri like /M00/00/00/xxx
- # set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
- # default value is false
- url_have_group_name = true
-
- # path(disk or mount point) count, default value is 1
- # must same as storage.conf
- store_path_count=1
-
- # store_path#, based 0, if store_path0 not exists, it's value is base_path
- # the paths must be exist
- # must same as storage.conf
- store_path0=/home/fastdfs/fdfs_storage
- #store_path1=/home/yuqing/fastdfs1
- # standard log level as syslog, case insensitive, value list:
- ### emerg for emergency
- ### alert
- ### crit for critical
- ### error
- ### warn for warning
- ### notice
- ### info
- ### debug
- log_level=info
-
- # set the log filename, such as /usr/local/apache2/logs/mod_fastdfs.log
- # empty for output to stderr (apache and nginx error_log file)
- log_filename=
-
- # response mode when the file not exist in the local file system
- ## proxy: get the content from other storage server, then send to client
- ## redirect: redirect to the original storage server (HTTP Header is Location)
- response_mode=proxy
-
- # the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a
- # multi aliases split by comma. empty value means auto set by OS type
- # this paramter used to get all ip address of the local host
- # default values is empty
- if_alias_prefix=
-
- # use "#include" directive to include HTTP config file
- # NOTE: #include is an include directive, do NOT remove the # before include
- #include http.conf
-
- # if support flv
- # default value is false
- # since v1.15
- flv_support = true
-
- # flv file extension name
- # default value is flv
- # since v1.15
- flv_extension = flv
-
-
- # set the group count
- # set to none zero to support multi-group
- # set to 0 for single group only
- # groups settings section as [group1], [group2], ..., [groupN]
- # default value is 0
- # since v1.14
- group_count = 0
-
- # group settings for group #1
- # since v1.14
- # when support multi-group, uncomment following section
- #[group1]
- #group_name=group1
- #storage_server_port=23000
- #store_path_count=2
- #store_path0=/home/yuqing/fastdfs
- #store_path1=/home/yuqing/fastdfs1
-
- # group settings for group #2
- # since v1.14
- # when support multi-group, uncomment following section
- #[group1]
- #group_name=group1
- #storage_server_port=23000
- #store_path_count=2
- #store_path0=/home/yuqing/fastdfs
- #store_path1=/home/yuqing/fastdfs1
- HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
- NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
- ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
- CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
- CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"
- CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
-
- #user nobody;
- worker_processes 1;
-
- #error_log logs/error.log;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
-
- #pid logs/nginx.pid;
-
-
- events {
- worker_connections 1024;
- }
-
-
- http {
- include mime.types;
- default_type application/octet-stream;
-
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
-
- #access_log logs/access.log main;
-
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
-
- #gzip on;
- #cms 页面预览
- upstream cms_server_pool{
- server 127.0.0.1:31001 weight=10;
- }
-
- #图片服务(配置了group1下的storage服务器地址)
- upstream img_server_pool{
- #server 192.168.101.64:80 weight=10;
- server 192.168.218.133:80 weight=10;
- }
-
- server{
- listen 80;
- server_name www.gaoxuecheng.com;
- ssi on;
- ssi_silent_errors on;
- location / {
- alias D:/WebStorm_soft/xc-ui-pc-static-portal/;
- index index.html;
- }
- #页面预览
- location /cms/preview/{
- proxy_pass http://cms_server_pool/cms/preview/;
- }
- }
- #学成网图片服务
- server {
-
- listen 80;
- server_name img.gaoxuecheng.com;
-
- #个人中心
- location /group1/ {
- proxy_pass http://img_server_pool;
- }
-
- #location /group2 {
- #proxy_pass http://img_server_pool;
- #}
-
- }
-
-
-
- # another virtual host using mix of IP-, name-, and port-based configuration
- #
- #server {
- # listen 8000;
- # listen somename:8080;
- # server_name somename alias another.alias;
-
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
-
-
- # HTTPS server
- #
- #server {
- # listen 443 ssl;
- # server_name localhost;
-
- # ssl_certificate cert.pem;
- # ssl_certificate_key cert.key;
-
- # ssl_session_cache shared:SSL:1m;
- # ssl_session_timeout 5m;
-
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
-
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
-
- }