nginx源码安装
下载
wget http://nginx.org/download/nginx-1.24.0.tar.gz
解压
tar -zxvf nginx-1.24.0.tar.gz
下载openssl
apt install openssl
安装nginx
cd nginx-1.24.0
sudo apt-get install libpcre3 libpcre3-dev
./configure --prefix=/home/nginx24 --with-http_ssl_module
编译
make install
查看是否安装成功
cd /home/nginx24/sbin
root@cvm-3kdmjix25i223:/home/nginx24/sbin# ./nginx -V
nginx version: nginx/1.24.0
built by gcc 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
built with OpenSSL 3.0.2 15 Mar 2022
TLS SNI support enabled
configure arguments: --prefix=/home/nginx24 --with-http_ssl_module
启动
root@cvm-3kdmjix25i223:/home/nginx24/sbin# ./nginx
访问
ip:80 查看是否成功
出现
./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl=<path> option.
-
For Ubuntu or Debian: Run
sudo apt-get install libssl-dev
to install the OpenSSL development package. -
For CentOS or Fedora: Run
sudo yum install openssl-devel
to install the OpenSSL development package. -
然后重新执行
./configure --prefix=/home/nginx24 --with-http_ssl_module
nginx配置ssl证书
1.先购买域名,然后申请ssl证书,下载ssl证书
2.配置DNS解析管理
3.将解压后的证书放入新创建的ssl文件夹下
root@cvm-3kdmjix25i223:/home/nginx24# mkdir ssl
root@cvm-3kdmjix25i223:/home/nginx24/sbin# cd /home/nginx24/conf/
root@cvm-3kdmjix25i223:/home/nginx24/conf# vim nginx.conf
修改nginx.conf文件
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;
}http {include mime.types;