本文介绍: usr/local/nginx/conf 目录下为Nginx配置文件nginx.conf。/usr/local/nginx/sbin 目录下为Nginx执行程序。命令正常执行后 会在/usr/local/目录下生成nginx目录。

安装编译环境

yum install -y gcc-c++ pcre pcrre-devel zlib zlib-devel openssl openssl-devel

下载或上传Nginx

​ 官网下载链接:nginx: download

​ 命令下载:

wget http://nginx.org/download/nginx-1.24.0.tar.gz

解压并编译文件

# tar -zxvf nginx-1.24.0.tar.gz
# cd nginx-1.24.0
# ./configure
# make & make install
  • 命令正常执行后 会在/usr/local/目录下生成nginx目录

  • /usr/local/nginx/conf 目录下为Nginx配置文件nginx.conf

  • /usr/local/nginx/sbin 目录下为Nginx执行程序

启动Nginx

cd /usr/local/nginx/sbin  
nginx -s reload

注:修改nginx-conf 配置文件后 需要执行nginx -s reload 完成配置重载

其他问题

出现启动问题

[root@71bbc89bd68f sbin]# ./nginx -s reload

nginx: [alert] kill(3042, 1) failed (3: No such process)

或者

[root@71bbc89bd68f sbin]# nginx -s reload

-bash: nginx: command not found

  • 查看nginx是否安装成功

[root@71bbc89bd68f sbin]# ps -ef | grep nginx

root 26291 26268 0 02:40 pts/2 00:00:00 grep –color=auto nginx

  • 解决方案
vim /etc/profile

添加

PATH=$PATH:/usr/local/nginx/sbin

export PATH

刷新配置文件

source /etc/profile

重启nginx

nginx -s reload

原文地址:https://blog.csdn.net/IT_LittleBaby/article/details/135431156

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_54288.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注