linux安装nginx一键,51CTO博客-专业IT技术博客创作平台-技术成就梦想

系统版本

CentOS release 6.9 (Final)

2.6.32-696.el6.x86_64 x86_64

#安装pcre pcre-devel

[root@web01 ~]# yum install pcre pcre-devel -y

#检查pcre pcre-devel

[root@web01 ~]# rpm -qa pcre pcre-devel

pcre-7.8-7.el6.x86_64

pcre-devel-7.8-7.el6.x86_64

#安装openssl-devel,使用nginx必须安装这个软件来支持

[root@web01 nginx-1.6.3]# yum install openssl-devel -y

#检查openssl-devel openssl

[root@web01 nginx-1.6.3]# rpm -qa openssl-devel openssl  #检查openssl-devel openssl

openssl-1.0.1e-57.el6.x86_64

openssl-devel-1.0.1e-57.el6.x86_6

#添加用户

useradd oldboy

#创建tools目录

mkdir /home/oldboy/tools

cd /home/oldboy/tools/

#下载nginx,具体需要什么版本自己可以到 http://nginx.org官网下载

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

#查看到下载的nginx

[root@web01 tools]# ll

总用量 788

-rw-r--r-- 1 root root 805253 4月   8 2015 nginx-1.6.3.tar.gz

#解压压缩包

[root@web01 tools]# tar xf nginx-1.6.3.tar.gz

#cd到nginx-1.6.3目录下

cd nginx-1.6.3

#创建application目录存放软件

mkdir /application

#创建虚拟用户

[root@web01 application]# useradd www -s /sbin/nologin -M

#编译安装nginx

./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3/

#查看编辑是否成功

[root@web01 nginx-1.6.3]# echo $?   #返回

0表示配置成功

0

bae293383972405c31a813893bb73291.png

[root@web01 nginx-1.6.3]# make    #返回0直接就用make编译

cec8c49a65b497afae79baf4a61f082d.png

同样是echo $?是返回0正常

#安装

[root@web01 nginx-1.6.3]# make install

#安装完成之后,为了以后更新软件方便,需要创建一个软链接给nginx

[root@web01 nginx-1.6.3]# ln -s /application/nginx-1.6.3/ /application/nginx

[root@web01 nginx-1.6.3]# cd /application/

[root@web01 application]# ll

总用量 4

lrwxrwxrwx 1 root root   25 2月  27 11:13 nginx -> /application/nginx-1.6.3/

drwxr-xr-x 6 root root 4096 2月  27 11:12 nginx-1.6.3

#启动nginx

[root@web01 application]# /application/nginx/sbin/nginx

[root@web01 ~]# /application/nginx/sbin/nginx -t   #检查语法对不对

1. 1. nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful

[root@web01 application]# netstat -lntup |grep 80   #查看nginx端口是否启动

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      45878/nginx

在自己浏览器查看是否成功

66f0120bf3c83fa9c6e16bfdcafe2e90.png

一键安装命令如下:

[root@web01 scripts]# cat nginx.sh

#!/bin/bash

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

LANG=en

yum install pcre pcre-devel -y

yum install openssl-devel -y

useradd oldboy

mkdir /home/oldboy/tools

cd /home/oldboy/tools/

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

tar xf nginx-1.6.3.tar.gz

cd nginx-1.6.3

mkdir /application

useradd www -s /sbin/nologin -M

./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3/

echo $?

make

echo $?

make install

ln -s /application/nginx-1.6.3/ /application/nginx

cd /application/

/application/nginx/sbin/nginx

/application/nginx/sbin/nginx -t

netstat -lntup |grep 80

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值