当前位置: 首页>编程语言>正文

centos安装nginx

  1. 官网下载nginx压缩包
  • 官网下载页面
    http://nginx.org/en/download.html

    centos安装nginx,第1张
  • 选择稳定版
    右键点击图中的Stable version下的 nginx-1.20.1,选择复制链接

  • 下载到linux
    命令wget url
    在这里选择个目录存放压缩包,然后执行wget 复制的下载地址

    • centos安装nginx,第2张
  1. 解压
    命令 tar -xvf 文件名 顺带一提tar -cvf 文件是压缩
  • centos安装nginx,第3张
  • 解压后进入这个文件夹


    centos安装nginx,第4张
  1. 配置
  • 执行
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin --modules-path=/usr/local/nginx/modules --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log --pid-path=/usr/local/nginx/logs/nginx.pid --lock-path=/usr/local/nginx/logs/nginx.lock
  • 关于配置的参数的含义,在官方文档中有说明
    http://nginx.org/en/docs/configure.html

  • 可能遇到的报错

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

解决方法
需要安装pcre的devel包,pcre-devel。使用yum安装即可:(以下命令还带有ssl、zlib等依赖的安装)
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel

  1. 安装
  • 执行
    make & make install
  1. nginx的基本命令
  • 官网 http://nginx.org/en/docs/beginners_guide.html
  • 首先进入到安装目录,如果没改configure参数,安装目录在 /usr/local/nginx
  • 启动 ./sbin
    停止 ./sbin -s quit
    重新加载配置文件 ./sbin -s reload


https://www.xamrdz.com/lan/5ab1848840.html

相关文章: