nginx windows 下安装和配置

ゝ一纸荒年。 2022-09-19 05:17 376阅读 0赞

转:http://blog.csdn.net/ajun_studio/article/details/8066550

下载地址:http://nginx.org/download/nginx-1.2.4.zip

下载后直接解压到你的硬盘上,我的是d:\nginx

启动nginx

cd d:

cd nginx-1.2.4

start nginx

查看任务任务管理器里面会有nginx的进程

在浏览器输入http://127.0.0.1 此时会出现nginx的欢迎界面,说明启动nginx成功。

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

其他操作:

nginx -s stop // 停止nginx
nginx -s reload // 重新加载配置文件
nginx -s quit // 退出nginx

配置文件:

  1. [plain] view plaincopyprint?
  2. #user nobody;
  3. worker_processes 1;#启动的线程数:一本内核的数目*2
  4. [plain] view plaincopyprint?
  5. #错误的位置和级别
  6. #error_log logs/error.log;
  7. #error_log logs/error.log notice;
  8. #error_log logs/error.log info;
  9. #pid logs/nginx.pid;#pid进程文件的位置
  10. events {
  11. worker_connections 1024;#每个进程的最大连接数
  12. }
  13. http {
  14. include mime.types;
  15. default_type application/octet-stream;
  16. #nginx日志格式定义,在下面可以进行引用
  17. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  18. # '$status $body_bytes_sent "$http_referer" '
  19. # '"$http_user_agent" "$http_x_forwarded_for"';
  20. #access_log logs/access.log main;#日志路径
  21. sendfile on;
  22. #tcp_nopush on;
  23. #keepalive_timeout 0;
  24. keepalive_timeout 65;#请求时间
  25. #gzip on;开启gzip压缩
  26. #server为设置的虚拟机,可以设多个
  27. server {
  28. listen 80;#监听的端口
  29. server_name localhost;#监听的域名
  30. #charset koi8-r;
  31. #access_log logs/host.access.log main;#该虚拟机日志存放的位置
  32. location / {
  33. root html;
  34. index index.html index.htm;
  35. }
  36. #error_page 404 /404.html;
  37. # redirect server error pages to the static page /50x.html
  38. #
  39. error_page 500 502 503 504 /50x.html;
  40. location = /50x.html {
  41. root html;
  42. }
  43. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  44. #
  45. #location ~ \.php$ {
  46. # proxy_pass http://127.0.0.1;
  47. #}
  48. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  49. #
  50. #location ~ \.php$ {
  51. # root html;
  52. # fastcgi_pass 127.0.0.1:9000;
  53. # fastcgi_index index.php;
  54. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  55. # include fastcgi_params;
  56. #}
  57. # deny access to .htaccess files, if Apache's document root
  58. # concurs with nginx's one
  59. #
  60. #location ~ /\.ht {
  61. # deny all;
  62. #}
  63. }
  64. # another virtual host using mix of IP-, name-, and port-based configuration
  65. #
  66. #server {
  67. # listen 8000;
  68. # listen somename:8080;
  69. # server_name somename alias another.alias;
  70. # location / {
  71. # root html;
  72. # index index.html index.htm;
  73. # }
  74. #}
  75. # HTTPS server
  76. #
  77. #server {
  78. # listen 443;
  79. # server_name localhost;
  80. # ssl on;
  81. # ssl_certificate cert.pem;
  82. # ssl_certificate_key cert.key;
  83. # ssl_session_timeout 5m;
  84. # ssl_protocols SSLv2 SSLv3 TLSv1;
  85. # ssl_ciphers HIGH:!aNULL:!MD5;
  86. # ssl_prefer_server_ciphers on;
  87. # location / {
  88. # root html;
  89. # index index.html index.htm;
  90. # }
  91. #}
  92. }

linux下:

启动nginx:

/安装目录/nginx -c 配置文件的目录,-c用于加载配置文件,默认是在 安装目录下conf/nginx.conf

推出或者停止nginx:

强制停止:kill -9 nginx

从容停止:kill -QUIT `cat nginx pid所在目录`

快速停止:kill -TERM `cat nginx pid所在目录`或kill -INT `cat nginx pid所在目录`

平滑重启:kill -HUA `cat nginx pid所在目录`(平滑重启需检查配置文件是否正确:/安装目录/nginx -t -c)

发表评论

表情:
评论列表 (有 0 条评论,376人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Windows安装Nginx

    前言 Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第

    相关 Windows安装Nginx

    Nginx nginx是一款开源的HTTP服务器和反向代理服务器,nginx可以作为Web服务器提供HTTP访问功能,类似于Apache、IIS等。目前nginx已经在国