CentOS 6.5 下编译安装 Nginx 1.8.0

安装编译依赖的包

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

安装 Nginx

# 下载源码
wget  http://nginx.org/download/nginx-1.8.0.tar.gz  

# 解压
tar zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0

# 编译安装
./configure
make && make install

运行 configure 后可以看到一大串配置信息:

nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/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"

配置 Nginx

注意上面的配置信息,Nginx 的配置文件在 /usr/local/nginx/conf/ 目录下,此时可以编辑 /usr/local/nginx/conf/nginx.conf 文件,修改配置,这个就不多说了。

配置完可以用 nginx -t 检查配置是否正确。

修改完之后就可以启动 Nginx 了:

nginx -c /usr/local/nginx/conf/nginx.conf 

# 查看 nginx 进程
ps aux | grep nginx 
    原文作者:Tony
    原文地址: https://segmentfault.com/a/1190000006692799
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