linux下nginx安装

来源:互联网 发布:淘宝评论折叠在哪里 编辑:程序博客网 时间:2024/04/28 17:05

 因为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-1.6.2 --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/ssl

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

0 0