Edhug

导航

Nginx安装及常用命令

安装步骤(建议安装在opt目录下)

#1、安装make(linux中对源代码进行编译的工具)
yum -y install autoconf automake make
#2、安装gcc(用于编译nginx源代码)
yum -y install gcc gcc-c++
#安装ngxin依赖
yum -y install wget pcre pcre-devel zlib zlib-devel openssl openssl-devel
#下载nginx源码
wget http://nginx.org/download/nginx-1.23.0.tar.gz
#解压源码
tar -zxvf nginx-1.23.0.tar.gz
#编译安装
cd nginx-1.23.0 && ./configure  --prefix=/opt/nginx && make && make install
#添加环境变量
vi /etc/profile
增加以下内容:opt/nginx 为nginx的安装目录
export PATH=$PATH:/opt/nginx/sbin
#生效环境变量
source /etc/profile
#关闭防火墙
systemctl stop firewalld
#禁止防火墙系统系统
systemctl disable firewalld

Nginx常用命令

#启动Nginx
nginx或者nginx-cnginx.conf#指定配置文件,默认为NGINX HOME/conf/nginx.conf
#停止Nginx(暴力停止)
nginx -s stop
#停止Nginx(优雅的停止)
nginx -s quit
#配置文件操作
nginx -s reload #重新加载配置。配置文件是否正确可通过:nginx-t进行校验

posted on 2025-01-20 15:07  饿得慌~  阅读(44)  评论(0)    收藏  举报