通过xshell在linux上安装nginx1.12.0 |
您所在的位置:网站首页 › xshell压缩gzip › 通过xshell在linux上安装nginx1.12.0 |
通过xshell在linux上安装nginx1.12.0
0)环境安装
Nginx是C语言开发,建议在 Linux 上运行,当然,也可以安装Windows版本,本篇则使用CentOS 7作为安装环境。 gcc安装:安装 nginx 需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,则需要安装: yum install gcc-c++PCRE pcre-devel安装:PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括perl兼容的正则表达式库。Nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库,pcre-devel 是使用pcre开发的一个二次开发库。Nginx也需要此库。命令: yum install -y pcre pcre-develzlib安装:zlib库提供了很多种压缩和解压缩的方式, Nginx使用zlib对http包的内容进行gzip ,所以需要在Centos上安装zlib库。 yum install -y zlib zlib-develOpenSSL安装:OpenSSL是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。Nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在Centos安装OpenSSL库。 yum install -y openssl openssl-devel 1)下载安装方式一:直接下载 .tar.gz 安装包,地址:https://nginx.org/en/download.html 方式二:使用wget命令下载(推荐)。确保系统已经安装了wget,如果没有安装,执行 yum install wget 安装。 wget -c https://nginx.org/download/nginx-1.12.0.tar.gz我下载的是1.12.0版本,这个是目前的稳定版。解压命令: tar -zxvf nginx-1.12.0.tar.gz cd nginx-1.12.0 2)配置编译其实在 nginx-1.12.0 版本中你就不需要去配置相关东西,默认就可以了。当然,如果你要自己配置目录也是可以的。 方式一:使用默认配置 ./configure方式二:自定义配置(不推荐) ./configure \ --prefix=/usr/local/nginx \ --conf-path=/usr/local/nginx/conf/nginx.conf \ --pid-path=/usr/local/nginx/conf/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp-path=/var/temp/nginx/scgi注:将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录 编译安装 make make install 或 make install PREFIX=/usr/nginx #这里可以指定安装位置查找安装路径: whereis nginx 启动成功后,在浏览器可以看到这样的页面: |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |