Linux下Nginx 1.18.X安装配置(图文详细)

Linux下Nginx 1.18.X安装配置(图文详细)

一、资源准备

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

在这里插入图片描述

二、安装配置

  • 上传资源
# 上传文件至soft目录

#切换目录并解压
cd /opt/soft
tar -zxvf nginx-1.18.0.tar.gz -C /opt/

#切换目录并重命名
cd /opt/module/nginx-1.18.0/ && ll

在这里插入图片描述

  • 安装依赖
#安装命令
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel pcre pcre-devel 
  • 编译安装
#命令
./configure && make && make install

#安装后相关目录
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
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
  • 配置系统变量
#编辑命令
vim /etc/profile

#加入内容
#NGINX_HOME
export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin

#生效配置
source /etc/profile

在这里插入图片描述

  • 配置系统服务
#添加系统服务
vim /etc/systemd/system/nginx.service
 
# Script内容
[Unit]
Description=The NGINX HTTP Server
After=syslog.target network.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target


#刷新配置
systemctl daemon-reload

# 启动命令
systemctl start|stop|restart|status nginx

# 开机自启
systemctl enable nginx
  • 相关命令
nginx version: nginx/1.18.0
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/nginx/)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值