Linux ·

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

更多

参与评论