linux-Centos7安装nginx,linux-centos7nginx


首先配置linux环境,我这里是刚刚装好linux,所以一次性安装了一系列我需要到的环境;

 yum install

 pcre pcre-devel zlib zlib-devel openssl openssl-devel gd gd-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel
 autoconf libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel libidn libidn-devel libtool libtool-libs libevent-devel libevent openldap openldap-devel nss_ldap openldap-clients openldap-servers libtool-ltdl libtool-ltdl-devel bison libgcrypt php-mcrypt libmcrypt libmcrypt-devel cmake gcc gcc-c++ ncurses-devel perl-Data-Dumper libicu-devel libquadmath-devel python-devel bzip2-devel

 

1.到http://nginx.org/en/download.html官网下载一个nginx

2.tar -zxvf  nginx-1.13.4.tar.gz 解压到/usr/local/nginx-1.13.4.tar.gz

3.cd  nginx-1.13.4 进入目录

4编译安装,执行:

  ./configure --prefix=/usr/local/nginx-1.13
  --with-pcre
  --with-ipv6
  --with-http_v2_module
  --with-http_ssl_module
  --with-http_dav_module
  --with-http_sub_module
  --with-http_realip_module
  --with-http_addition_module
  --with-http_stub_status_module 

  --add-module=/mnt/root/src/nginx.package/ngx_log_if     # 指定不写入的某些日志
  --add-module=/mnt/root/src/nginx.package/ngx_devel_kit
  --add-module=/mnt/root/src/nginx.package/form-input-nginx-module  # 在请求中获取POST的参数
  --add-module=/mnt/root/src/nginx.package/echo-nginx-module    # 在nginx中方便调试
  --add-module=/mnt/root/src/nginx.package/set-misc-nginx-module  # set value
  

以上编译命令中的(--add-module=)这些模块需要自行预先下载放在/mnt/root/src/nginx.package/(此路径不是必须,可自定义)文件夹里面才能编译,如果没有会报错;

根据自己需求,如果不需要(--add-module=)这些模块可以直接编译:

  ./configure --prefix=/usr/local/nginx-1.13
  --with-pcre
  --with-ipv6
  --with-http_v2_module
  --with-http_ssl_module
  --with-http_dav_module
  --with-http_sub_module
  --with-http_realip_module
  --with-http_addition_module
  --with-http_stub_status_module

编译之后执行make && make install  安装完成!

 

相关内容