版权声明:本文为wcuu原创文章。 https://blog.csdn.net/wcuuchina/article/details/86551158
首先生成证书 或者 购买证书
这里我们使用阿里云的证书,可以免费使用一年
配置方法的机票:
https://mp.csdn.net/postedit/86541664
nginx 搭建:
下载nginx
wget http://nginx.org/download/nginx-1.12.0.tar.gz
解压 安装
chmod u+x nginx-1.12.0.tar.gz
tar -zxvf nginx-1.12.0.tar.gz
cp -r nginx-1.12.0 /usr/local/nginx-1.12.0
rm -rf nginx-1.12.0
yum install pcre*
yum install -y zlib-devel
yum -y install openssl openssl-devel
./configure --with-http_ssl_module
make
make install
nginx文件在当前文件夹的 objs文件夹下。
配置文件在 conf文件夹下。
将阿里云的配置文件添加的 nginx.conf 配置文件中
server {
listen 443;
server_name localhost;
ssl on;
root html;
index index.html index.htm;
ssl_certificate cert/1753957_openglobal.cn.pem;
ssl_certificate_key cert/1753957_openglobal.cn.key;
ssl_session_timeout 5m;
ssl_ciphers xxxxxxxxxxxxxx;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
server_name 可以配置用户域名
然后 到objs文件夹下运行命令
./nginx -t
./nginx -s reload
由于免费证书,有的浏览器是不认得。
错误信息:
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
配置完毕。