linux下nginx安装

平台:centos
1.准备编译环境:gcc g++
安装make:

yum -y install gcc automake autoconf libtool make

安装g++:

yum -y install gcc automake autoconf libtool make

2.nginx一般需要用到重写rewrite和gzip压缩、ssl,所以要先安装prce、zlib、openssl
所以我先准备好了一下几个包:

openssl-1.0.1t.tar.gz
pcre-8.35.tar.gz
zlib-1.2.11.tar.gz

然后放到/usr/local/src目录(网上大多教程选择的,也可以是其他目录)

cd /usr/local/src

3.安装pcre

 tar -zxvf pcre-8.35.tar.gz
 cd pcre-8.35
 ./configure
 make
 make install

4.安装zlib

tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install

5.安装ssl,解压即可

tar -zxvf openssl-1.0.1t.tar.gz

6.安装nginx
其中
–with-pcre=/usr/local/src/pcre-8.35 \
–with-zlib=/usr/local/src/zlib-1.2.11 \
–with-openssl=/usr/local/src/openssl-1.0.1t
为各自软件安装的相应目录

tar -zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2

./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/usr/local/src/pcre-8.35 \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-openssl=/usr/local/src/openssl-1.0.1t

make
make install

7.可以用

netstat -ano|grep 80

查看80端口是否被占用
9.启动

sudo /usr/local/nginx/nginx

10.打开浏览器输入服务器ip访问到nginx即成功

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值