27°

nginx编译安装

官网地址:
https://nginx.org/

1、下载安装包 & 解压: 下载地址 https://nginx.org/en/download.html [root@localhost software]# wget https://nginx.org/download/nginx-1.16.1.tar.gz --no-check-certificate [root@localhost software]# tar zxvf nginx-1.16.1.tar.gz [root@localhost software]# cd nginx-1.16.1

2、安装依赖: [root@localhost nginx-1.16.1]# yum install -y pcre pcre-devel openssl openssl-devel gcc-c++ zlib zlib-devel

3、创建用户:www [root@localhost nginx-1.16.1]# useradd www -M -s /sbin/nologin [root@localhost sbin]# id www uid=502(www) gid=502(www) groups=502(www)

4、配置nginx & 编译 & 安装 [root@localhost nginx-1.16.1]# ./configure --prefix=/usr/local/nginx
--user=www --group=www
--with-http_stub_status_module
--with-http_v2_module
--with-http_ssl_module

[root@localhost nginx-1.16.1]# make objs/src/http/modules/ngx_http_upstream_keepalive_module.o
objs/src/http/modules/ngx_http_upstream_zone_module.o
objs/src/http/modules/ngx_http_stub_status_module.o
objs/ngx_modules.o
-ldl -lrt -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lpthread -lz
-Wl,-E sed -e "s|%%PREFIX%%|/usr/local/nginx|"
-e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|"
-e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|"
-e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|"
< man/nginx.8 > objs/nginx.8 make[1]: Leaving directory `/opt/software/nginx-1.16.1'

[root@localhost nginx-1.16.1]# make install

5、启动nginx & 验证 [root@localhost nginx-1.16.1]# ls /usr/local/nginx/ conf html logs sbin [root@localhost nginx]# cd sbin/ [root@localhost sbin]# ./nginx [root@localhost sbin]# ps -ef|grep nginx root 22174 1 0 15:26 ? 00:00:00 nginx: master process ./nginx www 22175 22174 0 15:26 ? 00:00:00 nginx: worker process root 22177 10741 0 15:26 pts/2 00:00:00 grep nginx

[root@localhost test]# wget http://192.168.189.132 or 浏览器访问如下:

6.基础运维 启动 [root@localhost sbin]# ./nginx 停止 [root@localhost sbin]# ./nginx -s stop 重启 [root@localhost sbin]# ./nginx -s reopen 重新加载配置文件 [root@localhost sbin]# ./nginx -s reload

 

 

 

 

本文由【丁】发布于开源中国,原文链接:https://my.oschina.net/dingyibo/blog/3159035

全部评论: 0

    我有话说: