In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to deploy Nginx services". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to deploy Nginx services.
1. Nginx introduction: 1.1What is Nginx?
Nginx ("engine x") is an open source software that supports high-performance, high-concurrency www services and proxy services.
It was developed by Russian Igor Sysoev and was originally used on www.rambler.ru, a large Russian website.
Nginx has the characteristics of high concurrency and less system resources.
Nginx can run on UNIX, Linux, DSB, Mac OS X, Solaris and Windows operating systems.
1.2 main features of Nginx
Support for high concurrency: tens of thousands of concurrent connections
Low resource consumption: under 30,000 concurrent connections, the first 10 threads consume less than 200MB.
Can do HTTP reverse proxy and acceleration cache, that is, load balancing function, built-in health check function for RS node server
Have the caching function of professional caching software such as Squid
Support for asynchronous network Icano event model
1.3 main functional applications of Nginx software
As Web service software
Reverse proxy and load balancing service
Front-end business data caching service
2. Nginx Web Service 2.1 Nginx as a Web server application scenario
Use Nginx to run static data such as HTML, JS, CSS, small pictures, etc.
Running dynamic programs such as PHP with Nginx and FastCGI
Nginx and Tomcat/Resin support Java dynamic programs.
2.2 how to select a Web server
In the work, choose the appropriate business service software according to the requirements:
Static business: high concurrency scenario, Nginx is preferred
Dynamic business: both Nginx and Apache are available. Nginx is recommended.
Static + dynamic service: recommended Nginx
3 compile and install Nginx
There are many installation methods, this article uses the compilation installation method. If you need to deploy on a large scale, you can customize the rpm package for your business requirements and install it through Ansible.
3.1 install the pcrelibrary
View the current system version:
Cat / etc/redhat-releaseuname-r
Results:
CentOS release 6.10 (Final) 2.6.32-754.el6.x86_64
Install pcre in yum:
Yum-y install pcre pcre-develrpm-qa pcre pcre-devel
Results:
Pcre-devel-7.8-7.el6.x86_64
Pcre-7.8-7.el6.x86_64
3.2 install Nginx
Check if openssl, openssl-devel are installed:
Rpm-qa openssl openssl-devel
Result: if not, install using yum
Openssl-1.0.1e-57.el6.x86_64openssl-devel-1.0.1e-57.el6.x86_64
Create a directory for storing nginx packages:
Mkdir-p / app/nginx-1.8.1mkdir-p / server/toolscd / server/tools/
Download the nginx package:
Official address: www.nginx.rog
Wget-Q http://nginx.org/download/nginx-1.8.1.tar.gz
To create a nginx user:
Useradd nginx-s / sbin/nologin-M
Extract the package and enter the unzipped directory:
Tar xf nginx-1.8.1.tar.gzcd nginx-1.8.1
To compile:
The compilation module can be viewed through. / configure-- help
. / configure-user=nginx-group=nginx-prefix=/app/nginx-1.8.1/-with-http_stub_status_module-with-http_ssl_module
Installation:
Makemake install
Create soft links: easy to use and version upgrade
Ln-s / app/nginx-1.8.1/ / app/nginx
Pre-launch test:
/ app/nginx/sbin/nginx-t
Results:
Nginx: the configuration file / app/nginx-1.8.1//conf/nginx.conf syntax is oknginx: configuration file / app/nginx-1.8.1//conf/nginx.conf test is successful
Start the Nginx service and check the port:
/ app/nginx/sbin/nginxnetstat-utpln | grep 80
Results:
Tcp 0 0 0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0 of the LISTEN 13689/nginx.
Check the startup result of Nginx: the following indicates that the startup is successful
Curl 192.168.1.31
Results:
Welcome to nginx! Body {width: 35eme; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif;} Welcome to nginx!
If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.
For online documentation and support please refer tonginx.org.Commercial support is available atnginx.com.
Thank you for using nginx.
4. Nginx directory structure and configuration file 4.1 Nginx directory structure description tree / app/nginx/app/nginx ├── client_body_temp ├── conf # nginx configuration file directory │ ├── fastcgi.conf # fastcgi related parameters configuration file │ ├── fastcgi.conf .default │ ├── fastcgi_params # fastcgi parameter file │ ├── fastcgi_params.default │ ├── koi-utf │ ├── koi-win │ ├── mime.types # Media Type │ ├── mime.types.default │ ├── nginx.conf # Nginx main configuration file │ ├── nginx.conf.default │ ├── scgi_params # scgi configuration file │ ├── scgi_params.default │ ├── uwsgi_params # uwsgi configuration file │ ├── uwsgi_params.default │ └── win-utf ├── fastcgi_temp # fastcgi temporary data file ├── html # default site directory │ ├── 50x.html # error page display file │ └── index.html # default site homepage file ├── logs # default log path │ ├── access.log # default access log file │ ├── error.log # default error Error log file │ └── nginx.pid # pid file ├── proxy_temp # temporary directory ├── sbin # Nginx command directory │ ├── nginx # launch command │ └── nginx.old ├── scgi_temp # temporary directory └── uwsgi_temp # temporary directory 9 directories 22 files4.2 Nginx Master Profil
To comment on the display profile:
Egrep-v "# | ^ $" / app/nginx/conf/nginx.conf.default
Results:
Worker_processes 1; # number of worker processes events {# event block start worker_connections 1024 # maximum connection supported by a single worker process} # event block end http {# HTTP block start include mime.types; # supported media type library default_type application/octet-stream # default media type sendfile on; # enable efficient transfer mode keepalive_timeout 65; # connection timeout server {# server block start listen 80 # Service port. Default is 80 server_name localhost; # domain name hostname location / {# location block start root html; # site root index index.html index.htm # default homepage file} # location block ends error_page 500 502 503 504 / 50x.htmlash # corresponding status code and response location = / 50x.html {# location starts responding to 50x.html root html # site directory is html}} # end of HTTP block
Note: server blocks and location blocks can be multiple.
At this point, I believe you have a deeper understanding of "how to deploy Nginx services". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.