Environment:
System hardware: VMWare vsphere (CPU: 2*4 cores, 2 GB memory)
System Version: centos Linux release 7.0.1406
Installation steps:
1. System Environment
1.1 update the system
[[Email protected] ~] # Yum Update-y
1.2 view the environment
[[Email protected] ~] # Cat/etc/RedHat-release
Centos Linux release 7.0.1406 (CORE)
[[Email protected] ~] # Uname-
Linux tengine 3.10.0-123.4.2.el7.x86 _ 64 #1 SMP mon Jun 30 16:09:14 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
2. Install 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 install 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 install 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 install 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 install 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 the log directories used by nginx, and grant them appropriate Permissions
[[Email protected] ~] # Groupadd WWW
[[Email protected] ~] # Useradd-G WWW
[[Email protected] ~] # Mkdir-P/data/WWW
[[Email protected] ~] # Chmod + w/data/WWW
[[Email protected] ~] # Chown-r www: www/data/WWW
4.5 install tengine
[[Email protected] ~] # Cd/usr/local/src/
[[Email protected] ~] # Tar zvxf tengine-2.0.3.tar.gz
Camouflage server information (not modified)
[[Email protected] ~] # Cd nginx-1.6.0/src/Core
[[Email protected] ~] # Vim./src/CORE/nginx. h
Change nginx_version to the version number you want to display
Change nginx_ver to the name you want to display
Change nginx_var to the name you want to display
Save
Start nginx Installation
. /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 modify nginx. conf
[[Email protected] ~] # Vim/opt/nginx/CONF/nginx. conf
Modify the previous behavior:
User WWW;
Worker_processes 4;
Error_log logs/error. Log crit;
PID logs/nginx. PID;
Events {
Use epoll;
Worker_connections 65535;
}
4.7 test and run
[[Email protected] ~] # Cd/opt/nginx
[[Email protected] ~] # Ldconfig
[[Email protected] ~] #./Sbin/nginx-T
If the following information is displayed, the configuration is correct.
Nginx: the configuration file/opt/nginx/CONF/nginx. conf syntax is OK
Nginx: configuration file/opt/nginx/CONF/nginx. conf test is successful
Enter the code to run the nginx Service
[[Email protected] ~] #./Sbin/nginx
[[Email protected] ~] # Ps au | grep nginx
If the following information is displayed, it indicates that nginx has been started.
Root 2013 0.0 0.0 103156 856 pts/0 S + grep nginx
Enter code to check whether acceleration is supported
Check whether it takes effect
[[Email protected] ~] # Lsof-N | grep jemalloc
G00002346 root mem Reg 253,1 1824470 51571788/usr/local/lib/libjemalloc. so.1
Nginx 2347 WWW mem Reg 1824470, 1 51571788/usr/local/lib/libjemalloc. so.1
Nginx 2348 WWW mem Reg 1824470, 1 51571788/usr/local/lib/libjemalloc. so.1
Nginx 2349 WWW mem Reg 1824470, 1 51571788/usr/local/lib/libjemalloc. so.1
Nginx 2350 WWW mem Reg 1824470, 1 51571788/usr/local/lib/libjemalloc. so.1
[[Email protected] ~] # Curl http: // localhost
4.8 open port 80 of the firewall
# Stop Firewall
[[Email protected] ~] # Systemctl stop firewalld. Service
# Disable firewall startup
[[Email protected] ~] # Systemctl disable firewalld. Service
Install iptables
[[Email protected] ~] # Yum install iptables-services
Set firewall rules (add Port 80)
[[Email protected] ~] # Vim/etc/sysconfig/iptables
Open the file and add the port 80 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 # Save and exit
# Restart the firewall to make the configuration take effect
[[Email protected] ~] # Systemctl restart iptables. Service
# Set firewall startup
[[Email protected] ~] # Systemctl enable iptables. Service
4.9 As a service, started after startup
[[Email protected] ~] # Vim/usr/lib/systemd/system/tengine. Service
Add the following content
[Unit]
Description = The nginx HTTP and Reverse Proxy Server
After1_syslog.tar get network.tar get 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]
Wantedbypolicmulti-user.tar get
: WQ save and 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