Nginx的安装与配置,Nginx安装配置


系统环境:

linuxboyECS Aliyun Linux 17.1 64 位

实验对象:

nginx

简介:Nginx(发音同engine x)是异步框架的 Web服务器,Nginx是免费的开源软件,根据类BSD许可证的条款发布。一大部分Web服务器使用Nginx, 通常作为负载均衡器。

  • Nginx可以部署在网络上使用FastCGI脚本、SCGI处理程序、WSGI应用服务器或Phusion乘客模块的动态HTTP内容,并可作为软件负载均衡器。
  • Nginx使用异步事件驱动的方法来处理请求。Nginx的模块化事件驱动架构[11]可以在高负载下提供更可预测的性能。
  • Nginx是一款面向性能设计的HTTP服务器,相较于Apache、lighttpd具有占有内存少,稳定性高等优势。

安装方法

  • 通过yum安装
  • 通过源码安装
  • 通过rpm安装
    yum安装方便简单,本次实验通过yum安装。Linux下执行命令yum install nginx即可,需要root权限。yum 安装

当显示:

Thanks for using nginx!

Please find the official documentation for nginx here:
* http://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:
* http://nginx.com/products/

----------------------------------------------------------------------
  Verifying  : 1:nginx-1.14.1-1.el7_4.ngx.x86_64                            1/1 

Installed:
  nginx.x86_64 1:1.14.1-1.el7_4.ngx                                             

Complete!

表明安装完成。

安装完毕检查

检查安装在哪里

  • 命令whereis

whereis niginx

nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz
  • 命令which

which nginx

/usr/sbin/nginx

检查安装版本

nginx -v

显示:nginx 版本

nginx启动与停止

  • 启动

systemctl start nginx

  • 停止

systemctl stop nginx

  • 重启

systemctl restart nginx

  • 开机自启

systemctl enable nginx

执行启动命令,命令执行后没有输出任何数据表示启动正常,在浏览器输入服务器ip即可访问,默认是80端口,所以需要配置linuxboy安全组规则,打开端口访问权限。
linuxboy安全组配置
浏览器访问:http://服务器ip/
访问结果

Nginx配置

通过yum安装的Nginx配置文件默认在/ect/nginx/下:
Nginx配置文件

Nginx卸载

yum安装的直接执行:

yum remove nginx

即可。

相关内容