安装依赖包 yum install -y gcc gcc-c++ ncurses-devel perl pcre pcre-devel openssl openssl-devel zlib
[root@nginx ~]# useradd nginx -s /sbin/nologin
[root@nginx opt]# tar zxf pcre-8.34.tar.gz
[root@nginx opt]# cd pcre-8.34
[root@nginx pcre-8.34]# ./configure
[root@nginx pcre-8.34]# make && make install
[root@nginx opt]# tar zxf tengine-1.5.1.tar.gz
[root@nginx opt]# cd tengine-1.5.1
[root@nginx tengine-1.5.1]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
[root@nginx tengine-1.5.1]# make && make install
(1)修改配置文件
[root@nginx ~]# mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
[root@nginx ~]# vi /usr/local/nginx/conf/nginx.conf
添加以下配置
user nginx nginx;
worker_processes auto;
worker_rlimit_nofile 65535;
error_log /var/log/www/error.log;
#pid logs/nginx.pid;
events {
use epoll;
worker_connections 51200;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request"'
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server_info off;
server_tag off;
server_name_in_redirect off;
access_log /var/log/www/access.log main;
client_max_body_size 20m;
client_header_buffer_size 16k;
large_client_header_buffers 4 16k;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
server_tokens on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_proxied any;
gzip_http_version 1.1;
gzip_comp_level 3;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
upstream www {
consistent_hash $request_uri;
#ip_hash;
server 192.168.1.242:8080;
server 192.168.1.243:8080;
}
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
proxy_pass http://www;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
}
nginx--tengine源码安装
最新推荐文章于 2023-07-09 21:05:45 发布