您当前的位置: 首页 >  linux

彭世瑜

暂无认证

  • 0浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Linux环境编译安装Nginx

彭世瑜 发布时间:2019-11-12 10:25:14 ,浏览量:0

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

下载地址:http://nginx.org/en/download.html

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_gzip_static_module \
--with-pcre \
--with-http_realip_module \
--with-http_sub_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
开机自启

vi /etc/systemd/system/nginx.service

[Unit]
Description=nginx
After=network.target
 
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target

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

关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.0474s