1. Install Pcre:
To see if Pcre has been installed:
[Email protected] ~]# Rpm-qa pcrepcre-devel
Pcre-7.8-6.el6.x86_64
If not, execute the Install command: [[email protected] ~]# Yum install pcre-devel-y
[Email protected] ~]# Rpm-qa pcrepcre-devel
Pcre-7.8-7.el6.x86_64
Pcre-devel-7.8-7.el6.x86_64
2. Install the security package OpenSSL:
[email protected] ~]# Yum installopenssl-devel-y
[Email protected] ~]# Rpm-qa opensslopenssl-devel
Openssl-devel-1.0.1e-48.el6_8.1.x86_64
Openssl-1.0.1e-48.el6_8.1.x86_64
3. Install Nginx:
[Email protected] ~]# Mkdir-p/home/oldboy/tools
[Email protected] ~]# Cd/home/oldboy/tools
[Email protected] tools]# wget-qhttp://nginx.org/download/nginx-1.6.3.tar.gz
[[email protected] tools]# ls nginx-1.6.3.tar.gz
Nginx-1.6.3.tar.gz
[[email protected] tools]# ls nginx-1.6.3.tar.gz-lk
-rw-r--r--1 root root 787 April 8 nginx-1.6.3.tar.gz
Unzip and switch to the Nginx directory:
[Email protected] tools]# tar zxfnginx-1.6.3.tar.gz
[Email protected] tools]# CD nginx-1.6.3
To view the total number of files:
[Email protected] nginx-1.6.3]# tree|wc-l
404
Compile and install (--prefix compiled directory)
[[Email protected]]#./configure--prefix=/application/nginx-1.6.3--user=nginx--group=nginx--with-http_ssl_module --with-http_stub_status_module
650) this.width=650; "Width=" 553 "height=" 147 "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "alt=" Spacer.gif "/>
[[email protected] nginx-1.6.3] #make && make install
Add Users:
[Email protected] nginx-1.6.3]# useradd nginx-s/sbin/nologin-m
[[email protected] nginx-1.6.3]# ID nginx
uid=502 (Nginx) gid=502 (nginx) group =502 (Nginx)
[Email protected] tools]# ll/application/nginx-1.6.3/-ld
Drwxr-xr-x 6 root root 4096 July 19:15/application/nginx-1.6.3/
To create a soft connection:
[Email protected] tools]# ln-s/application/nginx-1.6.3//application/nginx
[Email protected] tools]# ls-l/application/
Total Dosage 8
lrwxrwxrwx 1 root root 25 July 19:20 Nginx->/application/nginx-1.6.3/
Drwxr-xr-x 6 root root 4096 July 19:15 nginx-1.6.3
To start the Nginx service:
[Email protected] ~]# Ps-ef|grep nginx|grep-v grep
Root 10949 1 0 19:26? 00:00:00 Nginx:master Process/application/nginx/sbin/nginx
Nginx 10950 10949 0 19:26? 00:00:00 Nginx:worker Process
[Email protected] ~]# Ss-lntup|grep Nginx
TCP LISTEN 0 *:80 *:* Users: (("Nginx", 10949,6), ("Nginx", 10950,6))
Whether the local test was successfully deployed:
[Email protected] ~]# Curl 127.0.0.1
<! DOCTYPE html>
<title>welcome tonginx!</title>
<style>
Body {
Width:35em;
margin:0 Auto;
Font-family:tahoma, Verdana, Arial, Sans-serif;
}
</style>
<body>
<p>if you see this page, the Nginxweb server is successfully installed and
Working. Further configuration isrequired.</p>
<p>for online documentation Andsupport please refer to
<ahref= "http://nginx.org/" >nginx.org</a>.<br/>
Commercial support was available at
<ahref= "http://nginx.com/" >nginx.com</a>.</p>
<p><em>thank for Usingnginx.</em></p>
</body>
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/89/D1/wKioL1gew0PyfC3dAADfscl9QUc343.png-wh_500x0-wm_3 -wmp_4-s_1500858951.png "title=" 2.png "alt=" Wkiol1gew0pyfc3daadfscl9quc343.png-wh_50 "/> View compilation parameters for software Installation:
[Email protected] ~]#/application/nginx/sbin/nginx-v
Nginx version:nginx/1.6.3
Built by GCC 4.4.7 20120313 (Red hat4.4.7-11) (GCC)
TLS SNI Support Enabled
Configure arguments:--prefix=/application/nginx-1.6.3--user=nginx--group=nginx--with-http_ssl_module--with-http _stub_status_module
Switch to the installation directory and view:
[Email protected] nginx]# ls-l|grep-vtemp
Total Dosage 36
Drwxr-xr-x 2 root root 4096 July 19:15 conf
Drwxr-xr-x 2 root root 4096 July 19:15 html
Drwxr-xr-x 2 root root 4096 July 19:26 logs
Drwxr-xr-x 2 root root 4096 July 19:15 sbin
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/89/D1/wKioL1gewzHDp4x4AAUgDpxFtMw034.png-wh_500x0-wm_3 -wmp_4-s_2134491864.png "title=" 1.png "alt=" Wkiol1gewzhdp4x4aaugdpxftmw034.png-wh_50 "/>
To view Nginx core configuration files:
[Email protected] html]# CD.
[Email protected] nginx]# CD conf/
[Email protected] conf]# ls-lnginx.conf
-rw-r--r--1 root root 2656 July 19:15 nginx.conf
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/89/D4/wKiom1gew1mQ5yvVAASR5PIAno4433.png-wh_500x0-wm_3 -wmp_4-s_1746686492.png "title=" 3.png "alt=" Wkiom1gew1mq5yvvaasr5piano4433.png-wh_50 "/>
To minimize configuration of the domain-based nginx configuration file:
[Email protected]ongyaclient01 conf]# egrep-v "#|^$" Nginx.conf.default
Worker_processes 1;
Events {
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Sendfile on;
Keepalive_timeout 65;
server {
Listen 80;
server_name localhost;
Location/{
root HTML;
Index index.html index.htm;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
}
[Email protected] conf]# egrep-v "#|^$" Nginx.conf.default >nginx.conf
Edit nginx.conf File:
[Email protected] conf]# vim nginx.conf
Location =/50x.html {
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
Root html/www server {
Listen 80;
server_name www.hongya.org;
Location/{
Root html/www;
Index index.html index.htm;
}
Root html/www;
erver {
Listen 80;
server_name www.hongya.org;
Location/{
Root html/www;
Index index.html index.htm;
}
server {
Listen 80;
server_name www.hongya.org;
Location/{
Root html/www;
Index index.html index.htm;
}
}
erver {
Listen 80;
server_name www.hongya.org;
Location/{
Root html/www;
Index index.html index.htm;
}
Worker_processes 1;
Events {
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Sendfile on;
Keepalive_timeout 65;
server {
Listen 80;
server_name www.hongya.org;
Location/{
Root html/www;
Index index.html index.htm;
}
}
server {
Listen 80;
server_name bbs.hongya.org;
Location/{
Root Html/bbs;
Index index.html index.htm;
}
}
}
"Nginx.conf" 32L, 566C written
To create a table of contents and HTML pages:
[Email protected] conf]# mkdir. /html/{www,bbs}
[Email protected] conf]# ls-l. /html/
Total dosage 16
-rw-r--r--1 root root 537 July 19:15 50x.html
Drwxr-xr-x 2 root root 4096 July 21:31 BBS
-rw-r--r--1 root root 628 July 19:48 index.html
Drwxr-xr-x 2 root root 4096 July 21:31 www
[Email protected] conf]#
[Email protected] conf]# echo "www.hongya.org" ... /html/www/index.html
[Email protected] conf]# echo "bbs.hongya.org" ... /html/bbs/index.html
[email protected] conf]# cat. /html/{www,bbs}/index.html
www.hongya.org
bbs.hongya.org
Check that the configuration is incorrect:
[Email protected] Conf]#/application/nginx/sbin/nginx-t
Nginx:the configuration file/application/nginx-1.6.3/conf/nginx.conf syntax is OK
Nginx:configuration file/application/nginx-1.6.3/conf/nginx.conf Test is successful
Restart Nginx Service:
[Email protected] conf]#/application/nginx/sbin/nginx-s Reload
To configure the host file, test:
[Email protected] conf]# vim/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.132 www.hongya.org
192.168.10.132 bbs.hongya.org
~
"/etc/hosts" 5L, 221C written
Port-based Nginx configuration:
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/89/D1/wKioL1gew7uiTxg5AAP0Pn8igsQ978.png-wh_500x0-wm_3 -wmp_4-s_3518387696.png "style=" Float:none; "title=" 5.png "alt=" Wkiol1gew7uitxg5aap0pn8igsq978.png-wh_50 "/>
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/89/D1/wKioL1gew9XQHrv1AA4vBLhrue8877.png-wh_500x0-wm_3 -wmp_4-s_2040160482.png "style=" Float:none; "title=" 6.png "alt=" Wkiol1gew9xqhrv1aa4vblhrue8877.png-wh_50 "/>
Linux (version 6.8 minimized installation) installation Nginx combat