编译安装 nginx -1.14.2

1 ) 下载nginx-1.14.2 源码包:

  1. wget http://nginx.org/download/nginx-1.14.2.tar.gz

2 ) 编译安装 nginx:

  1. ### 1 ) 安装nginx 编译的依赖包(基本需要这3类的devel包,其他缺少的包自行解决报错):
  2. yum install pcre pcre-devel openssl openssl-devel zlib zlib-devel -y
  3. ### 2 ) 解压并安装nginx(注意定制的安装路径根据自己的需求自行更改 ):
  4. tar -zxvf nginx-1.14.2.tar.gz && cd nginx-1.14.2/
  5. ### 3 ) 编译安装nginx:
  6. ./configure --prefix=/data/nginx --http-client-body-temp-path=/data/nginx/cache/nginx/client_temp --http-proxy-temp-path=/data/nginx/cache/nginx/proxy_temp --http-fastcgi-temp-path=/data/nginx/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/data/nginx/cache/nginx/uwsgi_temp --http-scgi-temp-path=/data/nginx/cache/nginx/scgi_temp --user=fmw --group=fmw --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-pcre --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
  7. make && make install
  8. ### 4 ) 添加环境变量到系统:
  9. vim /etc/profile.d/nginx.sh
  10. PATH=$PATH:/data/nginx/bin/:/data/nginx/sbin
  11. export PATH
  12. source /etc/profile

3 ) 添加启动脚本(centos 7 ):

  1. ### 3.1 编写nginx启动脚本:
  2. [root@localhost ~]# vim /lib/systemd/system/nginx.service
  3. [Unit]
  4. Description=nginx
  5. After=network.target
  6. [Service]
  7. Type=forking
  8. ExecStart=/data/nginx/sbin/nginx
  9. ExecReload=/data/nginx/sbin/nginx -s reload
  10. ExecStop=/data/nginx/sbin/nginx -s quit
  11. PrivateTmp=true
  12. #EnvironmentFile=/etc/sysconfig/rdisc
  13. #ExecStart=/sbin/rdisc $RDISCOPTS
  14. [Install]
  15. WantedBy=multi-user.target
  16. ### 3.2 添加开启启动:
  17. systemctl enable nginx
  18. ### 3.3 查看nginx服务状态:
  19. systemctl start nginx
  20. systemctl status nginx

4 ) nginx 主要配置文件:

  1. grep -vE '^#|^$|^ #' nginx.conf
  2. user fmw fmw; # 运行nginx的用户组和用户.
  3. worker_processes auto; # 使用的CPU内核.
  4. error_log logs/error.log notice; # nginx 错误日志的存放路径和日志级别.
  5. pid logs/nginx.pid; # PID 路径.
  6. events {
  7. use epoll; # 使用的网络模型select,epoll,
  8. worker_connections 65535;
  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. server {
  23. listen 80;
  24. server_name www.188faka.com;
  25. #charset koi8-r;
  26. #access_log logs/host.access.log main;
  27. location / {
  28. root html;
  29. index index.php index.html index.htm;
  30. }
  31. error_page 404 /404/404.html;
  32. error_page 500 502 503 504 /50x.html;
  33. location = /50x.html {
  34. root html;
  35. }
  36. location ~ \.php$ {
  37. root html;
  38. fastcgi_pass 127.0.0.1:9000;
  39. fastcgi_index index.php;
  40. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  41. include fastcgi_params;
  42. }
  43. location ~ /\.ht {
  44. deny all;
  45. }
  46. }
  47. server {
  48. listen 443 ssl;
  49. server_name www.188faka.com;
  50. ssl_certificate /data/nginx/conf/188kafa_ssl/188faka.crt;
  51. ssl_certificate_key /data/nginx/conf/188kafa_ssl/188faka.key;
  52. ssl_session_cache shared:SSL:1m;
  53. ssl_session_timeout 5m;
  54. ssl_ciphers HIGH:!aNULL:!MD5;
  55. ssl_prefer_server_ciphers on;
  56. location / {
  57. root html;
  58. index index.php index.html index.htm;
  59. }
  60. error_page 404 /404/404.html;
  61. error_page 500 502 503 504 /50x.html;
  62. location = /50x.html {
  63. root html;
  64. }
  65. location ~ \.php$ {
  66. root html;
  67. fastcgi_pass 127.0.0.1:9000;
  68. fastcgi_index index.php;
  69. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  70. include fastcgi_params;
  71. }
  72. }
  73. }

