• Fast——Nginx


    安装

    安装详情查看 

    链接:https://pan.baidu.com/s/1lcO7OO-Lntz63NeCmOa3yg 
    提取码:2015

    问题

    1.

    ./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 

     原因依赖不完整:

    1. ## pcre-devel 环境
    2. [root@localhost nginx-1.15.2]# yum install -y pcre pcre-devel
    3. ## zlib-devel 环境
    4. [root@localhost nginx-1.15.2]# yum install -y zlib zlib-devel
    5. ## openssl-devel 环境
    6. [root@localhost nginx-1.15.2]# yum install -y openssl openssl-devel

    2.

    /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删除(修改保存路径)

    1. HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
    2. NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
    3. ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
    4. CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
    5. CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"
    6. 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()

    解决:

    换个端口

     4.

    nginx: [emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or director)

     配置文件里没设置nginx.pid

    解决(完整配置在下面)

    pid        /usr/local/nginx/logs/nginx.pid;

     5.

    在执行./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配置图片代理服务

    1. #图片服务
    2. upstream img_server_pool{
    3. #server 192.168.101.64:80 weight=10;
    4. server 192.168.101.65:80 weight=10;
    5. }
    6. #学成网图片服务
    7. server {
    8. listen 80;
    9. server_name img.gaoxuecheng.com;
    10. #个人中心
    11. location /group1 {
    12. proxy_pass http://img_server_pool;
    13. }
    14. location /group2 {
    15. proxy_pass http://img_server_pool;
    16. }
    17. }

     host文件:127.0.0.1 img.gaoxuecheng.com

    启动 

    1. 启动tracker/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
    2. 启动storage/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
    3. 启动storage上的nginx
       cd 
      /usr/local/nginx/sbin
      ./nginx ‐c /usr/local/nginx/conf/nginx‐fdfs.conf
    4. 启动window图片虚拟主机 nginx

    相关命令 

    1. 查看使用80端口的服务
    2. netstat -tunlp |grep 80
    3. 查看fdfs服务
    4. ps aux|grep fdfs
    5. 杀死所有nginx服务
    6. killall -9 nginx
    7. 刷新DNS解析缓存
    8. ipconfig /flushdns
    9. 重启nginx(window)
    10. .\nginx.exe -s reload

     完整配置

    nginx‐fdfs.conf

    1. user nobody;
    2. worker_processes 1;
    3. #error_log logs/error.log;
    4. #error_log logs/error.log notice;
    5. #error_log logs/error.log info;
    6. #不写此句, 重启虚拟机后再启动Nginx时会报错:nginx: [emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory))
    7. pid /usr/local/nginx/logs/nginx.pid;
    8. events {
    9. worker_connections 1024;
    10. }
    11. http {
    12. include mime.types;
    13. default_type application/octet-stream;
    14. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    15. # '$status $body_bytes_sent "$http_referer" '
    16. # '"$http_user_agent" "$http_x_forwarded_for"';
    17. #access_log logs/access.log main;
    18. sendfile on;
    19. #tcp_nopush on;
    20. #keepalive_timeout 0;
    21. keepalive_timeout 65;
    22. #gzip on;
    23. upstream storage_server_group1{
    24. # 填写Storage所在的电脑ip, 即leapfrog-sub
    25. server 192.168.218.133:80 weight=10;
    26. #server 192.168.101.6:80 weight=10;
    27. }
    28. server {
    29. listen 80;
    30. server_name 192.168.218.133;
    31. location /group1/M00/{
    32. root /home/fastdfs/fdfs_storage/data;
    33. ngx_fastdfs_module;
    34. }
    35. }
    36. }

    mod_FastDFS.conf

    1. # connect timeout in seconds
    2. # default value is 30s
    3. connect_timeout=2
    4. # network recv and send timeout in seconds
    5. # default value is 30s
    6. network_timeout=30
    7. # the base path to store log files
    8. base_path=/home/fastdfs
    9. # if load FastDFS parameters from tracker server
    10. # since V1.12
    11. # default value is false
    12. load_fdfs_parameters_from_tracker=true
    13. # storage sync file max delay seconds
    14. # same as tracker.conf
    15. # valid only when load_fdfs_parameters_from_tracker is false
    16. # since V1.12
    17. # default value is 86400 seconds (one day)
    18. storage_sync_file_max_delay = 86400
    19. # if use storage ID instead of IP address
    20. # same as tracker.conf
    21. # valid only when load_fdfs_parameters_from_tracker is false
    22. # default value is false
    23. # since V1.13
    24. use_storage_id = false
    25. # specify storage ids filename, can use relative or absolute path
    26. # same as tracker.conf
    27. # valid only when load_fdfs_parameters_from_tracker is false
    28. storage_ids_filename = storage_ids.conf
    29. # FastDFS tracker_server can ocur more than once, and tracker_server format is
    30. # "host:port", host can be hostname or ip address
    31. # valid only when load_fdfs_parameters_from_tracker is true
    32. tracker_server=192.168.218.133:22122
    33. # the port of the local storage server
    34. # the default value is 23000
    35. storage_server_port=23000
    36. # the group name of the local storage server
    37. group_name=group1
    38. # if the url / uri including the group name
    39. # set to false when uri like /M00/00/00/xxx
    40. # set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
    41. # default value is false
    42. url_have_group_name = true
    43. # path(disk or mount point) count, default value is 1
    44. # must same as storage.conf
    45. store_path_count=1
    46. # store_path#, based 0, if store_path0 not exists, it's value is base_path
    47. # the paths must be exist
    48. # must same as storage.conf
    49. store_path0=/home/fastdfs/fdfs_storage
    50. #store_path1=/home/yuqing/fastdfs1
    51. # standard log level as syslog, case insensitive, value list:
    52. ### emerg for emergency
    53. ### alert
    54. ### crit for critical
    55. ### error
    56. ### warn for warning
    57. ### notice
    58. ### info
    59. ### debug
    60. log_level=info
    61. # set the log filename, such as /usr/local/apache2/logs/mod_fastdfs.log
    62. # empty for output to stderr (apache and nginx error_log file)
    63. log_filename=
    64. # response mode when the file not exist in the local file system
    65. ## proxy: get the content from other storage server, then send to client
    66. ## redirect: redirect to the original storage server (HTTP Header is Location)
    67. response_mode=proxy
    68. # the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a
    69. # multi aliases split by comma. empty value means auto set by OS type
    70. # this paramter used to get all ip address of the local host
    71. # default values is empty
    72. if_alias_prefix=
    73. # use "#include" directive to include HTTP config file
    74. # NOTE: #include is an include directive, do NOT remove the # before include
    75. #include http.conf
    76. # if support flv
    77. # default value is false
    78. # since v1.15
    79. flv_support = true
    80. # flv file extension name
    81. # default value is flv
    82. # since v1.15
    83. flv_extension = flv
    84. # set the group count
    85. # set to none zero to support multi-group
    86. # set to 0 for single group only
    87. # groups settings section as [group1], [group2], ..., [groupN]
    88. # default value is 0
    89. # since v1.14
    90. group_count = 0
    91. # group settings for group #1
    92. # since v1.14
    93. # when support multi-group, uncomment following section
    94. #[group1]
    95. #group_name=group1
    96. #storage_server_port=23000
    97. #store_path_count=2
    98. #store_path0=/home/yuqing/fastdfs
    99. #store_path1=/home/yuqing/fastdfs1
    100. # group settings for group #2
    101. # since v1.14
    102. # when support multi-group, uncomment following section
    103. #[group1]
    104. #group_name=group1
    105. #storage_server_port=23000
    106. #store_path_count=2
    107. #store_path0=/home/yuqing/fastdfs
    108. #store_path1=/home/yuqing/fastdfs1

     /usr/local/FastDFS-nginx-module/src/config

    1. HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
    2. NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
    3. ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
    4. CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
    5. CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"
    6. CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"

    window下的nginx.conf

    1. #user nobody;
    2. worker_processes 1;
    3. #error_log logs/error.log;
    4. #error_log logs/error.log notice;
    5. #error_log logs/error.log info;
    6. #pid logs/nginx.pid;
    7. events {
    8. worker_connections 1024;
    9. }
    10. http {
    11. include mime.types;
    12. default_type application/octet-stream;
    13. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    14. # '$status $body_bytes_sent "$http_referer" '
    15. # '"$http_user_agent" "$http_x_forwarded_for"';
    16. #access_log logs/access.log main;
    17. sendfile on;
    18. #tcp_nopush on;
    19. #keepalive_timeout 0;
    20. keepalive_timeout 65;
    21. #gzip on;
    22. #cms 页面预览
    23. upstream cms_server_pool{
    24. server 127.0.0.1:31001 weight=10;
    25. }
    26. #图片服务(配置了group1下的storage服务器地址)
    27. upstream img_server_pool{
    28. #server 192.168.101.64:80 weight=10;
    29. server 192.168.218.133:80 weight=10;
    30. }
    31. server{
    32. listen 80;
    33. server_name www.gaoxuecheng.com;
    34. ssi on;
    35. ssi_silent_errors on;
    36. location / {
    37. alias D:/WebStorm_soft/xc-ui-pc-static-portal/;
    38. index index.html;
    39. }
    40. #页面预览
    41. location /cms/preview/{
    42. proxy_pass http://cms_server_pool/cms/preview/;
    43. }
    44. }
    45. #学成网图片服务
    46. server {
    47. listen 80;
    48. server_name img.gaoxuecheng.com;
    49. #个人中心
    50. location /group1/ {
    51. proxy_pass http://img_server_pool;
    52. }
    53. #location /group2 {
    54. #proxy_pass http://img_server_pool;
    55. #}
    56. }
    57. # another virtual host using mix of IP-, name-, and port-based configuration
    58. #
    59. #server {
    60. # listen 8000;
    61. # listen somename:8080;
    62. # server_name somename alias another.alias;
    63. # location / {
    64. # root html;
    65. # index index.html index.htm;
    66. # }
    67. #}
    68. # HTTPS server
    69. #
    70. #server {
    71. # listen 443 ssl;
    72. # server_name localhost;
    73. # ssl_certificate cert.pem;
    74. # ssl_certificate_key cert.key;
    75. # ssl_session_cache shared:SSL:1m;
    76. # ssl_session_timeout 5m;
    77. # ssl_ciphers HIGH:!aNULL:!MD5;
    78. # ssl_prefer_server_ciphers on;
    79. # location / {
    80. # root html;
    81. # index index.html index.htm;
    82. # }
    83. #}
    84. }

  • 相关阅读:
    【MySQL索引与优化篇】InnoDB数据存储结构
    图像转换多样化图像生成在“分子优化”中的思考和Paper
    文本攻击textattack->openattack
    互换性与技术测量试题库
    相控阵雷达天线不同阵列的特性matlab仿真分析——有限扫描阵,稀疏阵,多波束阵,共形阵
    Spring Boot 常见面试题
    第四章-并发与同步思考题
    遗传算法 - 函数最优解计算
    Enhancing Quality for HEVC Compressed Videos
    pytest-fixture执行顺序
  • 原文地址:https://blog.csdn.net/qq_51497041/article/details/127803491