Nginx在linux下安装及简单命令
2024-09-01 03:57:16
安装环境:Centos7
创建目录及切换至目录
# mkdir /usr/local/nginx
# cd /usr/local/nginx/
下载nginx包,访问http://nginx.org下载或http://nginx.org/download或使用命令下载
wget http://nginx.org/download/nginx-1.17.3.tar.gz
解压nginx包及移至解压目录
# tar -zxvf nginx-1.17..tar.gz
# cd nginx-1.17./
设置安装路径
# ./configure --prefix=/usr/local/nginx
若出现错误【checking for C compiler ... not found】需要执行如下命令
# yum -y install gcc gcc-c++ autoconf automake make
若出现下面的错误,需要安装openssl
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
安装openssl命令
# yum -y install openssl openssl-devel
编译--make是用来编译的,它从Makefile中读取指令,然后编译。
# make
安装--make install是用来安装的,它也从Makefile中读取指令,安装到指定的位置。
# make install
至此,nginx已经安装成功,接下来可以执行nginx命令来操作nginx
命令
启动 -- # /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
重启 -- # nginx -s reload
重新打开日志文件 -- # nginx -s reopen
测试nginx配置文件是否正确 -- # nginx -t -c /usr/local/nginx/conf/nginx.conf
快速停止 -- # nginx -s stop
完整有序的停止 -- # nginx -s quit
也可以通过进程停止nginx
查询nginx主进程号 -- # ps -ef | grep nginx
有序停止 -- # kill -QUIT 主进程号
快速停止 -- # kill -TERM 主进程号
强制停止 -- # pkill -9 nginx
平滑启动 -- # kill -HUP 主进程号
最新文章
- protocol的简单写法
- [转](四)unity4.6Ugui中文教程文档-------概要-UGUI Visual Components
- MongoDB 启动mongo不带DB
- sping获取bean方法 解决资源耗尽
- jquery 工作笔记,不断整理中..
- html5 canvas+js实现ps钢笔抠图
- C#获取指定月指定周的日期范围
- Spring基础篇——Spring容器和应用上下文理解
- Linux通过NFS实现文件共享
- Unity Chan 2D Asset
- ios判断当前设备类型
- RocketMQ概述
- Howto: 使用ImageBrush替换PictureMarkerSymbol以加强graphic显示性能
- ajax jquery校验用户是否已经注册
- 安装cocoa pods
- codeforces-727A
- 向git服务器添加shh公钥
- Tunnel Warfare(HDU1540+线段树+区间合并)
- 12-4 NSString
- git配置ssh key并从github.com拉取repos