运维的那点事

nginx源码安装

2019-05-12  本文已影响29人  无字天书

1,安装依赖包

[root@web50 ~]# yum -y install zlib-devel openssl-devel pcre-devel gcc make

2,nginx下载

官网地址:http://nginx.org/en/download.html

[root@web50 iso]# curl -O http://nginx.org/download/nginx-1.12.2.tar.gz

[root@web50 iso]# ls

nginx-1.12.2.tar.gz

3,解压安装

[root@web50 iso]# tar -xvf nginx-1.12.2.tar.gz

[root@web50 iso]# ls

nginx-1.12.2  nginx-1.12.2.tar.gz

[root@web50 nginx-1.12.2]# ./configure --help

--prefix=PATH

--user=USER

--group=GROUP

--with-http_ssl_module

--with-http_stub_status_module

--without-http_fastcgi_module disable ngx_http_fastcgi_module

  --without-http_uwsgi_module        disable ngx_http_uwsgi_module

--without-mail_pop3_module disable ngx_mail_pop3_module

  --without-mail_imap_module        disable ngx_mail_imap_module

  --without-mail_smtp_module        disable ngx_mail_smtp_module

..........

[root@web50 nginx-1.12.2]# useradd -s /sbin/nologin nginx

[root@web50 nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module

[root@web50 nginx-1.12.2]# make && make install

[root@web50 ~]# ls /usr/local/nginx/

conf  html  logs  sbin

[root@web50 ~]# ln -s /usr/local/nginx/sbin/nginx /sbin/       

[root@web50 ~]# nginx

[root@web50 ~]# ss -tunlp | grep :80

tcp    LISTEN    0      128      *:80                    *:*                  users:(("nginx",pid=3816,fd=6),("nginx",pid=3815,fd=6))

提示:

[root@web50 ~]# nginx

[root@web50 ~]# nginx -s reload

[root@web50 ~]# nginx -s stop

4,验证

注意关闭防火墙:

[root@web50 ~]# iptables -F

[root@web50 ~]# systemctl stop firewalld

[root@web50 ~]# curl http://127.0.0.1

<!DOCTYPE html>

<html>

<head>

<title>Welcome to nginx!</title>

........

</html>

或者打开浏览器输入

http://127.0.0.1


看官福利:


结束语:

更多精彩内容持续更新中,关注我,有你更精彩。

上一篇下一篇

猜你喜欢

热点阅读