编译安装 nginx -1.14.2的更多相关文章

  1. Centos7 编译安装 Nginx Mariadb Asp.net Core2 (实测 笔记 Centos 7.3 + Openssl 1.1.0h + Mariadb 10.3.7 + Nginx 1.14.0 + Asp.net. Core 2 )

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...

  2. ubuntu 14.04 编译安装 nginx

    下载源码包 nginx 地址:http://nginx.org/en/download.html  下载nginx 1.4.7 编译前先安装两个包: 直接编译安装会碰到缺少pcre等问题,这时候只要到 ...

  3. centos系统编译安装nginx+php环境另加独立mysql教程

    以前看过的安装nginx+php环境都带了mysql数据库了,这个是因为很多站长都是nginx+php+mysql都在同一台服务器了,那么今天我们是单独处理了,一个是nginx+php环境,然后mys ...

  4. Centos7 编译安装 Nginx PHP Mariadb Memcached 扩展 ZendOpcache扩展 (实测 笔记 Centos 7.3 + Mariadb 10.1.20 + Nginx 1.10.2 + PHP 7.1.0 + Laravel 5.3 )

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...

  5. CentOS7 编译安装 Nginx (实测 笔记 Centos 7.0 + nginx 1.6.2)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  6. ubuntu 12.04 编译安装 nginx

    下载源码包 nginx 地址:http://nginx.org/en/download.html 编译前先安装两个包: 直接编译安装会碰到缺少pcre等问题,这时候只要到再安装两个包就ok sudo ...

  7. Centos7 编译安装 Nginx PHP Mariadb Memcached 扩展 ZendOpcache扩展 (实测 笔记 Centos 7.3 + Openssl 1.1.0e + Mariadb 10.1.22 + Nginx 1.12.0 + PHP 7.1.4 + Laravel 5.4 )

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...

  8. Centos7 编译安装 Nginx PHP Mariadb Memcache扩展 ZendOpcache扩展 (实测 笔记 Centos 7.0 + Mariadb 10.1.9 + Nginx 1.9.9 + PHP 5.5.30)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1503-01.iso 安装步骤: 1.准备 1.1 ...

  9. Centos7 编译安装 Nginx、MariaDB、PHP

    前言 本文主要大致介绍CentOS 7下编译安装Nginx.MariaDB.PHP.面向有Linux基础且爱好钻研的朋友.技艺不精,疏漏再所难免,还望指正. 环境简介: 系统: CentOS 7,最小 ...

随机推荐

  1. CSP-S 2019 Emiya 家今天的饭

    64 pts 类似 乌龟棋 的思想,由于 \(64pts\) 的 \(m <= 3\), 非常小. 我们可以设一个 \(dp\),建立 \(m\) 个维度存下每种物品选了几次: \(f[i][A ...

  2. 【译】为什么Rust中的BTreeMap没有with_capacity()方法?

    原文标题:Why doesn't Rust's BTreeMap have a with_capacity() method? 原文链接:https://www.nicolas-hahn.com/20 ...

  3. Unity2D 人物移动切换人物图片

      勾选Constraints_freeze Rotation_z轴锁定,防止碰撞偏移.        public float moveSpeed = 3f;//定义移动速度        priv ...

  4. Fabric 配置 order节点问题

    问题描述: Error: failed to create deliver client: orderer client failed to connect to orderer.example.co ...

  5. python 安装相关

    一.安装python 1.官网下载python 1.1 可下载绿色版 2.2 也可下载安装版,安装时可自动安装pip 和 自动配置环境变量 2.手动配置环境变量,我的电脑>属性>高级> ...

  6. 最详细10招Spark数据倾斜调优

    最详细10招Spark数据倾斜调优 数据量大并不可怕,可怕的是数据倾斜 . 数据倾斜发生的现象 绝大多数 task 执行得都非常快,但个别 task 执行极慢. 数据倾斜发生的原理 在进行 shuff ...

  7. 初识SylixOs

    SylixOS 概述 SylixOS 是一款大型嵌入式实时操作系统,诞生于 2006 年,起初它只是一个小型多任务调度器,经过多年开发,SylixOS 目前已经成为一个功能完善.性能卓越.可靠稳定的嵌 ...

  8. RabbitMq基本概念理解

    RabbitMQ的基本概念 RabbitMQ github项目地址 RabbitMQ 2007年发布,是一个在AMQP(高级消息队列协议)基础上完成的,可复用的企业消息系统,是当前最主流的 消息中间件 ...

  9. 爬取并分析一下B站的最热视频排行榜,看看大家都喜欢看什么视频

    前言 现在大家的生活中,已经越来越离不开B站了,2020年的第一季度,B站月活跃用户达到了1.72亿,日活跃用户也已经突破了5000万个用户.源源不断的流量让B站的up主们也是粉丝数目不断暴涨,百万粉 ...

  10. 【剑指offer】01 二维数组中的查找

    题目地址:二维数组中的查找 题目描述                                    在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照 ...