nginx服务

Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器 ,同时也提供了IMAP/POP3/SMTP服务。Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好。

安装nginx

安装前需要准备:

[root@elk01 ~]# yum install -y gcc-c++

[root@elk01 ~]# yum install -y pcre pcre-devel

[root@elk01 ~]# yum install -y zlib zlib-devel

[root@elk01 ~]# yum install -y openssl openssl-devel

上传下载好的安装包nginx-1.24.0.tar.gz

安装和编译nginx:

[root@elk01 src]# tar -xvf nginx-1.24.0.tar.gz 

[root@elk01 src]# cd /usr/local/src/nginx-1.24.0/

[root@elk01 nginx-1.24.0]# ./configure --prefix=/usr/local

[root@elk01 nginx-1.24.0]# make && make install

启动nginx:

[root@elk01 conf]# pwd
/usr/local/src/nginx-1.24.0/conf
[root@elk01 conf]# nginx -c /usr/local/src/nginx-1.24.0/conf
conf/ configure
[root@elk01 conf]# nginx -c /usr/local/src/nginx-1.24.0/conf/nginx.conf
[root@elk01 conf]# ps -ef|grep nginx
root 51788 1 0 10:38 ? 00:00:00 nginx: master process nginx -c /usr/local/src/nginx-1.24.0/conf/nginx.conf
nobody 51789 51788 0 10:38 ? 00:00:00 nginx: worker process
root 51791 48694 0 10:38 pts/1 00:00:00 grep --color=auto nginx

检查配置文件是否正确:

[root@elk01 conf]# nginx -t -c /usr/local/src/nginx-1.24.0/conf/nginx.conf
nginx: the configuration file /usr/local/src/nginx-1.24.0/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/src/nginx-1.24.0/conf/nginx.conf test is successful

平滑停止Nginx服务:

[root@elk01 conf]# nginx -s quit
[root@elk01 conf]# ps -ef|grep nginx
root 51833 48694 0 10:40 pts/1 00:00:00 grep --color=auto nginx

 

如果想安装Nginx其它模块,比如:

[root@elk01 nginx-1.24.0]# pwd
/usr/local/src/nginx-1.24.0

[root@elk01 nginx-1.24.0]# ./configure --prefix=/usr/local --with-http_stub_status_module

[root@elk01 nginx-1.24.0]# make & make install

 

posted on 2024-01-17 10:35  永远的大空翼  阅读(4)  评论(0编辑  收藏  举报