Configure and start Nginx and do local directory mapping under Windows

Source: Internet
Author: User
Tags memory usage

1. View the Nginx process

Tasklist/fi "imagename eq nginx.exe", shown below:
Image name PID session name Session # Memory usage
========================= ======== ================ =========== ============
Nginx.exe 8944 Console 1 5,128 K
Nginx.exe 6712 Console 1 5,556 K

2, Nginx Common command

Nginx-s stop forced shutdown
Nginx-s quit safe shutdown
Nginx-s Reload Change the configuration file, restart the Nginx worker process, when the configuration file comes into effect
Nginx-s Reopen open log file

3. Other
You can open multiple Nginx worker processes through a configuration file, but at the same time only one of the Nginx worker processes are working and other blocking waits.
A nginx worker process can handle up to 1024 connections at the same time.
Cache or modules that require shared memory in nginx cannot be used properly under Windows.
However, nginx officials are improving, and in the future Nginx will run as a service, using I/O completion ports instead of the Select method, enabling multiple worker processes to work concurrently.
To use Nginx with php-cgi, you need to modify the environment variables, otherwise, php-cgi run a certain number of launches, need to restart, set php_fcgi_max_requests this variable is 0.

The above is passed on the Win7.


4, directly posted the entire configuration file, the red part is the focus:


#user nobody;
Worker_processes 1;


Error_log Logs/error.log;
Error_log Logs/error.log Notice;
Error_log Logs/error.log Info;


PID Logs/nginx.pid;




Events {
Worker_connections 1024;
}




HTTP {
Include Mime.types;
Default_type Application/octet-stream;


Log_format Main ' $remote _addr-$remote _user [$time _local] ' $request '
' $status $body _bytes_sent ' $http _referer '
' $http _user_agent ', ' $http _x_forwarded_for ';


Access_log Logs/access.log Main;


Sendfile on;
#tcp_nopush on;


#keepalive_timeout 0;
Keepalive_timeout 65;


#gzip on;


server {
Listen 88;
server_name localhost;


#charset Koi8-r;


#access_log Logs/host.access.log Main;


Location/{
root HTML;
Index index.html index.htm;
}
location/attached {
root/;
Rewrite ^/image/(. *) $/attached/$1 break; #这里很重要, rewrite is the real jump rule that enables Nginx to access folders that are not located in the Nginx root directory
AutoIndex on; #启用目录索引功能
Autoindex_exact_size off; #关闭详细文件大小统计, let the file size display MB,GB units, the default is B;
Autoindex_localtime on; #开启以服务器本地时区显示文件修改日期.
}

#location/attached set up the server to intercept the request containing/attached, in fact, determine the accuracy according to the actual situation

#root/; Set the role of the root directory, rewrite is the real jump rule, set the request to start with the image to jump to the beginning of the/image root directory, the subsequent parameters are added to the past, so that the map of the directory to achieve,

#使用上面的规则可以很方便的映射到本地指定的多个用于静态访问的目录

#保存之后使用./nginx-s reload the configuration file, accessing the specified URL and accessing the


#error_page 404/404.html;


# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}


# Proxy The PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# Proxy_pass http://127.0.0.1;
#}


# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root HTML;
# Fastcgi_pass 127.0.0.1:9000;
# Fastcgi_index index.php;
# Fastcgi_param Script_filename/scripts$fastcgi_script_name;
# include Fastcgi_params;
#}


# Deny access to. htaccess files, if Apache ' s document Root
# concurs with Nginx ' s one
#
#location ~/\.ht {
# Deny All;
#}
}




# Another virtual host using mix of ip-, name-, and port-based configuration
#
#server {
# Listen 8000;
# Listen somename:8080;
# server_name somename alias Another.alias;


# location/{
# root HTML;
# index index.html index.htm;
#    }
#}




# HTTPS Server
#
#server {
# Listen 443 SSL;
# server_name localhost;


# ssl_certificate Cert.pem;
# Ssl_certificate_key Cert.key;


# Ssl_session_cache shared:ssl:1m;
# ssl_session_timeout 5m;


# ssl_ciphers high:!anull:! MD5;
# ssl_prefer_server_ciphers on;


# location/{
# root HTML;
# index index.html index.htm;
#    }
#}


}

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.