centos7编译安装nginx
一、安装依赖包
yum install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel
二、下载
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.14.2.tar.gz
三、编译
tar -zxvf nginx-1.14..tar.gz
cd nginx-1.14.
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
四、将nginx设置为服务
centos 7 中采用 systemd 来管理系统,我们为 nginx 创建服务文件
vim /lib/systemd/system/nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
这里的 PIDFile 的配置要和前面的 配置保持一致。
设置自启动
[root@node2 logs]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
五、启动nginx
[root@node2 logs]# systemctl start nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
提示报错,查看查看状态
[root@node2 logs]# systemctl status nginx
● nginx.service - The NGINX HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 二 -- :: CST; 15s ago
Process: ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=/FAILURE)
Process: ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=/SUCCESS) 4月 :: node2.jinglong nginx[]: nginx: [emerg] bind() to 0.0.0.0: failed (...e)
4月 :: node2.jinglong nginx[]: nginx: [emerg] bind() to 0.0.0.0: failed (...e)
4月 :: node2.jinglong nginx[]: nginx: [emerg] bind() to 0.0.0.0: failed (...e)
4月 :: node2.jinglong nginx[]: nginx: [emerg] bind() to 0.0.0.0: failed (...e)
4月 :: node2.jinglong nginx[]: nginx: [emerg] bind() to 0.0.0.0: failed (...e)
4月 :: node2.jinglong nginx[]: nginx: [emerg] still could not bind()
4月 :: node2.jinglong systemd[]: nginx.service: control process exited, code=e...s=
4月 :: node2.jinglong systemd[]: Failed to start The NGINX HTTP and reverse pr...er.
4月 :: node2.jinglong systemd[]: Unit nginx.service entered failed state.
4月 :: node2.jinglong systemd[]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
提示80端口被占用,此时执行:
[root@node2 sbin]# killall - nginx
-bash: killall: 未找到命令
安装killall
yum install psmisc
再执行
killall - nginx
启动服务
[root@node2 sbin]# systemctl start nginx
[root@node2 sbin]#
没有报错,查看状态
[root@node2 sbin]# systemctl status nginx
● nginx.service - The NGINX HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since 二 -- :: CST; 17s ago
Process: ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=/FAILURE)
Process: ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=/SUCCESS)
Process: ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=/SUCCESS)
Main PID: (nginx)
CGroup: /system.slice/nginx.service
├─ nginx: master process /usr/local/nginx/sbin/nginx
└─ nginx: worker process 4月 :: node2.jinglong systemd[]: Starting The NGINX HTTP and reverse proxy server...
4月 :: node2.jinglong nginx[]: nginx: the configuration file /usr/local/ngin...ok
4月 :: node2.jinglong nginx[]: nginx: configuration file /usr/local/nginx/co...ul
4月 :: node2.jinglong systemd[]: Started The NGINX HTTP and reverse proxy server.
Hint: Some lines were ellipsized, use -l to show in full.
此时为running,启动成功,执行
[root@node2 sbin]# curl 127.0.0.1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>
获取页面成功
建立软连接
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
此时nginx可以在任意目录下执行命令
centos7编译安装nginx的更多相关文章
- Centos7 编译安装 Nginx PHP Mariadb Memcached 扩展 ZendOpcache扩展 (实测 笔记 Centos 7.3 + Mariadb 10.1.20 + Nginx 1.10.2 + PHP 7.1.0 + Laravel 5.3 )
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...
- CentOS7 编译安装 Nginx (实测 笔记 Centos 7.0 + nginx 1.6.2)
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...
- Centos7 编译安装 Nginx Mariadb Asp.net Core2 (实测 笔记 Centos 7.3 + Openssl 1.1.0h + Mariadb 10.3.7 + Nginx 1.14.0 + Asp.net. Core 2 )
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...
- Centos7 编译安装 Nginx PHP Mariadb Memcached 扩展 ZendOpcache扩展 (实测 笔记 Centos 7.3 + Openssl 1.1.0e + Mariadb 10.1.22 + Nginx 1.12.0 + PHP 7.1.4 + Laravel 5.4 )
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...
- Centos7 编译安装 Nginx、MariaDB、PHP
前言 本文主要大致介绍CentOS 7下编译安装Nginx.MariaDB.PHP.面向有Linux基础且爱好钻研的朋友.技艺不精,疏漏再所难免,还望指正. 环境简介: 系统: CentOS 7,最小 ...
- Centos7 编译安装 Nginx PHP Mariadb Memcache扩展 ZendOpcache扩展 (实测 笔记 Centos 7.0 + Mariadb 10.1.9 + Nginx 1.9.9 + PHP 5.5.30)
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1503-01.iso 安装步骤: 1.准备 1.1 ...
- centos7编译安装nginx及无缝升级https
安装依赖: yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel 下载nginx: wget -c ...
- Centos7编译安装Nginx+keepalived
一.安装环境.主机信息及软件版本 Nginx:1.12.2keepalived:2.0.12时间同步(同步后确认各服务器时间是否一致,不一致需要修改一下时区) 关闭防火墙 二.编译安装Nginx 1. ...
- Centos7 编译安装Nginx 教程
相信经过上篇博文的学习,聪明的你已经学会了如何在Centos7 上通过yum 方式安装Nginx ,但是有时候有些场景或者特俗情况下,我们往往需要通过编译源码方式安装,以便于更灵活地定制我们的Ngin ...
- CentOS7 编译安装Nginx+php并配置php-fpm模块
1.编译安装PHP7.2.0 去官网下载安装包:http://php.net/downloads.php ,完成之后,上传至服务器,并释放压缩包 .tar.gz cd php- 因为我们需要编译安装, ...
随机推荐
- 关于git merge,rebase合并的差别,以及*(no branch)的处理。
1.merge 在上篇介绍分支的时候有简单的说了一下分支的创建和合并,当时合并就是写的merge,这是依据两个不同分支的最后一次提交的commit对象c5,c7和两个分支的交叉点的commit对象c3 ...
- 【剑指Offer】只出现一次的字符
题目描述 请实现一个函数用来找出字符流中第一个只出现一次的字符.例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g".当从该字符流中读出 ...
- [ZZ]MTSC 2017 Mobile Testing@Google 演讲的感受
原文地址: https://testerhome.com/topics/9364 Mobile Testing@Google 其实在开始听谷歌的张南和潘岩开始演讲前,了解下 Google Test C ...
- python-setuptool安装
安装setuptools时报error: ”RuntimeError: Compression requires the (missing) zlib module“ 解决办法: yum安装zlib和 ...
- DOM 核心
继承在DOM中的重要性: 1. Node 对象 2. Element 对象 3. Document 对象
- jmeter接口测试-GET请求路径中包含特殊字符或中文导致Response400报错
问题描述:接口测试中异常用例GET请求路径中包含特殊字符或中文,运行jmeter会报错,取样器中只能看到Response400,响应结果为空 解决思路: 对于通过BODY发送的中文内容可以用Jmete ...
- C#动态给Word文档填充内容
//filePath:word文档的路径:strOld:需要替换的内容:strNew:替换的新内容: //注意:strOld中的字符数量要与新的strNew中的一一对应 public static v ...
- 在Spring Boot中使用 @ConfigurationProperties 注解
但 Spring Boot 提供了另一种方式 ,能够根据类型校验和管理application中的bean. 这里会介绍如何使用@ConfigurationProperties.继续使用mail做例子. ...
- C# 使用缓存数据模拟抢购
在所有的电商网站中,不乏大量的抢购,比如双十一,双十二等等,作为一名开发人员考虑最多的就是多并发以及高并发 废话少说,开始写代码.我用了C#的MemoryCache代替试下流行的各种缓存 商品测试 ...
- 使用JavaScript制作页面特效2
1.Date对象的常用方法 setFullYear() setMonth() setDate() setHours() setMinutes() setSeconds() 定时函数 setTimeou ...