In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Author: Georgekai
Archiving: learning notes
2018-2-2
Nginx Service deployment 1.1 Common web Software understanding 1.1.1 web Service mainstream Software address
Https://w3techs.com/technologies/overview/web_server/all
1.1.2 Software commonly used to provide dynamic services
The files at the end of PHP:.php are suitable for large, medium, small and medium-sized websites. It is a parsing container for dynamic web language PHP programs, usually with apache or nginx parsing dynamic programs.
Tomcat: suitable for small and medium-sized enterprises, not suitable for environments with high concurrency
Resin: suitable for large enterprises, suitable for environments with high concurrency
The file at the end of IIS:.asp, web service software under windows
1.2 Nginx introduction
1.Nginx ("engine x") is an open source software that supports high-performance, high-concurrency WWW servers and proxy services
2.Nginx is becoming more and more popular because of its high concurrency (especially static resources), less system resources and rich functions.
3.Nginx can run in UNIX, Linux, BSD, Mac OS X, Solaris, and Microsoft Windows operating systems.
4. The current popular Nginx Web combination is called LNMP or LEMP
The code program of the 5.L==Linux N/E==Nginx M==MySQL P==php website = = build a complete website
1.2.1 official website: selection of http://nginx.org/1.2.2 software version (recommended)
The version that is pushed forward one year to half a year is relatively stable (there may be bug in the near future)
1.2.3 Module usage (Chinese version): http://manual.51yip.com/nginx/1.3 nginx Software feature description
1) support high concurrency: can support tens of thousands of concurrent connections (especially in static small file business environment)
2) low resource consumption: under 30, 000 concurrent connections, starting 10 Nginx threads consumes less memory than 200MB
PS: (test software tool: ab,JMeter,Webbench,LoadRunner,http_load,tcpcopy)
3) can do HTTP reverse proxy and accelerate cache, that is, load balancing function (layer 4 and layer 7)
Built-in RS node server health check function, which is equivalent to professional Haproxy software or LVS (layer 4) function.
Software such as PS:LVS does not have health check function.
4) it has the cache function of professional cache software such as Squid. (memcache/redis)
5) support epoll (Linux 2.6 +), the event model of asynchronous network Iamp O
The model used by PS:apache: select, the performance is not as good as nginx.
1.4 Why is the overall performance of Nginx higher than that of Apache
Ngimx: using the latest epoll (linux 2.6 kernel) model, and kqueue (freebsd) asynchronous network Icano model
Features analogy: find a girlfriend, hostel aunt check registration information, quickly find personnel information, this is the epoll model
Apache: using the traditional select model
Features analogy: find a girlfriend, hostel aunt one by one to take you to find, to ask, this is the select model
1.5 steps for compiling and installing nginx software
PS: you can also refer to the official documentation: building nginx: http://nginx.org/en/docs/configure.html from the source
1.5.1 check the system environment where the software is installed first
Cat / etc/redhat-release
Uname-r
1.5.2 download nginx software-1.12.2 copy link address (unified location for download)
Mkdir-p / server/tools
Cd / server/tools
Wget-Q http://nginx.org/download/nginx-1.12.2.tar.gz
1.5.3 install the dependent package (pcre-devel openssl-devel) for nginx
Yum install-y pcre-devel openssl-devel
PS: do not install pcre and cannot use rewrite modules (rewrite requires regular expressions that recognize the perl language)
PS:openssl: encrypt remote access to a website
1.5.4 steps to compile and install software
Advance condition: if the system does not install compatible libraries or development tools, please install the basic dependency package
Yum install gcc gcc-c++ automake autoconf-y
1. Extract to the current directory nginx-1.12.2.tar.gz
Tar xf nginx-1.12.2.tar.gz
two。 Enter the nginx-1.12.2 directory
Cd nginx-1.12.2/
3. Create a www virtual user
PS: let www users specifically manage nginx services. Root permissions are too large to be safe.
Useradd-M-s / sbin/nologin www
3. Specify the installation path and configure the parameters (the parameters are explained below)
. / configure-prefix=/application/nginx-1.12.2-user=www-group=www-with-http_stub_status_module-with-http_ssl_module
4. Compile (translate)
PS: the essence of the compilation process is to convert various program languages into binary information that the system can recognize.
Make
5. Compilation and installation
Make install
6. Create a soft connection to the program directory
PS: avoid frequent version changes, then only need to change the soft connection, do not need to change the code program
Ln-s / application/nginx-1.12.2/ / application/nginx
7. Start the website service
/ application/nginx/sbin/nginx
8. Check whether the service starts successfully
Ps-ef | grep nginx
9. Test access
Lynx 10.0.0.7
Curl 10.0.0.7
Browser access mode
1.6 Edit installation configuration parameter description
. / configure
-- prefix=PATH-- specify the path information for the installation of software programs
-- user=USER-- create a virtual user to manage the worker process of the nginx service
-- group=GROUP-- create a virtual user group to manage the worker process of the nginx service
-- with-http_ssl_module-- enable nginx services to support https access
-- with-http_stub_status_module-- convenient for monitoring software to monitor the running status of nginx services
The following parameters can be referenced (the above by default):
-- sbin-path=/usr/local/nginx/nginx
-- conf-path=/usr/local/nginx/nginx.conf
-- pid-path=/usr/local/nginx/nginx.pid
-- with-pcre=../pcre-8.41
-- with-zlib=../zlib-1.2.11
1.7 nginx command parameters
/ application/nginx/sbin/nginx-- start nginx
/ application/nginx/sbin/nginx-s reload-- smooth restart
/ application/nginx/sbin/nginx-s stop-- stop the service
/ application/nginx/sbin/nginx-t-- configuration file syntax check
/ application/nginx/sbin/nginx-h-- View parameter usage help information
/ application/nginx/sbin/nginx-V-- View software compilation, installation and configuration parameter information
1.7.1 nginx view software compilation and installation configuration parameter information (- V)
[root@web01 application] # / application/nginx/sbin/nginx-V
Nginx version: nginx/1.10.3
Built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
Built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
Configure arguments:-prefix=/application/nginx-1.10.3-- user=www-- group=www-- with-http_stub_status_module-- with-http_ssl_module
PS: commonly used to view the parameters of the previous configuration of nginx
1.7.2 nginx View Parameter usage help (- h)
[root@web01 application] # / application/nginx/sbin/nginx-h
Nginx version: nginx/1.10.3
Usage: nginx [-? hvVtTq] [- s signal] [- c filename] [- p prefix] [- g directives]
Options:
-h: this help
-v: show version and exit
-V: show version and configure options then exit
-t: test configuration and exit
-T: test configuration, dump it and exit
-Q: suppress non-error messages during configuration testing
-s signal: send signal to a master process: stop, quit, reopen, reload
-p prefix: set prefix path (default: / application/nginx-1.10.3/)
-c filename: set configuration file (default: conf/nginx.conf)
-g directives: set global directives out of configuration file
1.8 problems that may be encountered during the deployment of nginx software
1. Software dependency package is not installed correctly-PCRE dependency package is not installed
. / configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using-without-http_rewrite_module
Option, or install the PCRE library into the system, or build the PCRE library
Statically from the source with nginx by using-- with-pcre= option.
Solution: yum install pcre pcre-devel-y
two。 Software dependency package is not installed correctly-OPENSSL dependency package is not installed
. / configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
Into the system, or build the OpenSSL library statically from the source
With nginx by using-- with-openssl= option.
Solution: yum install openssl openssl-devel-y
1.9 problems that may be encountered during the startup of nginx software
1. The error "nginx: [emerg] getpwnam (" nginx ") failed" is reported when starting Nginx
Answer: this is because there is no corresponding Nginx service user, perform useradd nginx-s / sbin/nologin-M creation
1.10 nginx software program directory structure
Ls-l / application/nginx/
Drwxr-xr-x 2 root root 4096 Sep 8 21:22 conf-configuration file save directory
Drwxr-xr-x 2 root root 4096 Sep 8 21:22 html-site directory
Drwxr-xr-x 2 root root 4096 Sep 8 21:52 logs-nginx service related log files save directory (error log access log)
Drwxr-xr-x 2 root root 4096 Sep 8 21:22 sbin-Service commands save directory (only one nginx command file)
1.10.1 description of the main files under the nginx configuration file directory conf:
Mime.types-Media Resource Type File
Nginx.conf-nginx service master profile
Nginx.conf.default-default configuration of the nginx service master profile (template)
PS: vimdiff nginx.conf nginx.conf.default-you can compare the difference between two files (practical)
1.11 the test environment simulates the construction of the website 1.11.1 simplifies the content of the nginx.conf main configuration file
Grep-Ev "# | ^ $" nginx.conf.default > nginx.conf
PS: filter out lines containing the # sign, and blank lines
1.11.2 backup before editing the main configuration file
Cp nginx.conf {, .bak}
1.11.3 Editing the main profile
Vim / application/nginx/conf/nginx.conf
Worker_processes 1;-- number of worker main processes (equivalent to server) the more processes, the higher efficiency
Events {--event block start
Worker_connections 1024;-- maximum number of connections per main process (want to be a customer)
}-end of event block
Http {--http block start
Include mime.types;-supported media type files
Default_type application/octet-stream;-Media type files supported by default
Sendfile on;-efficient transfer mode (disk-based block transfer, much faster)
Keepalive_timeout 65;-- connection timeout (disconnect if there is no data transmission within 65s)
Server {- the first server block (that is, a website (virtual host) that can have more than one)
Listen 80;-- listening port
Server_name www.georgekai.com;-the domain name that provides the service
Location / {- the first location (manage some website resource files)
Root html/www;-site root directory (home page files, pictures, etc.)
Index georgekai.html index.htm;-the default home page file for the website (multiple files are separated by spaces)
}-- end of the first server block
Error_page 500502 503 504 404 / kai.jpg;-the corresponding http status code, using kai.jpg to respond to the customer
Location = / kai.jpg {- second server block... (second website (virtual host))
Root html;. Ditto.
}
}
}
1.11.4 create a site directory and generate the home page file
1. Create a site directory
Mkdir / application/nginx/html/www
two。 Generate the home page file (html language)
Vim georgekai.html
Website title
Main content of website
01 oldboy
02 oldgril
03 olddog
PS: the above content is in html language format, and you can also write something to test it.
1.11.5 check the profile syntax and restart the nginx service
/ application/nginx/sbin/nginx-t
/ application/nginx/sbin/nginx-s reload
1.11.6 browser for test access
10.0.0.7
Www.georgekai.com
PS: to access through a domain name, you need to add the above resolution relationship to the native hosts file
1.12 nginx main profile area classification and description
1. Main block
2. Event Block
3. Http Block
Server blocks (there can be multiple), and each server is equivalent to a website
Location blocks (there can be multiple), and each location is equivalent to one module of server
1.13 what is the site directory and what is the home file?
The Spring Festival is coming soon, and the update will not be interrupted during the annual leave! Friends can consider using ansible to deploy and manage Nginx
Follow the Wechat public account: linux operation and maintenance rookie trip
Friends can follow my official Wechat account: linux operation and maintenance rookie trip.
Follow the official account of "China Telecom Tianjin Network Office". You can get free 2G traffic for the first time to provide traffic for your study!
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.