做网站需要多,做房源网站,黄岛区城市建设局网站,微小店网站建设比较好环境Centos7.6nginx-1.17.0下载官网#xff1a;http://nginx.org/download/nginx-1.17.0.tar.gz环境确认在安装nginx前首先要确认系统中是否安装gcc、pcre-devel、zlib-devel、openssl-devel检查是否安装过软件包yum list installed | grep xxx安装软件包yum -y install gcc p…环境Centos7.6nginx-1.17.0下载官网http://nginx.org/download/nginx-1.17.0.tar.gz环境确认在安装nginx前首先要确认系统中是否安装gcc、pcre-devel、zlib-devel、openssl-devel检查是否安装过软件包yum list installed | grep xxx安装软件包yum -y install gcc pcre-devel zlib-devel openssl openssl-devel上图为已安装安装将nginx-1.17.0.tar.gz上传至服务器并解压tar -xzvf nginx-1.17.0.tar.gz解压后如下所示nginx目录下编译安装nginx./configure --prefix/usr/local/nginx1.17.0 --conf-path/usr/local/nginx1.17.0/nginx.conf --with-http_stub_status_module --with-http_ssl_module--with-http_ssl_module配置nginx支持https协议访问不使用https可以不用添加该命令该命令编译nginx时将配置文件nginx.conf生成在nginx目录下因编译后出现错误采用这种方式详见后面错误记录因此nginx的配置文件不再是conf中的nginx.conf顺序执行makemake install编译makemake install测试是否安装成功./sbin/nginx -t启动nginx./sbin/nginx停止nginx./sbin/nginx -s stop重启nginx./sbin/nginx -s reload查看nginx进程ps -ef | grep nginx访问浏览器访问服务器IP(nginx默认端口为80)出现如下界面则证明成功配置HTTPS服务器上安装opensslopenssl-develyum install openssl openssl-devel创建证书存放目录mkdir /usr/local/nginx/conf/ssl创建服务器私钥openssl genrsa -des3 -out server.key 2048 #根据提示输入证书口令创建签名请求的证书(CSR)openssl req -new -key server.key -out server.csr #输入上面设置的口令根据提示输入相应的信息对key进行解密openssl rsa -in server.key -out server_nopasswd.key标记证书使用上述私钥和CSRopenssl x509 -req -days 365 -in server.csr -signkey server_nopasswd.key -out server.crtvim修改nginx配置文件加载ssl证书server { listen 443 ssl; server_name localhost; ssl_certificate /usr/local/nginx-1.17.0/conf/ssl/server.crt; ssl_certificate_key /usr/local/nginx-1.17.0/conf/ssl/server.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_protocols TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root html; index index.html index.htm; } }输入证书密码启动nginx浏览器访问测试https://服务器IP 端口443出现如下界面则成功错误记录nginx报错cp: conf/koi-win and /usr/local/nginx/conf/koi-win are the same file该错误为编译安装nginx时没有指定conf-path出现的出现问题的命令./configure --prefix/usr/local/nginx1.17.0 --with-http_stub_status_module --with-http_ssl_module将命令改为如下指定conf-path后正常./configure --prefix/usr/local/nginx1.17.0 --conf-path/usr/local/nginx1.17.0/nginx.conf --with-http_stub_status_module --with-http_ssl_module