Home > Backend Development > PHP Tutorial > Installation and use of nginx nginx apache nginx php nginx rewrite

Installation and use of nginx nginx apache nginx php nginx rewrite

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 08:48:58
Original
1063 people have browsed it
Blocking call: If the event is not ready, you can only wait. When the event is ready, you can continue.
Blocking calls will enter the kernel and wait, and the CPU will be used by others. It is obviously not suitable for single-threaded workers. When there are more network events, everyone is waiting, and no one will use the CPU when it is idle. Naturally, the utilization rate cannot go up, let alone high concurrency.
Asynchronous non-blocking: Asynchronous non-blocking event processing mechanism, specific system calls are system calls like select/poll/epoll/kqueue.
They provide a mechanism that allows you to monitor multiple events at the same time. Calling them is blocking, but you can set a timeout. Within the timeout, if an event is ready, it will return.
tar -zxvf nginx.tar.gz
./configure
linux install gcc,gcc-c++
yum -y install gcc gcc-c++ autoconf automake
install pcre
yum -y install pcre pcre-devel
install zlib
yum - y install zlib zlib-devel
make
make install
Start the nginx server
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
Stop the nginx server
1. Stop gracefully
kill -QUIT 15369
2. Quick stop
kill -TERM 15417
kill -INT 15417
3. Force stop
pkill -9 nginx
4. Verify the correctness of the configuration file
./nginx -t
./nginx -t -c /usr/local/nginx/conf/nginx.conf
5.nginx Restart
./nginx -s reload (enter the directory)
kill -HUP 15446
6.USR1: Switch log files
USR2: Smooth upgrade Executable process
WINCH: Shut down the working process gracefully (kill -WINCH 2255)
7. View the version
./nginx -V
#Set the user
#user nobody
#The number of work-derived processes (equal to the number of cores of the cpu or 2 times Number of cores)
worker_processes 6;
#Set the path where pid is stored
#pid logs/nginx.pid;
//Maximum number of connections
events {
worker_connections 1024;
}
#Turn on gzip (user access is compression (original 30%))
#gzip on
#Set character encoding
charset koi8-r;
charset gb2312;
nginx configuration file abstraction (instance)
user nobody;
worker_processes 4;
events{
worker_connections 1024;
}
http{
server{
listen 192.168.1.7:80;
server_name 192.168.1.7;
access_log logs/server1.access.log.combined;
location /
{
index index.html index.htm ;
root html/server1;
}
}
server{
listen 192.168.1.8:80;
server_name 192.168.1.17;
access_log logs/server2.access.log.combined;
location /
{
index index.html index.htm;
root html/server2;
}
}
}
Set the ip address and subnet mask of the host
ifconfig eth1 192.168.1.10 netmask 255.255.255.0
Set the ip address and broadcast address of the virtual host (subserver) and subnet mask
ifconfig eth1:1 192.168.1.7 broadcast 192.168.1.255 netmask 255.255.255.0
Virtual host configuration: After configuring the IP address, we need to establish contact between the corresponding IP address and the corresponding virtual host
log_format The command is used to set the recording format of the nginx server's log file.
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '"$http_user_agent" "$ http_x_forwarded_for"';

remote_addr : ip address
remote_user : user
request : requested URL
status : status
body_bytes_sent : number of bytes transferred
http_referer: original page
http_user_agent : browser (client)
http_x_forwarded_for: similar ip
//Modify nginx default configuration file
vi /usr/local/nginx/conf/nginx.conf
access_log storage path
/*****************nginx implements load balancing*************************/
user nobody;
worker_processes 4;
events{
worker_connections 1024. 0.96.12.1;
                                                                                                                                                                                using using using       using using         through using ’ ’ s using ’ s ’ through ’ s ‐    ‐                                                            
                                                                                                                           listen 8080;
                  location /
                           }


}

/*****************nginx implements load balancing*************************/



The above introduces the installation and use of nginx, including nginx content. I hope it will be helpful to friends who are interested in PHP tutorials.


Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Error restarting nginx
From 1970-01-01 08:00:00
0
0
0
server - Nginx configuration webapp problem
From 1970-01-01 08:00:00
0
0
0
Nginx default.conf problem
From 1970-01-01 08:00:00
0
0
0
centos7 - NGINX exception occurs
From 1970-01-01 08:00:00
0
0
0
nginx load balancing
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template