1.企业级Tengine的安装配置优化

###安装

yum install -y pcre zlib openssl jemallocid
groupadd www-data
useradd -s /sbin/nologin -g www-data www-data 

cd /tmp
wget http://tengine.taobao.org/download/tengine-2.3.3.tar.gz
tar -zxvf tengine-2.3.3.tar.gz
cd tengine-2.3.3

./configure --prefix=/usr/local/tengine-2.3.3 --user=www-data --group=www-data --with-threads --with-http_v2_module --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_stub_status_module --add-module=modules/ngx_http_upstream_session_sticky_module --add-module=modules/ngx_http_upstream_check_module --with-stream --with-stream_ssl_module

make
make install 

###配置服务

cd /usr/local/
ln -s tengine-2.3.3 nginx

vim /lib/systemd/system/nginx.service #加入以下内容

[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
Execstop=/bin/kill -s QUIT $SMAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

#保存并使之生效

systemctl daemon-reload 

###配置tengine

mkdir /usr/local/tengine-2.3.3/vhosts
cp -a /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.original


vim /usr/local/nginx/conf/nginx.conf
user www-data;
worker_processes auto;
pid logs/nginx.pid;

events{
    accept_mutex on;
    multi_accept on;
    worker_connections 65535;
}

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"';

    log_format hr_upstreams '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer"'
                    '"$http_user_agent" "$http_x_forwarded_for" $request_time $upstream_response_time "$upstream_addr" $upstream_status';
	
	access_log /var/log/nginx/access.log main;
	error_log /var/log/nginx/error.log warn;

	sendfile on;
	tcp_nopush on;
	keepalive_timeout 65;
	gzip on;
	gzip_disable "msie6";
	gzip_proxied any;
	gzip_comp_level 6;
	gzip_buffers 16 8k;
	gzip_vary on;
	gzip_http_version 1.1;
	gzip_types text/plain text/css text/xml text/javascript application/json application/x-javascript application/xml application/xml+rss;
	charset UTF-8;
	include /usr/local/nginx/vhosts/*.conf;
	server{
		listen 80 default;
		server_name localhost;
		
		location / {
			root html;
			index index.html index.htm;
		}
		error_page 500 502 503 504 /50x.html;
		location = /50x.html{
			root html;
		}
	}
}



mkdir -p /var/log/nginx
chown -R www-data. /var/log/nginx
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx

###检查与开启

nginx -t
systemctl start nginx
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值