System hardware: VMware vsphere (cpu:2*4 core, memory 2G)
System version: CentOS Linux release 7.0.1406
Installation steps:
1. System environment
1.1 Updating the system
[email protected] ~]# Yum update-y
1.2 Viewing the Environment
[Email protected] ~]# cat/etc/redhat-release
CentOS Linux release 7.0.1406 (Core)
[Email protected] ~]# uname-a
Linux tengine 3.10.0-123.4.2.el7.x86_64 #1 SMP Mon June 16:09:14 UTC x86_64 x86_64 x86_64 gnu/linux
2. Installing Tengine
2.1. Prepare for installation
[Email protected] ~]# cd/usr/local/src/
Download pcre-8.35.tar.gz to/usr/local/src
[Email protected] ~]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
Download zlib-1.2.8.tar.gz to/usr/local/src
[Email protected] ~]# wget http://zlib.net/zlib-1.2.8.tar.gz
Download openssl-1.0.1h.tar.gz to/usr/local/src
[Email protected] ~]# wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz
Download jemalloc-3.6.0.tar.bz2 to/usr/local/src
[Email protected] ~]# wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
Download tengine-2.0.3.tar.gz to/usr/local/src
[Email protected] ~]# wget http://tengine.taobao.org/download/tengine-2.0.3.tar.gz
2.2 Update Package
[email protected] ~]# Yum install zlib-devel openssl-devel-y
2.3 Installing Pcre
[Email protected] ~]# cd/usr/local/src/
[Email protected] ~]# tar zvxf pcre-8.35.tar.gz
[Email protected] ~]# CD pcre-8.35
[Email protected] ~]#./configure
[[email protected] ~]# make && make install
2.4 Installing OpenSSL
[Email protected] ~]# cd/usr/local/src/
[Email protected] ~]# tar zvxf openssl-1.0.1h.tar.gz
[Email protected] ~]# CD openssl-1.0.1h
[Email protected] ~]#./config
[[email protected] ~]# make && make install
2.5 Installing Zlib
[Email protected] ~]# cd/usr/local/src/
[Email protected] ~]# tar zlib-1.2.8.tar.gz
[Email protected] ~]# CD zlib-1.2.8
[Email protected] ~]#./configure
[[email protected] ~]# make && make install
2.6 Installing Jemalloc
[Email protected] ~]# cd/usr/local/src/
[Email protected] ~]# tar zvxf jemalloc-3.6.0
[Email protected] ~]# CD jemalloc-3.6.0
[Email protected] ~]#./configure
[[email protected] ~]# make && make install
[[email protected] ~]# echo '/usr/local/lib ' >/etc/ld.so.conf.d/local.conf
[Email protected] ~]# Ldconfig
4.4 Create WWW Users and groups, create directories used by WWW virtual hosts, and log directories used by Nginx, and give them appropriate permissions
[Email protected] ~]# Groupadd www
[Email protected] ~]# useradd-g www www
[Email protected] ~]# mkdir-p/data/www
[Email protected] ~]# chmod +w/data/www
[Email protected] ~]# chown-r www:www/data/www
4.5 Installing Tengine
[Email protected] ~]# cd/usr/local/src/
[Email protected] ~]# tar zvxf tengine-2.0.3.tar.gz
Spoofing server information (can not be modified)
[Email protected] ~]# CD Nginx-1.6.0/src/core
[[email protected] ~]# vim./src/core/nginx.h
Modify Nginx_version to the version you want to display
Modify Nginx_ver to the name you want to display
Modify Nginx_var to the name you want to display
Save
Start installing Nginx
./configure--prefix=/opt/nginx--user=www--group=www--with-http_stub_status_module--with-http_ssl_module-- With-http_gzip_static_module--with-openssl=/usr/local/src/openssl-1.0.1h--with-zlib=/usr/local/src/zlib-1.2.8- -with-pcre=/usr/local/src/pcre-8.35--with-jemalloc
[[email protected] ~]# make && make install
4.6 Modifying nginx.conf
[Email protected] ~]# vim/opt/nginx/conf/nginx.conf
Modify the previous behaviors:
User www www;
Worker_processes 4;
Error_log Logs/error.log Crit;
PID Logs/nginx.pid;
events{
Use Epoll;
Worker_connections 65535;
}
4.7 Testing and running
[Email protected] ~]# Cd/opt/nginx
[Email protected] ~]# Ldconfig
[Email protected] ~]#./sbin/nginx-t
If the following information is displayed, it means that the configuration is not a problem
Nginx:the configuration file/opt/nginx/conf/nginx.conf syntax is OK
Nginx:configuration file/opt/nginx/conf/nginx.conf Test is successful
Enter code to run Nginx service
[Email protected] ~]#./sbin/nginx
[[Email protected] ~]# PS au|grep nginx
If you display a message similar to the following, it means that Nginx has started
Root 0.0 0.0 103156 856 pts/0 s+ 03:22 0:00 grep nginx
Enter code to detect if acceleration is supported
See if it takes effect
[Email protected] ~]# Lsof-n | grep jemalloc
Ginx 2346 root mem REG 253,1 1824470 51571788/usr/local/lib/libjemalloc.so.1
Nginx 2347 www mem REG 253,1 1824470 51571788/usr/local/lib/libjemalloc.so.1
Nginx 2348 www mem REG 253,1 1824470 51571788/usr/local/lib/libjemalloc.so.1
Nginx 2349 www mem REG 253,1 1824470 51571788/usr/local/lib/libjemalloc.so.1
Nginx 2350 www mem REG 253,1 1824470 51571788/usr/local/lib/libjemalloc.so.1
[Email protected] ~]# Curl http://localhost
4.8 Open Firewall 80 port
#停止firewall
[Email protected] ~]# Systemctl stop Firewalld.service
#禁止firewall开机启动
[Email protected] ~]# systemctl disable Firewalld.service
Installing Iptables
[email protected] ~]# Yum install iptables-services
Set firewall rules (add 80 ports)
[Email protected] ~]# Vim/etc/sysconfig/iptables
Open file, add 80 port that line
*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m state--state related,established-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-i lo-j ACCEPT
-A input-p tcp-m state--state new-m TCP--dport 22-j ACCEPT
-A input-p tcp-m state--state new-m TCP--dport 80-j ACCEPT
-A input-j REJECT--reject-with icmp-host-prohibited
-A forward-j REJECT--reject-with icmp-host-prohibited
COMMIT
: Wq #保存退出
#重启防火墙使配置生效
[Email protected] ~]# systemctl restart Iptables.service
#设置防火墙开机启动
[Email protected] ~]# Systemctl enable Iptables.service
4.9 As a service, boot after boot
[Email protected] ~]# Vim/usr/lib/systemd/system/tengine.service
Add the following content
[Unit]
Description=the nginx HTTP and reverse proxy server
After=syslog.target Network.target Remote-fs.target Nss-lookup.target
[Service]
Type=forking
Pidfile=/opt/nginx/logs/nginx.pid
Execstartpre=/opt/nginx/sbin/nginx-t
Execstart=/opt/nginx/sbin/nginx
Execreload=/bin/kill-s HUP $MAINPID
Execstop=/bin/kill-s QUIT $MAINPID
Privatetmp=true
[Install]
Wantedby=multi-user.target
: Wq Save Exit
[Email protected] ~]# Systemctl stop Tengine
[Email protected] ~]# systemctl start tengine
[Email protected] ~]# Systemctl Reload Tengine
[Email protected] ~]# Systemctl enable Tengine
[Email protected] ~]# Shutdown-r now
Compile and install Centos 7 x64 + tengine.2.0.3 (measured + notes)