天天看点

Linux环境编译安装Nginx

1、安装编译工具

yum -y install make zlib zlib-devel gcc gcc-c++ libtool  openssl openssl-devel pcre pcre-devel ncurses-devel perl      

2、创建用户

groupadd www
useradd -g www www -M -s /sbin/nologin
# -M参数表示不添加用户家目录,-s参数表示指定shell类型      

3、安装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 \
--prefix=/usr/local/nginx \
--user=www --group=www \
--with-http_stub_status_module \
--with-http_ssl_module

#  –with-http_stub_status_module 启用 Nginx 的 NginxStatus 功能

make && make install

# 软链
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx

nginx -v   # 查看版本

netstat -ano|grep 80  # 检查80端口

nginx      # 启动
nginx -t   # 检查配置
      

查看Nginx所在网址

http://127.0.0.1

Welcome to nginx!

4、常用操作

nginx -s reload            # 重新载入配置文件
nginx -s reopen            # 重启 Nginx
nginx -s stop              # 停止 Nginx      

参考

Nginx安装及配置详细教程 Nginx 安装配置

继续阅读