【Linux基础运维】安装部署nginx

安装部署nginx


方式一:编译安装

安装依赖:yum install -y gcc gcc-c++ make zlib zlib-devel libtool opennssl openssl-devel pcre pcre-devel html

nginx的下载连接:http://nginx.org/en/download.htmlnginx

下载tar解压缩后,configure、make、make install三步走。c++

  1. 添加nginx用户:useradd -s /sbin/nologin -M nginx
  2. 预编译:./configure --user=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
  3. 预编译成功后,编译:make(能够根据CPU核数,添加-j选项加快编译速度)
  4. 编译安装:make install

启动:/usr/local/nginx/sbin/nginx,或者指定配置文件:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confweb

方式二:软件源安装

使用yum、apt等包管理器安装docker

方式三:docker安装

简单测试

  • 检查Nginx配置文件是否正确:/usr/local/nginx/sbin/nginx -t
  • web访问nginx
相关文章
相关标签/搜索