【Linux環境配置】Linux 安裝 Nginx 並配置 https 訪問

原文地址

Linux 配置 Nginx https 訪問

安裝 nginx時

make之前需要在 nginx 解壓目錄下執行:

./configure --with-http_ssl_module

使支持 https,然後再安裝。

已安裝 nginx

在 nginx 解壓目錄下執行

./configure --with-http_ssl_module

然後將解壓目錄中 ngxin 執行文件替換安裝目錄下的 nginx 執行文件:

cp objs/nginx /usr/local/nginx/sbin/nginx
注:

當執行上面語句,出現

./configure: error: SSL modules require the OpenSSL library.

需要安裝以下依賴:

yum -y install openssl openssl-devel

重新執行

./configure --with-http_ssl_module

Linux 安裝 Nginx

1. 安裝依賴

yum install gcc
yum install pcre-devel
yum install zlib zlib-devel
yum install openssl openssl-devel

一鍵安裝上面四個依賴:

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

2. 下載nginx的tar包

創建一個文件夾

cd /usr/local
mkdir nginx
cd nginx

下載tar包

wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.g

3. 安裝nginx

進入nginx目錄

cd /usr/local/nginx

執行命令

./configure --with-http_ssl_module

執行make命令

make

執行make install命令

make install
附:
  • nginx 以指定配置文件啓動
/xxx/sbin/nginx -c /configPath
  • nginx 設置文件上傳大小限制client_max_body_size
server {
    listen       80;
    server_name  localhost;
    client_max_body_size 10M;
    
    ...
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章