CentOS7.0下編譯安裝Nginx 1.10.0

寫在前面的話

每次在Linux搭建web環境都要一頓google求參考文檔,此次索性寫個簡單的文章記錄一下。其實Linux下編譯安裝主要就是這幾個步驟。
linux

  • 安裝編譯工具、依賴包及下載源碼包nginx

  • 解壓編譯c++

  • 安裝web

  • 啓動centos

準備工做

安裝編譯工具、依賴包

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

以上安裝的是一些主要的依賴包,具體可根據本身狀況或者報錯信息提示安裝或修改bash

新建匿名用戶和用戶組

新建的用戶組和用戶主要是在編譯配置的時候指定nginx運行的用戶和用戶組。這樣指定後之後配置使用也方便。工具

$ sudo groupadd -r nginx

$ sudo useradd -s /sbin/nologin -g nginx -r nginx

Nginx編譯安裝

下載源碼包

我通常從官網下載google

wget http://nginx.org/download/nginx-1.10.0.tar.gz

解壓並編譯

解壓
tar -zxvf nginx-1.10.0.tar.gz
配置
./configure \
--prefix=/usr/local/nginx \
--conf-path=/etc/nginx/nginx.conf \ 
--user=nginx \
--group=nginx \

配置沒毛病的話能夠看到這些信息centos7

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 --helpcode

編譯並安裝

$ make && make install
啓動等命令
須進入到/usr/local/nginx/sbin目錄下

啓動:
$ nginx
中止:
$ nginx -s stop
重啓:
$ nginx -s reload

以上各個步驟報錯的話根據報錯提示缺啥裝啥,不犯幾回錯誤都很差意思說本身配過環境。PS:有問題可留言討論哦


博客原文連接

相關文章
相關標籤/搜索