网站首页 > 技术教程 正文
- 环境:Centos 7.2
- nginx版本:1.11.5
下载Nginx
mkdir -p /opt/module
cd /opt/module
wget http://nginx.org/download/nginx-1.11.5.tar.gz
我们将nginx下载到/opt/module目录下
安装Nginx
- 安装依赖
yum install gcc-c++
yum install pcre
yum install pcre-devel
yum install zlib
yum install zlib-devel
yum install openssl
yum install openssl-devel
- 解压nginx
cd /opt/module
tar -zxvf nginx-1.11.5.tar.gz
- 安装nginx
cd /opt/module/nginx-1.11.5/
./configure
该操作会检测当前系统环境,以确保能成功安装nginx,执行该操作后可能会出现以下几种提示:
checking for OS
+ Linux 3.10.0-123.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
如果出现以上错误提示信息,执行yum install gcc-c++安装gcc,
./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.
如果出现上面提示,表示缺少PCRE库
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
如果出现以上提示,表示缺少zlib库
如果没有出现./configure: error提示,表示当前环境可以安装nginx,执行make和make install编译nginx
- 编译nginx
make
make install
没有出错的话,表示nginx已经成功安装完成,默认安装位置为/usr/local/nginx,之前的/opt/module/nginx-1.11.5/可以删除掉了。
如果出现cp: 'conf/koi-win' and '/usr/local/nginx/conf/koi-win' are the same file,可能是你把安装包解压到了/usr/local/nginx目录,解决办法是将该目录重命名为其他名称后再执行make,make install.
配置开机启动
- 配置启动文件
cd /lib/systemd/system/
vim nginx.service
# 将以下文件内容粘贴进去
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
- 加载配置文件
# 记得保存上面的nginx.service文件
#使nginx开机启动
systemctl enable nginx.service
常用命令
nginx默认是装在/usr/local/nginx目录下,日志也在该目录下。
systemctl start nginx.service 启动nginx
systemctl stop nginx.service 结束nginx
systemctl restart nginx.service 重启nginx
可以直接访问ip查看nginx启动情况,输入http://服务器IP/ 如果能看到nginx的界面,就表示安装成功了。
猜你喜欢
- 2024-10-10 Nginx教程从入门到精通-nginx安装
- 2024-09-11 如何快速掌握Nginx 安装与配置?这个方法可能有用!
- 2024-09-11 nginx-安装与启动(nginx安装和配置)
- 2024-09-11 运维基础服务篇:Nginx概述和安装(nginx应用与运维实战pdf百度云)
- 2024-09-11 Nginx从安装到高可用,一篇搞定(nginx安装和使用)
- 2024-09-11 如何在linux中安装Nginx(如何在linux中安装python)
- 2024-09-11 Nginx安装配置学习(nginx1.16安装)
- 2024-09-11 新手学习第二阶段:Nginx服务安装配置及实战演练
- 2024-09-11 安装nginx(安装nginx涉及环境变量嘛)
- 2024-09-11 Nginx的安装、配置文件详解以及基本应用
你 发表评论:
欢迎- 最近发表
-
- Win11学院:如何在Windows 11上使用WSL安装Ubuntu
- linux移植(Linux移植freemodbus)
- 独家解读:Win10预览版9879为何无法识别硬盘
- 基于Linux系统的本地Yum源搭建与配置(ISO方式、RPM方式)
- Docker镜像瘦身(docker 减小镜像大小)
- 在linux上安装ollama(linux安装locale)
- 渗透测试系统Kali推出Docker镜像(kali linux渗透测试技术详解pdf)
- Linux环境中部署Harbor私有镜像仓库
- linux之间传文件命令之Rsync傻瓜式教程
- 解决ollama在linux中安装或升级时,通过国内镜像缩短安装时长
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)