MAC下 nginx搭建https服务器

来源:互联网 发布:男士洗面奶推荐 知乎 编辑:程序博客网 时间:2024/06/15 18:58

安装nginx

1. http://nginx.org/en/download.html下载http://nginx.org/download/nginx-1.2.0.tar.gz

2. tar -xf nginx-1.2.0.tar.gz

3. 进入解压目录  chmod a+rwx *

4. ./configure --without-http_rewrite_module --with-http_ssl_module

5. make && make install

6. sudo /usr/local/nginx/sbin/nginx

浏览器访问 localhost

确保机器上安装了openssl和openssl-devel

#yum install openssl#yum install openssl-devel

然后就是自己颁发证书给自己

#cd /usr/local/nginx/conf#openssl genrsa -des3 -out server.key 1024#openssl req -new -key server.key -out server.csr#openssl rsa -in server.key -out server_nopwd.key#openssl x509 -req -days 365 -in server.csr -signkey server_nopwd.key -out server.crt

至此证书已经生成完毕,下面就是配置nginx

server {    listen 443;    ssl on;    ssl_certificate  /usr/local/nginx/conf/server.crt;    ssl_certificate_key  /usr/local/nginx/conf/server_nopwd.key;}

然后重启nginx即可。


0 1
原创粉丝点击