Nginx的使用

来源:互联网 发布:数据库物理设计图visio 编辑:程序博客网 时间:2024/06/07 02:28

        Nginx可作为web服务器,反向代理服务器,电子邮件代理服务器.

一 安装nginx

         1.yum -y install pcre-devel openssl openssl-devel

         2.到官方网站下载Nginx并安装

                         http://nginx.org/en/download.html

         3.启动nginx 

            #   /usr/local/nginx/sbin/nginx 

         4.访问http://localhost.

二 .查看nginx配置文件地址

         1.执行 /usr/local/nginx/sbin/nginx -t

               nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

             可知默认的配置文件是/usr/local/nginx/conf/nginx.conf

        2 执行 /usr/local/nginx/sbin/nginx -v   查看版本

         3 执行 /usr/local/nginx/sbin/nginx -V   查看版本和配置文件

         4. /usr/local/nginx/sbin/nginx  -s reload    重新load配置文件

          5  /usr/local/nginx/sbin/nginx  -t    检查配置文件是否正确 

三 nginx配置文件

    配置文件结构

 

...              #全局块events {         #events块   ...}http      #http块{    ...   #http全局块    server        #server块    {         ...       #server全局块        location [PATTERN]   #location块        {            ...        }        location [PATTERN]         {            ...        }    }    server    {      ...    }    ...     #http全局块}

0 0