sunny123456

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

CentOS7.0下编译安装Nginx

  写在前面的话

  每次在Linux搭建web环境都要一顿google求参考文档,这次索性写个简单的文章记录一下。其实Linux下编译安装主要就是这几个步骤。

  安装编译工具、依赖包及下载源码包

  解压编译

  安装

  启动

  准备工作安装编译工具、依赖包

$ yum -y install gcc gcc-c++ autoconf automake $ yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

  以上安装的是一些主要的依赖包,www.lu0.com具体可根据自己情况或者报错信息提示安装或修改

  新建匿名用户和用户组

  新建的用户组和用户主要是在编译配置的时候指定nginx运行的用户和用户组。这样指定后以后配置使用也方便。

  

$ sudo groupadd -r nginx $ sudo useradd -s /sbin/nologin -g nginx -r nginx
Nginx编译安装下载源码包

  我一般从官网下载

  

wget 
解压并编译
解压
tar -zxvf nginx-1.10.0.tar.gz
配置

  配置没毛病的话可以看到这些信息

  

Configuration summary + using system PCRE library + OpenSSL library is not used + md5: using system crypto library + sha1: using system crypto library + using system zlib library nginx path prefix: /usr/local/nginx nginx binary file: /usr/local/nginx/sbin/nginx nginx modules path: /usr/local/nginx/modules nginx configuration prefix: /etc/nginx nginx configuration file: /etc/nginx/nginx.conf nginx pid file: /usr/local/nginx/logs/nginx.pid nginx error log file: /usr/local/nginx/logs/error.log nginx http access log file: /usr/local/nginx/logs/access.log nginx http client request body temporary files: client_body_temp nginx http proxy temporary files: proxy_temp nginx http fastcgi temporary files: fastcgi_temp nginx http uwsgi temporary files: uwsgi_temp nginx http scgi temporary files: scgi_temp

  以上编译参数只是配置了主要的东西,全部配置参数说明你可以通过这个命令查看
./configure --help

  

编译并安装

  $ make make install
启动等命令
须进入到/usr/local/nginx/sbin目录下

  

启动:
$ nginx
停止:
$ nginx -s stop
重启:
$ nginx -s reload

  以上各个步骤报错的话根据报错提示缺啥装啥,不犯几次错误都不好意思说自己配过环境。PS:有问题可留言讨论哦

  


  博客原文链接

https://www.lu0.com/news/content/15065.html
posted on 2022-10-11 08:56  sunny123456  阅读(38)  评论(0编辑  收藏  举报