CentOS6.5 安装Nginx

准备nginx的安装环境

      yum -y install gcc gcc-c++ autoconf automake make

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

注意:如果某些依赖已经安装过,则会自动更新。

下面正式开始


一般我们都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩。

我们将 pcre 和 zlib 安装在:/usr/local/bin 目录下

 [root@user ~]# cd  /usr/local/bin

一.安装PCRE库

[root@user /usr/local/bin]#  wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz 

[root@user /usr/local/bin]# tar -zxvf pcre-8.40.tar.gz

[root@user /usr/local/bin]# cd pcre-8.40

[root@user /usr/local/bin]# ./configure

[root@user /usr/local/bin]# make

[root@user /usr/local/bin]# make install

二.安装zlib库


[root@user /usr/local/bin]# wget http://zlib.net/zlib-1.2.10.tar.gz

[root@user /usr/local/bin]# tar -zxvf zlib-1.2.10.tar.gz

[root@user /usr/local/bin]# cd zlib-1.2.10

[root@user /usr/local/bin]# ./configure

[root@user /usr/local/bin]# make

[root@user /usr/local/bin]# make install

三.安装ssl(某些vps默认没装ssl)


[root@user ~]# wget http://[www.openssl.org/source/openssl-fips-2.0.14.tar.gz](http://www.openssl.org/source/openssl-fips-2.0.14.tar.gz) 

[root@user ~]# tar -zxvf openssl-fips-2.0.14.tar.gz

[root@user ~]# yum -y install openssl openssl-devel

四.安装nginx

注意:nginx的默认安装路径是/usr/local/nginx 其运行文件在其/usr/local/nginx/sbin目录下面

[root@user ~]# wget http://nginx.org/download/nginx-1.4.2.tar.gz (你可以去Nginx 官网上找你自己想要的版本)

[root@user ~]# tar -zxvf nginx-1.4.2.tar.gz

[root@user ~]# cd nginx-1.4.2

[root@user ~]# ./configure 

[root@user ~]#  make

[root@user ~]#  make install
自定义安装:

如果直接执行 ./configure 则nginx安装到默认路径,自定义安装步骤如下,例如:安装到/soft/nginx目录


[root@user ~]#   ./configure --sbin-path=/usr/local/bin/nginx/nginx 
\--conf-path=/usr/local/bin/nginx/nginx.conf 
\--pid-path=/usr/local/bin/nginx/nginx.pid 
\--with-http_ssl_module 
\--with-pcre=/usr/local/bin/pcre-8.40
 \--with-zlib=/usr/local/bin/zlib-1.2.10 
\--with-openssl=/usr/local/bin/openssl-fips-2.0.14

你可能感兴趣的:(CentOS6.5 安装Nginx)