首页 > 技术文章 > nginx安装ssl

liqing1009 2016-11-16 16:00 原文

http://wiki.nginx.org/Modules#Standard_HTTP_modules 这里面带有所有基本的模块,及需要额外增加的模块

1.安装带有ssl模块的 nginx

 

[html] view plain copy
 
  1. wget http://nginx.org/download/nginx-0.8.52.tar.gz  
  2. tar zxvf nginx-0.8.52.tar.gz  
  3. chown root:root nginx-0.8.52 -R  
  4. apt-get install libpcre3 libpcre3-dev  
  5. apt-get install openssl  
  6. apt-get install libssl-dev  
  7. ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module  --with-http_realip_module  
  8. make  
  9. make install  


 2.配置nginx 配置文件

[html] view plain copy
 
  1. ssl on;  
  2. ssl_certificate /etc/nginx/nginx_pas/*.crt;  
  3. ssl_certificate_key /etc/nginx/nginx_pas/*.key;  

 

启动nginx提示:error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory,意思是找不到libpcre.so.1这个模块,而导致启动失败。

[root@lee ~]# /usr/local/webserver/nginx/sbin/nginx
nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

经过搜索资料,发现部分linux系统存有的通病。要解决这个方法非常容易

如果是32位系统

[root@lee ~]#  ln -s /usr/local/lib/libpcre.so.1 /lib

如果是64位系统

[root@lee ~]#  ln -s /usr/local/lib/libpcre.so.1 /lib64

然后在启动nginx就OK了

[root@lee ~]# /usr/local/webserver/nginx/sbin/nginx

 



3. 配置nginx的conf ,所有都要求访问https
  [html] view plain copy

 
    1. location / {  
    2.              rewrite ^/(.*) https://*.com/$1 permanent ;  
    3.              #root   /var/www/nginx-default;  
    4.              #index  index.html index.htm;  
    5. }

推荐阅读