Nginx安装及配置
Nginx安装
https://nginx.org/en/download.html
下载nginx
解压:tar –xzf nginx-1.10.3.tar.gz && cd nginx-1.10.3
配置:./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
编译安装 sudo make && sudo make install
启动:/usr/local/nginx/sbin/nginx
查看进程:ps –aux | grep nginx
验证 curl http:
- 如果安装时提示缺少
compiler cc
,需要安装gcc,可以从网址http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
下载以下包:
mpfr-3.1.1-4.el7.x86_64.rpm
libmpc-1.0.1-3.el7.x86_64.rpm
kernel-headers-3.10.0-123.el7.x86_64.rpm
glibc-headers-2.17-55.el7.x86_64.rpm
glibc-devel-2.17-55.el7.x86_64.rpm
cpp-4.8.2-16.el7.x86_64.rpm
gcc-4.8.2-16.el7.x86_64.rpm
- 然后安装:
rpm -Uvh *.rpm --nodeps --force
- 如果安装时提示
./configure: error: the HTTP rewrite module requires the PCRE library.
- 安装openssl即可:
yum -y install openssl openssl-devel
- 如果提示需要PCRE包:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
- 需要进行安装:
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
配置Nginx转发到后端服务器/K8S/PaaS
worker_processes 1
user root
events {
worker_connections 1024
}
http {
include mime.types
default_type application/octet-stream
client_max_body_size 1000m
client_body_buffer_size 100m
client_body_temp_path /tmp
sendfile on
keepalive_timeout 65
server {
listen 80
server_name localhost
location / {
proxy_pass {PaaS应用的域名}
proxy_redirect off
}
}
}