Plan: I have used it briefly and read the book to get a complete understanding. 1. "Practical nginx: a high-performance web server that replaces apache" Contents: Installation, configuration and optimization, PHP FastCGI, JSP, reverse proxy, load balancing, Rewrite, caching, module introductionPress Go through it in order, focusing on reverse proxy, load balancing, rewrite, caching and module introduction. 2. "In-depth understanding of Nginx: module development and architecture analysis/Tao Hui. -Beijing: Machinery Industry Press, 2013.3" 978-7-111-41478-0This book talks about: How to use nginx Develop extension modules. The first part talks about how to use it, then analyzes the architecture and talks about how to develop it. "Nginx is very suitable for developing server programs that provide external services using TCP at the transport layer." Read the first part and skim the other parts. 3. "Learning nginx http server"Content: installation, http configuration, rewrite ssi, php, apacheFinally, briefly go over it, check for leaks and fill in the gapsBook 1: "Practical nginx: Replace apache High-performance web server》
---------------------------------13:25 2014- 05-18 1. Introduction nginx can use epoll and kqueue network io models. ---------------------------------13:29 2014-05-18 2 , installation and configuration http://www.nginx.net/Mainline version 1.7, Stable version 1.6, choose 1.7. Both windows version and linux version are required. Does apt library have it? What's the latest version? http://nginx.org/en/download.htmlhttp://nginx.org/download/nginx-1.7.0.tar.gzhttp://nginx.org/download /nginx-1.7.0.zipSource code online: http://trac.nginx.org/nginx/browser. Tested operating systems and platformsLinux 2.2 — 3 / i386; Linux 2.6 — 3 / amd64;Windows XP, Windows Server 2003.My experimental environment: Windows 2008 Server There is a virtual machine of Ubuntu 14.04 in R2. tar./configure [Various options]makemake installstart nginx -c nginx.confgView pid ps -ef | grep nginxstopkill -QUIT pidkill -TERM pidkill -9 nginxcheck configuration filenginx -t -c nginx.config smooth Restart kill -HUP pid-USR2: Smooth upgrade-USR1: Reopen the log file-WINCH: Close the work process gracefully-------------------------- ------------------14:09 2014-05-18 3. Basic configuration and optimization
Three and a half hours were wasted
17:24 2014-05-18 GO ONnginx.config structure events{}http{server{} server{ }}nginx supports a variety of virtual host configurations: ip-based, domain-name-based, and port-based. log_format can reference many variables! The appendix will have a complete list, including each module. After reverse proxy, $http_x_forwarded_for is the real IP of the client, $remote_addr is not. Browser-side cache must be set up, especially for content that changes little such as images, js, css, swf, etc. ---------------------------------18:14 2014-05-18 4. FastCGI
PHP or Perl
location ~ .*.(php|php5)?${fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php; include fcgi.conf;}Set up automatic startup at boot
Linux operation is what I want to strengthen, I need to read this book. Network settings, system settings, script analysis, etc.
vi /etc/rc.local---------------------------ulimit -SHn 65535/ ../php/sbin/php-fpm start/../sbin/nginx-------------------------- -------18:40 2014-05-18 5, JSPHmm! Lift your spirits. upstream tomcat_server{server 127.0.0.1:8000;}
There can be many servers here. You can use ip_hash, and the load may be unbalanced, but there is no need to copy the Session. Copying the Session will fill up the memory of each server in the cluster.
server{
location ~ .(jsp|jspx|do)?${proxy_set_header Host $host;proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http:// tomcat_server;}}---------------------------------
18:46 2014-05-18 6. HTTP load balancing and reverse proxyReview OSI1. Physics2. Data link3. Network: IP, IPX 4. Transmission! TCP and UDP are starting to become important5. Session6. Representation7. Applications: HTTP, FTP, Telnet, SNMP, etc. Common load balancing solutions are at Layer 4/Layer 7. The legendary F5. High-end equipment. Are there any cheaper domestic ones? Convinced, Hua 3. Common people’s LVS (Linux Server)Find a book and read it specificallynginx down offlinebackup is only enabled for non-backup complete downtimeip_hash is similar to session_sticky upstream proxy_passfastcgi_passnginx dual-machine high availability: Drift IP; write scripts for background monitoring and offline transfer.
This should be implemented using keepalived? Find the article and read it. A single machine can load 100,000. The demand for Load Balance may not be large, but the demand for HA is too great. Is there module support?
---------------------------------19:23 2014-05-18 7. Rewrite式 Various regular expression 正PCRE
IF REWRITE SET RETURN BREAK
= equal to
! = Not equal to
~ distinguishment
~* Do not distinguish big messages
-- f The file exists
!-f The file does not exist
-d The directory exists
-e The file or directory exists
-x The file is executable
() and can be accessed later via $1-$9
set
7.2.7 Global variables that can be used
$http_cookie
$args
7.3 PCRE syntax! !
Transfer characters
^ Beginning of line
$ End of line
* Previous 0 or n times
+ Previous 1 or n times
? Previous 0 or 1 time
Various chestnuts
---------------------------------
19:56 2014-05-18
8. Module development
Experts learn from each other.
Configuration files include: main, server, upstream, location
Modules cannot be added dynamically and need to be compiled into a binary file at compile time.
handlers processing module
filters or green module
load-balancers load balancing module
8.1
module is equivalent to an aspect in aop and can be mounted on different processing events.
Don’t look down carefully.
---------------------------------
20:02 2014-05-18
9、 Cache
The famous Squid
proxy_cache instruction
ncache module developed by Sina.com, which makes full use of multi-core and is faster than Squid
20:29 2014-05-18
proxy_cache_path
proxy_cache_method
proxy_cache_valid
proxy_cache_key
./configure --add-module=../ngx_cache_purge-1.0
Create proxy_temp_path and proxy_cache_path must be in the same partition
--------------------- --------------------------
20:41 2014-05-18
10, Case
Sina Video
Jinshan Xiaoyao.com
CMS
Video website
rsync, check it out later.
---------------------------------
21:05 2014-05-18
11 , Atypical applications
HTTPS
./configure --with-http_ssl_module
Spontaneous certificate
Create private key
openssl genrsa -des3 -out api.bz.key 1024
openssl req -new -key aop.bz.key -out api.bz.csr
openssl rsa -in api.bz.key -out api.bz_nopass.key
Create certificate
openssl req -new -x509 - days 3650 -key api.bz_nopass.key -out api.bz.crt
Get the private key file: api.bz_nopass.key
Certificate: api.bz.crt
server{
ssl on;
ssl_certificate api.bz.crt;
ssl_certificate_key api.bz_nopass.key; Apply for a certificate
Similarly, generate a private key
http://startssl.com provides free certificates.
FLV video server
HTTP download, or streaming (Flash Media Server/RTMP)
nginx provides flv stream module, supports dragging
./configure --with-http_flv_module
limit_rate_after 3m
limit_rate 512k
Add keyframes
Find a flv player
Streaming fms/red5 load balancing
VPS (Virtual Private Server) virtual machine
The biggest indicator is memory.
Forward Agent
---------------------------------
21:27 2014- 05-18
12. Core module
---------------------------------21: 34 2014-05-18
13. Standard HTTP module
--------------------------------- 21:53 2014-05-18
14. Other modules
12, 13, and 14 are reference manuals, which should be read carefully and kept for reference at any time. ---------------------------------
21:55 2014-05-18
15 , Email module
This is also very practical! Book 2:
Quickly read the first 3 chapters of "In-depth understanding of Nginx: Module development and architecture analysis
".
Chapter 1 InstallationIt’s very detailed. Let’s read it on the way to work tomorrow.
Chapter 2 Configuration
Very detailed!
Chapter 3 How to write HTTP module
It’s too detailed. If you follow it, you can make a Hello, world! Why do I have the urge to write c.
nginx’s design and code are great, I really want to take a closer look.
It’s a pity that the time is difficult to arrange.
Everything you give up must be gained.
Book3, "Learning nginx http server"
Damn it!
Even basic Linux commands are taught, starting with mkdir.
A must-read for beginners! !
I really don’t know how to create a user group, I should find time to take a closer look.
Ch1 Basic linux operation
Ch2 Installation 22:11 2014-05-18
Ch3 Configuration 22:12 2014-05-18
Ch4 HTTP configuration 22:13 2014-05-18
Ch5 module configuration 22:14 2014-05-18
Ch6 PHP, Python 22:15 2014-05-18
Ch7 Apache
Ch8 Ported from Apache
22:17 2014-05-18 Eat I took cold medicine and was almost exhausted.
The above is an introduction to nginx reading notes, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.