Nginx installation and use of Nginx Apache nginx php nginx rewrite

Source: Internet
Author: User
Tags nginx server
Blocking call: The event is not ready, it will only wait, wait until the event is ready, you can continue.
Blocking calls into the kernel waits, the CPU will let go out to others, for the single-threaded workers, obviously inappropriate, when the network event more time, everyone is waiting, CPU idle No one use, CPU utilization naturally not go, not to talk about high concurrency.
Asynchronous non-blocking: asynchronous, non-blocking event handling mechanism, specifically to system calls such as Select/poll/epoll/kqueue.
They provide a mechanism that allows you to monitor multiple events at the same time, call them blocked, but you can set the timeout period, and return if an event is ready in the timeout period.
TAR-ZXVF nginx.tar.gz
./configure
Linux installation gcc,gcc-c++
Yum-y install gcc gcc-c++ autoconf automake
Installing Pcre
Yum-y Install Pcre Pcre-devel
Installing 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 Nginx Server
1. Calmly stop
Kill-quit 15369
2. Quick Stop
Kill-term 15417
Kill-int 15417
3. Force stop
Pkill-9 Nginx
4. Verifying the correctness of the configuration file
./nginx-t
./nginx-t-c/usr/local/nginx/conf/nginx.conf
5.nginx restart
./nginx-s reload (go to your directory)
Kill-hup 15446
6.USR1: Toggle Log File
USR2: Smooth Upgrade executable process
WINCH: Gracefully Close the worker process (Kill-winch 2255)
7. View version
./nginx-v
#设置用户
#user Nobody
#工作衍生进程数 (equals the number of cores or twice times the number of cores in the CPU)
Worker_processes 6;
#设置pid存放的路径
#pid Logs/nginx.pid;
Maximum number of connections
Events {
Worker_connections 1024;
}
#开启gzip on (the user is accessing a compressed file (the original 30%))
#gzip on
#设置字符编码
CharSet Koi8-r;
CharSet gb2312;
Abstraction of Nginx configuration file (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 host's IP address and subnet mask
Ifconfig eth1 192.168.1.10 netmask 255.255.255.0
Set the IP address and broadcast address and subnet mask of the virtual host (sub-server)
Ifconfig eth1:1 192.168.1.7 broadcast 192.168.1.255 netmask 255.255.255.0
Configuration of the virtual host: After configuring the IP address, we need to connect the corresponding IP address with the corresponding virtual host
The Log_format directive is used to set the record format of the Nginx server's log file
Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" "$http _x_forwarded_for";

Remote_addr:ip Address
Remote_user: User
Request: The requested URL
Status: State
Body_bytes_sent: Number of bytes transferred
Http_referer: Original page
Http_user_agent: Browser (client)
Http_x_forwarded_for: Similar IP
Modify the nginx default configuration file
Vi/usr/local/nginx/conf/nginx.conf
Access_log Storage Path
/*****************nginx for load Balancing *********************/
User nobody;
Worker_processes 4;
events{
Worker_connections 1024;
}
http{
Upstream myproject{
Ip_hash;
Server 115.239.210.27;
Server 180.96.12.1;
Server 42.156.140.7;
Server 140.205.230.49;
Server 122.225.67.253;
}
server{
Listen 8080;
Location/
{
Proxy_pass Http://myproject;
}
}


}

/*****************nginx for load Balancing *********************/

The above describes the installation and use of Nginx, including nginx aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.