Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。
据W3Techs统计,Tengine在全球用户量排名中位列第9。
官网: http://tengine.taobao.org/
线上服务器都是Tengine
在官网下载最新版本
目前最新版本是Tengine-2.1.2
解压软件包,其中openssl,pcre,zlib都是最新版
tar zxvf openssl-1.0.2h.tar.gz -C /usr/src/
tar zxvf pcre-8.38.tar.gz -C /usr/src/
tar zxvf zlib-1.2.8.tar.gz -C /usr/src/
tar zxvf tengine-2.1.2.tar.gz -C /usr/src/
cd /usr/src/tengine-2.1.2/
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-openssl=/usr/src/openssl-1.0.2h --with-zlib=/usr/src/zlib-1.2.8 --with-pcre=/usr/src/pcre-8.38
make && make install
编辑配置文件
cd /usr/local/nginx/conf
mv nginx.conf nginx.conf.bak
vi nginx.conf
内容如下:
user www www;
worker_processes 4;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 60240;
}
# load modules compiled as Dynamic Shared Object (DSO)
#
#dso {
# load ngx_http_fastcgi_module.so;
# load ngx_http_rewrite_module.so;
#}
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
proxy_read_timeout 200;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css text/xml
application/x-javascript application/xml
application/atom+xml text/javascript;
client_max_body_size 64M;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
include vhosts/*;
}
上面的文件把默认的localhost给分离出来了
服务器是4核的
编辑配置文件
vi fastcgi_params
最后一行添加
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
创建虚拟主机配置文件目录
mkdir vhosts
创建localhost.conf文件
内容如下:
server {
listen 80;
server_name localhost;
root /usr/local/nginx/html;
index index.php index.html index.htm;
location / {
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
检测配置文件是否ok
/usr/local/nginx/sbin/nginx -t
启动nginx
/usr/local/nginx/sbin/nginx -s start
查看端口是否存在
netstat -anpt | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 24435/nginx
使用IP访问页面
http://192.168.1.110