1、官网下载安装包

http://nginx.org/en/download.html,选择适合Linux的版本,这里选择最新的版本,下载到本地后上传到服务器或者centos下直接wget命令下载。

切换到/usr/local目录,下载软件包

1
2
# cd /usr/local
# wget http://nginx.org/download/nginx-1.11.5.tar.gz

2、安装nginx

先执行以下命令,安装nginx依赖库,如果缺少依赖库,可能会安装失败,具体可以参考文章后面的错误提示信息。

1
2
3
4
5
6
7
# 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

解压安装包

1
# tar -zxvf nginx-1.11.5.tar.gz

nginx被解压到了/usr/local/nginx-1.11.5 目录下(不要把压缩包解压到/usr/local/nginx目录下,或者将解压后的目录重命名为nginx,因为nginx会默认安装到/usr/local/nginx目录下),切换到nginx-1.11.5/目录

1
# cd /usr/local/nginx-1.11.5/

执行# ./configure

1
# ./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

1
2
# make
# make install

没有出错的话,表示nginx已经成功安装完成,默认安装位置为/usr/local/nginx,之前的/usr/local/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.

3、配置nginx开机启动

切换到/lib/systemd/system/目录,创建nginx.service文件vim nginx.service

1
2
# cd /lib/systemd/system/
# vim nginx.service

文件内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
[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

退出并保存文件,执行systemctl enable nginx.service使nginx开机启动

1
# systemctl enable nginx.service

systemctl start nginx.service    启动nginx

systemctl stop nginx.service    结束nginx

systemctl restart nginx.service    重启nginx

4、验证是否安装成功

输入http://服务器IP/ 如果能看到nginx的界面,就表示安装成功了

centos7安装与配置nginx1.11,开机启动的更多相关文章

  1. 开发--CentOS-7安装及配置

    开发|CentOS-7安装及配置 本文主要进行详细讲解CentOS7.5系统的安装过程,以及CentOS系统初始化技术.我并不想将这篇文章变成一个教程,尽管我将详细的进行每一步的讲解,enjoy! 前 ...

  2. Centos7安装并配置mysql5.6完美教程

    Centos7安装并配置mysql5.6完美教程 Centos7将默认数据库mysql替换成了Mariadb,对于我们这些还想使用mysql的开发人员来说并不是一个好消息.然而,网上关于Linux安装 ...

  3. CentOS7安装及配置vsftpd (FTP服务器)

    CentOS7安装及配置vsftpd (FTP服务器) 1.安装vsftpd 1 yum -y install vsftpd 2.设置开机启动 1 systemctl enable vsftpd 3. ...

  4. CentOS7安装及配置vsftpd (FTP服务器FTP账号创建以及权限设置)

    本文章向大家介绍CentOS7安装及配置vsftpd (FTP服务器FTP账号创建以及权限设置),主要包括CentOS7安装及配置vsftpd (FTP服务器FTP账号创建以及权限设置)使用实例.应用 ...

  5. windows安装SVN服务器并设置开机启动

    1.安装SVN服务器,到http://subversion.apache.org/packages.html上下载windows版的SVN,并安装,在命令行下运行svn命令,如下所以,则svn服务器安 ...

  6. CentOS8安装GNOME3桌面并设置开机启动图形界面

    本篇文章介绍如何在CentOS8 Linux操作系统中安装GNOME3桌面环境和GDM(GNOME Display Manager)现实环境管理器. 环境 CentOS8 Minimal 安装GNOM ...

  7. windows系统下同时启动三台Tomcat服务的配置&并设置开机启动服务

    1.tomcat 7.0.82下载地址:链接:https://pan.baidu.com/s/1i51pAgl 密码:mxol 2.解压apache-tomcat-7.0.82-windows-x64 ...

  8. linux centos7.3安装lnmp,nginx-1.11.12 ,php7.0.2 ,

    #更新源 yum -y update #添加用户和组 adduser www groupadd www usermod -G www www #初始化目录 mkdir -p /data/app/php ...

  9. CentOS7 配置花生壳开机启动

    在家安装服务器,外地可以随时登陆,感觉花生壳特别方便,具体路由器配置请参考http://service.oray.com/question/2486.html. 我使用的操作系统是 [root@loc ...

随机推荐

  1. python使用rabbitMQ介绍三(发布订阅模式)

    一.模式介绍 在前面的例子中,消息直接发送到queue中. 现在介绍的模式,消息发送到exchange中,消费者把队列绑定到exchange上. 发布-订阅模式是把消息广播到每个消费者,每个消费者接收 ...

  2. 解决在使用gensim.models.word2vec.LineSentence加载语料库时报错 UnicodeDecodeError: 'utf-8' codec can't decode byte......的问题

    在window下使用gemsim.models.word2vec.LineSentence加载中文维基百科语料库(已分词)时报如下错误: UnicodeDecodeError: 'utf-8' cod ...

  3. fastJson反序列化异常,JSONException: expect ':' at 0, actual =

    com.alibaba.fastjson.JSONException: expect , actual = at com.alibaba.fastjson.parser.DefaultJSONPars ...

  4. js实现分段上传文件

    使用js实现分段上传文件,本文使用了FileReader对象,可参考:https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader 1)获取文 ...

  5. Neutron:Firewall as a Service(FWaaS)

    用户可以用它来创建和管理防火墙,在 subnet 的边界上对 layer 3 和 layer 4 的流量进行过滤.   传统网络中的防火墙一般放在网关上,用来控制子网之间的访问. FWaaS 的原理也 ...

  6. Selenium WebDriver原理(一):Selenium WebDriver 是怎么工作的?

    首先我们来看一个经典的例子: 搭出租车 在出租车驾驶中,通常有3个角色: 乘客 : 他告诉出租车司机他想去哪里以及如何到达那里 对出租车司机说: 1.去阳光棕榈园东门 2.从这里转左 3.然后直行 2 ...

  7. js判断iPhone XS、iPhone XS Max、iPhone XR

    // iPhone X.iPhone XS && window.screen.width === && window.screen.height === ; // iP ...

  8. tp5问题整理

    问题一:致命错误: Class 'think\controller' not found 原因:controller首字母要大写 解决:use think\Controller; 问题二:html页面 ...

  9. PL2303HX在Windows 10下面不装安装驱动的解决办法(Code:10)

    Prolific在很早之前推出了一款名为PL2303HX的芯片, 用于USB转RS232, 这款芯片使用的范围非常广, 并且年代久远. 但是这款芯片因为用的特别多, 所以中国就有很多厂家生产了仿造的P ...

  10. 单元测试之Fixture

    声明: 作者:zhaojun  创建日期:2017-08-04  更新日期:2017-08-07 一.什么是Fixture,Fixture有什么作用,为什么需要使用Fixture # 下载 pip i ...