首页 > 代码库 > CentOS安装Nginx

CentOS安装Nginx

一、安装基础环境包

yum -y install gcc gcc-c++ openssl*
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel
yum -y install libxml2 libxml2-devel zlib zlib-devel ncurses ncurses-devvel curl curl-devel
yum -y install gd gd2 gd-devel gd2-devel

二、安装PCRE

1、下载

    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz

2、解压

  tar zxvf pcre-8.35.tar.gz

3、安装

  cd pcre-8.35

  ./configure

  make && make install

三、安装Nginx

1、下载Nginx

  wget http://nginx.org/download/nginx-1.7.3.tar.gz

2、解压

  tar zxvf nginx-1.7.3.tar.gz

3、安装

  cd nginx-1.7.3

  ./configure --prefix=/opt/nginx --with-http_ssl_module  --with-http_stub_status_module 

  make && make install

  注:--prefix=/opt/nginx,nging安装目录;--with-http_ssl_module,开启HTTP SSL模块,使NGINX可以支持HTTPS请求。这个模块需要已经安装了OpenSSL;--with-http_stub_status_module,开启 nginx 的 NginxStatus功能,用来监控 Nginx 的当前状态。

四、启动Nginx

  echo "/usr/local/lib" >>/etc/ld.so.conf

  tail -1 /etc/ld.so.conf

  ldconfig

  /opt/nginx/sbin/nginx

  lsof -i:80