1、上次文章说到怎么安装nginx,但是并没有开启ssl模块,这次给大家开启nginx ssl模块安装教程
2、重新下载nginx源码
3、解压
tar -zxvf nginx-1.17.3.tar.gz
cd nginx-1.17.3
4、安装依赖库(如果第一次安装则需要安装一下)
sudo apt-get install libpcre3-dev aptitude libssl-dev
sudo apt-get install openssl
sudo apt-get install libssl-dev
5、编译
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module
成功会输出:
Configuration summary
+ using system PCRE library
.....
make
make[1]: Leaving directory '/root/nginx-1.17.3' 成功
6、安装,特别重要一步
先备份旧的程序(以前安装过的)
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
然后把新的nginx覆盖到旧的上面,
cp objs/nginx /usr/local/nginx/sbin/nginx
7、配置nginx https
server {
listen 80;
listen 443 ssl;
root /var/www/;
server_name localhost;
ssl_certificate 证书文件.crt;
ssl_certificate_key 证书文件.key;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
8、开启https
killall nginx
nginx