良许Linux教程网 干货合集 详解Nginx安装与配置

详解Nginx安装与配置

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

image-20220904222601141

简单安装

本教程一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。

以上就是良许教程网为各位朋友分享的Linu系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !

137e00002230ad9f26e78-265x300
本文由 良许Linux教程网 发布,可自由转载、引用,但需署名作者且注明文章出处。如转载至微信公众号,请在文末添加作者公众号二维码。
良许

作者: 良许

良许,世界500强企业Linux开发工程师,公众号【良许Linux】的作者,全网拥有超30W粉丝。个人标签:创业者,CSDN学院讲师,副业达人,流量玩家,摄影爱好者。
上一篇
下一篇

发表评论

联系我们

联系我们

公众号:良许Linux

在线咨询: QQ交谈

邮箱: yychuyu@163.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部