详解Nginx安装与配置

2023-11-28 0 823

Nginx是一个高性能的HTTP反向代理服务器。特点是占用内存少,并发能力强。实际上Nginx的并发能力是同类的网页服务器中最好的。

简单安装

本教程一Centos 6.3为例讲解,软件包可以在官方网站下载,编译安装之前,我们需要使用YUM提前将所需的软件依赖包安装完成。

安装命令如下:

[root@centos6 ~]# wget http://nginx.org/download/nginx-1.4.0.tar.gz
[root@centos6 ~]# tar -xzf nginx-1.4.0.tar.gz -C /usr/src
[root@centos6 ~]# yum -y install gcc pcre pcre-devel openssl \
>openssl-devel gd gd-devel perl perl-ExtUtils-Embed
[root@centos6 ~]# cd /usr/src/nginx-1.4.0/
[root@centos6 nginx-1.4.0]# ./configure --prefix=/usr/local/nginx \
>--with-ipv6 \
>--with-http_ssl_module \
>--with-http_realip_module \
>--with-http_addition_module \
>--with-http_dav_module \
>--with-http_flv_module \
>--with-http_mp4_module \
>--with-http_gzip_static_module \
>--with-http_perl_module \
>--with-mail \
>--with_main_ssl_module
[root@centos6 nginx-1.4.0]# make && make install

Nginx Web服务器软件安装完成后,程序主目录位于/usr/local/nginx/,该目录下的内容分别为cong、html、logs、sbin。下面是Nginx常用的进程管理指令:

[root@centos6 ~]# /usr/local/nginx/sbin/nginx          #启动主程序
[root@centos6 ~]# /usr/local/nginx/sbin/nginx -c  \         #指定配置文件启动主程序
[root@centos6 ~]# /usr/local/nginx/sbin/nginx -s stop       #关闭主程序
[root@centos6 ~]# /usr/local/nginx/sbin/nginx -s reload     #重新加载设置

配置文件解析

Nginx默认的配置文件为/usr/local/nginx/conf/nginx.conf,配置文件包括全局、event、http、server设置,event主要用来定义Nginx工作模式,http提供Web功能,server用来设置虚拟主机,server必须位于http内部,一个配置文件中可以有多个server。

本文来源:www.lxlinux.net/11056.html,若引用不当,请联系修改。

相关文章

猜你喜欢
官方客服团队

为您解决烦忧 - 24小时在线 专业服务

  • 0 +

    访问总数

  • 0 +

    会员总数

  • 0 +

    文章总数

  • 0 +

    今日发布

  • 0 +

    本周发布

  • 4975 +

    运行天数

你的前景,远超我们想象