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基础之注释,算数运算符,变量,输入和格式化输出

    Python的注释 注释的作用:用自己熟悉的语言,对某些代码进行标注说明,增强程序的可读性: 在python解释器解释代码的过程中,凡是#右边的,解释器都直接跳过这一行: 注释的分类 单行注释 # 这 ...

  2. angularjs html 转义

    angularjs html 转义 默认情况下,AngularJS对会对插值指令求职表达式(模型)中的任何HTML标记都进行转义,例如以下模型: $scope.msg = “hello,<b&g ...

  3. StringUtils工具类常用方法详解

    StringUtils 常用方法 1.isEmpty(String str) 是否为空,空格字符为false2.isNotEmpty(String str) 是否为非空,空格字符为true3.isBl ...

  4. node的第一步,hello,以及小技巧和CPU使用情况。到底能用几个核心?

    安装了啥的就不说了,百度一下有很多. Windows环境.Linux不会,所有就不说了. 1.  hello Word node的hello Word很简单,就一行. console.log(&quo ...

  5. Android Studio3.x上使用Lombok

    1.添加gradle依赖 implementation 'org.projectlombok:lombok:1.16.8' //添加lombok依赖implementation 'org.glassf ...

  6. vue动态设置初始页

  7. [转帖]Oracle 补丁体系(PSR/PSU/CPU) 及 opatch 工具 介绍

    Oracle 补丁体系(PSR/PSU/CPU) 及 opatch 工具 介绍 原文:http://blog.csdn.net/tianlesoftware/article/details/58095 ...

  8. Javascript实现base64的加密解密

    //1.加密解密方法使用: //1.加密 var str = '124中文内容'; var base = new Base64(); var result = base.encode(str); // ...

  9. 重写Sink合并多行

    flume1.6+elasticsearch6.3.2 Pom <dependencies> <dependency> <groupId>junit</gro ...

  10. Springboot读取Jar文件中的resource

    如题,碰到了问题. 事情是这样的. 一个导入模板, 因为比较少, 所以就直接放在后台的resources中了.调试的时候是下载没有问题的. 等到发布后,下载就出问题了. 参照: ***.jar!\BO ...