2019-10-16-Nginx使用

Nginx使用

Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。

Windows下的安装部署

  1. 下载软件

链接,Nginx下载地址

  1. 解压启动

使用cmd命令行启动,start nginx

可能没有反馈提示,这时可以查看任务管理器是否有Nginx进程

  1. 验证

访问lovalhost:80

页面内容:

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.

Linux下安装部署

  1. 添加repo文件
vi /etc/yum.repos.d/nginx.repo
  1. 搜索nginx

    yum search nginx
    
  2. 安装nginx

    yum install nginx -y
    
  3. 启动

    systemctl start nginx
    
  4. 关闭防火墙(或者开放端口)

    systemctl stop firewalld
    
  5. 访问验证 浏览器访问http://192.168.200.128/

输出内容:

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.

配置文件

配置文件在/etc/nginx/nginx.conf,按照需要的配置填写