CentOS 7.0 下源码编译安装 Nginx 1.8.0


系统版本 CentOS 7.0

Nginx版本 Nginx1.8.0

tar zxf nginx-1.8.0.tar.gz

cd nginx-1.8.0/

vim auto/cc/gcc 
    注释debug 可以减小安装后的大小
vim src/core/nginx.h
    隐藏nginx版本信息 
#解决软件包依赖性
yum install -y pcre-devle
yum install -y openssl-devel
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module                  
#编译
--with-http_ssl_module   开启HTTP SSL模块 支持https请求

make
make install

以下操作是给nginx一个安全认证的key,就可以开始使用

cd /etc/pki/tls/certs/
make nginx.pem      ##建立安全认证文件,在其中填写信息
mv nginx.pem /usr/local/nginx/conf/

编辑配置文件

vim /usr/local/lnmp/nginx/conf/nginx.conf

 server {
117         listen       443 ssl;
118         server_name  localhost;
119 
120         ssl_certificate       nginx.pem;
121         ssl_certificate_key   nginx.pem;
122 
123         ssl_session_cache    shared:SSL:1m;
124         ssl_session_timeout  5m;
125 
126         ssl_ciphers  HIGH:!aNULL:!MD5;
127         ssl_prefer_server_ciphers  on;
128 
129         location / {
130             root   html;
131             index  index.php index.html index.htm;
132         }
133     }

开启服务

nginx

更多Nginx相关教程见以下内容

CentOS 6.2实战部署Nginx+MySQL+PHP

Ubuntu 16.04下安装部署 Nginx+uWSGI+Django1.9.7 

搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程

CentOS 6.3下Nginx性能调优

CentOS 6.3下配置Nginx加载ngx_pagespeed模块

CentOS 6.4安装配置Nginx+Pcre+php-fpm

Nginx安装配置使用详细笔记

Nginx日志过滤 使用ngx_log_if不记录特定日志

Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里

本文永久更新链接地址

相关内容