Nginx安装与服务部署
2022-08-03 本文已影响0人
beyond阿亮
Nginx安装与服务部署
nginx安装
a.安装编译工具及库文件
yum -y install make wget gcc-c++ libtool openssl openssl-devel zlib zlib-devel
b.下载PCRE
mkdir -p /data/software
cd /data/software
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
tar zxvf pcre-8.35.tar.gz
c.安装Nginx
wget http://nginx.org/download/nginx-1.10.2.tar.gz
tar -zxvf nginx-1.10.2.tar.gz
cd nginx-1.10.2
./configure --prefix=/data/liang/nginx-upload-main \
--pid-path=/data/logs/nginx-upload-main/nginx.pid \
--lock-path=/data/liang/nginx-upload-main/nginx.lock \
--error-log-path=/data/logs/nginx-upload-main/error.log \
--http-log-path=/data/logs/nginx-upload-main/access.log \
--http-client-body-temp-path=/data/temps/nginx-upload-main/client_body_temp \
--http-proxy-temp-path=/data/temps/nginx-upload-main/proxy_temp \
--http-fastcgi-temp-path=/data/temps/nginx-upload-main/fastcgi_temp \
--http-uwsgi-temp-path=/data/temps/nginx-upload-main/uwsgi_temp \
--http-scgi-temp-path=/data/temps/nginx-upload-main/scgi_temp \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre=/data/software/pcre-8.35 \
--with-http_auth_request_module
make
make install
配置服务
vim /data/liang/nginx-upload-main/conf/nginx.conf
user root;
worker_processes 1;
error_log /data/logs/nginx-upload-main/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /data/logs/nginx-upload-main/nginx.pid;
events {
worker_connections 1024;
}
http{
access_log /data/logs/nginx-upload-main/access.log;
underscores_in_headers on;
upstream auth-server {
server 127.0.0.1:8080;
}
upstream upload-server {
hash $http_x_liang_uid;
server 192.168.1.8:80;
server 192.168.1.9:80;
}
upstream check-server {
server 192.168.1.8:8080;
server 192.168.1.9:8080;
}
server {
listen 80;
client_max_body_size 100m;
location ~/media/file/\S+/checksum{
auth_request /auth;
auth_request_set $auth_status $upstream_status;
proxy_pass http://check-server;
}
location ~/media/file/\S+/upload {
auth_request /auth;
auth_request_set $auth_status $upstream_status;
proxy_pass http://upload-server;
}
location = /auth {
internal;
proxy_pass http://auth-server;
proxy_set_header Content-Length "";
}
}