Nginx-windows under Nginx Basic installation and configuration

Source: Internet
Author: User
Nginx is a lightweight, high-performance Http WebServer, written in an event-driven manner, so nginx is more stable, better performing, simpler to configure, and less resource-intensive than Apache.
1. Installing Nginx
from v0.7.52 onwards, Nginx started to release the Windows version of Nginx, you can download on its official website: http://nginx.net
after downloading, unzip directly, here unzip to C:\nginx directory.
2. Start Nginx
The command line enters the C:\nginx directory, runs Nginx.exe, and starts the console window. Port 80 is enabled by default. People who have used Tomcat want to be able to see the boot log in the console, and the Nginx log has to look at the corresponding log file in the logs directory.
3. Visit the Welcome HTML page
by accessing http://localhost in the browser, you can see the default welcome page.
4. Stop Nginx
Ctrl + C didn't respond. The console window is then closed. But the re-visit to http://localhost still works. Review the process and discover that Nginx was not shut down at all. So if you want to shut down nginx completely, it should be

Command code

    1. Nginx-s stop


Please refer to the official documentationNginx/windows usage
or use the Windows Taskkill command:

Command code

    1. taskkill/f/im nginx.exe > nul


5. Ngnix Common Configuration
all Nginx configurations use the conf/nginx.conf file by default, which is equivalent to the Apache httpd.conf file. When running the Nginx.exe implication runs the nginx-c conf\nginx.conf. If you want to use your own defined conf file such as my.conf, the command is Nginx-c conf\my.conf.
common configurations are as follows:

nginx.conf Code

  1. HTTP {
  2. server {
  3. #1. Listen for Port
  4. Listen ;
  5. Location/{
  6. # 2. The default home directory is the HTML subdirectory of the Nginx installation directory.
  7. root HTML;
  8. Index index.html index.htm;
  9. # 3. Lists files and subdirectories when no index pages are available
  10. AutoIndex on;
  11. Autoindex_exact_size on;
  12. Autoindex_localtime on;
  13. }
  14. # 4. Specify the virtual directory
  15. Location/tshirt {
  16. Alias D:\programs\Apache2\htdocs\tshirt;
  17. Index index.html index.htm;
  18. }
  19. }
  20. # 5. Virtual Host Www.emb.info Configuration
  21. server {
  22. Listen ;
  23. server_name www.emb.info;
  24. Access_log Emb.info/logs/access.log;
  25. Location/{
  26. Index index.html;
  27. Root Emb.info/htdocs;
  28. }
  29. }
  30. }


Tips:
run nginx-v to see which modules are supported by the WIN32 platform's compiled version. My results here are:

Log Code

  1. Nginx version:nginx/0.7. $
  2. TLS SNI Support Enabled
  3. Configure arguments:
  4. --builddir=objs.msvc8
  5. --crossbuild=win32
  6. --with-debug--prefix=
  7. --conf-path=conf/nginx.conf
  8. --pid-path=logs/nginx.pid
  9. --http-log-path=logs/access.log
  10. --error-log-path=logs/error.log
  11. --sbin-path=nginx.exe
  12. --http-client-body-temp-path=temp/client_body_temp
  13. --http-proxy-temp-path=temp/proxy_temp
  14. --http-fastcgi-temp-path=temp/fastcgi_temp
  15. --with-cc-opt=-dfd_setsize=1024x768
  16. --with-pcre=objs.msvc8/lib/pcre-7.9
  17. --with-openssl=objs.msvc8/lib/openssl-0.9. 8k
  18. --with-openssl-opt=enable-tlsext
  19. --with-zlib=objs.msvc8/lib/zlib-1.2. 3
  20. --with-select_module
  21. --with-http_ssl_module
  22. --with-http_realip_module
  23. --with-http_addition_module
  24. --with-http_sub_module
  25. --with-http_dav_module
  26. --with-http_stub_status_module
  27. --with-http_flv_module
  28. --with-http_gzip_static_module
  29. --with-http_random_index_module
  30. --with-http_secure_link_module
  31. --with-mail
  32. --with-mail_ssl_module
  33. --with-ipv6


Obviously, the most frequently used memcache, rewrite modules are not in it, so the Win32 compiled version can only be used for basic development testing, for the product platform, you should recompile the Win32 version you want, or more convenient to use under Linux.

The above describes the basic installation and configuration of Nginx-windows Nginx, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    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.