1 源码包下载并解压
[root@server1 ~]# ls
nginx-1.12.0 nginx-1.12.0.tar.gz
2 建立nginx用户
[root@server1 ~]# useradd -M -d /usr/local/lnmp/nginx -s /sbin/nologin -u 800 nginx
(-M 不要自动建立用户的登入目录;
-d<登入目录>:指定用户登入时的启始目录;
-s<shell>:指定用户登入后所使用的shell;)
3 ./configure (主要的作用是对即将安装的软件进行配置,检查当前的环境是否满足要安装软件的依赖关系)
[root@server1 ~]# cd nginx-1.12.0
[root@server1 nginx-1.12.0]# ls
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
[root@server1 nginx-1.12.0]# ./configure --prefix=/usr/local/lnmp/nginx --user=nginx --group=nginx --with-threads --with-file-aio --with-http_ssl_module --with-http_stub_status_module 添加所需模块
[root@server1 nginx-1.12.0]# yum install -y pcre-devel openssl-devel 安装依赖包后,再次./configure
4. 编译安装
[root@server1 nginx-1.12.0]# make && make install
5 查看
[root@server1 sbin]# netstat -antlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9046/nginx
[root@server1 sbin]# curl -I localhost
HTTP/1.1 200 OK
Server: nginx/1.12.0 (服务器安装成功)
Date: Mon, 08 Jan 2018 03:16:07 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Mon, 08 Jan 2018 03:12:53 GMT
Connection: keep-alive
ETag: "5a52e1b5-264"
Accept-Ranges: bytes