广州网站设计公司兴田德润电话多少链友咨询
什么是Nginx?
Nginx(发音同engine x)是一款由俄罗斯程序员Igor Sysoev所开发轻量级的网页服务器、反向代 理服务器以及电子邮件(IMAP/POP3)代理服务器。
Nginx 因具有高并发(特別是静态资源)、 占用系统资源少等特性,目.功能丰富而逐渐流行起来。 在功能应用方面,Nginx 不但是一个优秀的 Web 服务软件,还具有反向代理负载均衡功能和缓存 服务功能。
目录
安装
RMP包安装
1、获取RPM包
2、安装
3、查看版本,即安装成功
源码安装
1、获取地址
2、创建用户和组
3、安装
4、为nginx提供SysV init脚本
5、启动服务
6、浏览器查看
安装
RMP包安装
1、获取RPM包
Index of /packages/
2、安装
3、查看版本,即安装成功
源码安装
1、获取地址
Index of /download/ (nginx.org)
2、创建用户和组
[root@node2 ~]# groupadd -r nginx
[root@node2 ~]# grep nginx /etc/group
nginx:x:992:
[root@node2 ~]# useradd nginx -u 993 -r -g 992 -c "nginx user" -s /sbin/nologin
3、安装
[root@node2 ~]# yum install gcc gcc-c++ make -y
[root@node2 ~]# yum install -y pcre-devel openssl-devel #基础依赖包(重写、开发)
[root@node2 ~]# tar xf download/nginx-1.22.0.tar.gz -C /usr/local/
[root@node2 ~]# ll /usr/local/nginx-1.22.0/[root@node2 nginx-1.22.0]# ./configure \ #检查缺省依赖
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib64/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--user=nginx --group=nginx \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module --with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-stream --with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module编译并安装
[root@node2 nginx-1.22.0]# make && make install
4、为nginx提供SysV init脚本
[root@node2 ~]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)"
ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)"[Install]
WantedBy=multi-user.target
5、启动服务
[root@node2 ~]# systemctl daemon-reload
[root@node2 ~]# systemctl start nginx
Nginx 软件的主要企业功能应用
( 1 ) 作为 Web 服务软件
( 2 ) 反向代理或负载均衡服务
( 3 ) 前端业务数据缓存服务