NGINX源码安装

1.nginx介绍

Nginx (engine x) 是一个轻量的,高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 服务 器。Nginx 是由伊戈尔 · 赛索耶夫所研发,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的 消耗而闻名。
其特点是占有内存少,并发能力强, nginx 的并发能力在同类型的网页服务器中表现较好,中国大陆使 用nginx 网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。
在高连接并发的情况下, Nginx Apache 服务器不错的替代品。

 

2,nginx编译安装

上传nginx包 nginx-1.12.2.tar.gz

   1.安装nginx依赖

    yum install lrzsz gcc gcc-c++ pcre-devle zlib-devel

  2.解压nginx包

    tar -xvf nginx-1.12.2.tar.gz

 3.配置和检测环境

 ./configure --prefix=/usr/local/nginx  #配置nginx安装目录

 这种报错就是确实pcre库,,一般就是因为没有安装 

yum install pcre-devel 安装一下就好

.

4. 编译 安装

make && make install

5. 启动nginx 

[root@localhost nginx-1.12.2]# /usr/local/nginx/sbin/nginx 
[root@localhost nginx-1.12.2]# netstat -pltun|grep nginx 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      16659/nginx: master 

6.关闭防火墙,访问

7.做软连接

[root@localhost nginx-1.12.2]# ln -sv /usr/local/nginx/sbin/nginx  /usr/bin/nginx 
‘/usr/bin/nginx’ -> ‘/usr/local/nginx/sbin/nginx’
[root@localhost nginx-1.12.2]# ln -sv /usr/local/nginx/sbin/nginx /usr/bin/nginx

可以直接启动nginx
[root@localhost nginx-1.12.2]# nginx 
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

8.启停检测语法

nginx -t   检测nginx是否正常 出现isoknginx 即可
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx
: configuration file /usr/local/nginx/conf/nginx.conf test is successful
停止nginx

[root@localhost nginx-1.12.2]# nginx -s stop

netstat  -pltu|grep nginx 查看端口是否存在

nginx -s reload  #当子配置文件发生变化,重新载入配置文件  这个报错是因为没有启动nginx
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)

nginx

nginx -s reload

下一章节 nginx负载均衡+反向代理

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值