linux下安装nginx

 因为nginx的安装需要依赖其他库,所以要先安装依赖库。以下是具体步奏

 

http://nginx.org/download/nginx-1.2.8.tar.gz

 1.安装PCRE库
cd /usr/local/
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
tar -zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure
make && make install


注意:因为有些64位机器需要加入一下软连接nginx才能读取得到
ln -s /usr/local/lib/libpcre.so.1 /lib64/


2.安装zlib库
cd /usr/local/
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz 
cd zlib-1.2.8
./configure
make && make install
 
3.安装ssl
方法一:
yum -y install openssl openssl-devel
方法二:
cd /usr/local/
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz
./config
make && make install

4.安装nginx
cd /usr/local/
wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar -zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2  
./configure --prefix=/usr/local/nginx
make && make install


//建立一个软连接
ln -s /usr/local/nginx-1.6.2 nginx
注意:
--with-http_ssl_module 是为了配置https访问所需的模块

--with-http_gzip_static_module 是静态压缩模块

 

启动nginx::

/usr/local/nginx/sbin/nginx

检查配置文件:

/usr/local/nginx/sbin/nginx -t

指定配置文件启动:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

重启:

/usr/local/nginx/sbin/nginx -s reload

测试nginx安装是否成功

[root@localhost sysconfig]# /usr/local/nginx/sbin/nginx -t


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

 

 

添加开机启动

# vi /etc/rc.local

154113_2p6A_3226688.png

 

 

 

转载于:https://my.oschina.net/u/3226688/blog/843639

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值