nginx linux安装

1、安装工具包 wget、vim和gcc

yum install -y wget  
yum install -y vim-enhanced  
yum install -y make cmake gcc gcc-c++ 

2、下载nginx安装包

wget http://nginx.org/download/nginx-1.6.3.tar.gz

3、安装依赖包

yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

4、解压nginx-1.6.3.tar.gz到/usr/local/目录下

tar -zxvf nginx-1.6.3.tar.gz -C /usr/local/

5、进行configure配置

进入nginx-1.6.3目录然后在执行./configure命令

[root@demo nginx-1.6.3]# ./configure --prefix=/usr/local/nginx

6、编译安装

[root@demo nginx-1.6.3]# make && make install

7、启动Nginx,启动完之后检查nginx是否已经正常启动,看到如下信息说明正常启动

[root@demo nginx-1.6.3]# /usr/local/nginx/sbin/nginx
[root@demo nginx-1.6.3]# ps -ef | grep nginx
root      8692     1  0 19:26 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody    8693  8692  0 19:26 ?        00:00:00 nginx: worker process      
root      8946 22540  0 19:26 pts/0    00:00:00 grep nginx
[root@demo nginx-1.6.3]# 

如果要关闭nginx,我们可以使用如下命令:

[root@demo nginx-1.6.3]# /usr/local/nginx/sbin/nginx -s stop

如果想要重新热启动nginx,则使用如下命令:

[root@demo nginx-1.6.3]# /usr/local/nginx/sbin/nginx -s reload

如出现以下错误,请执行:

[root@demo nginx-1.6.3]# /usr/local/nginx/sbin/nginx -s reloadnginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)

[root@demo nginx-1.6.3]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

8、开机自动启动

即在/etc/rc.local增加启动代码就可以了。

增加一行:

/usr/local/nginx/sbin/nginx

授权:

[root@demo nginx-1.6.3]# chmod 755 /etc/rc.local
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值