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- 因为我们需要编译安装, ...
随机推荐
- JavaScript中数组的应用
Array的应用 1)创建 new Array();new Array(size);new Array(element,element,...,element); 2).Array对象属性 const ...
- Java Socket NIO
服务端: public class NIOServer { private static final String HOST = "localhost"; private stat ...
- Android Studio Gradle依赖冲突
版本冲突 Gradle提供了两种解决版本冲突的策略:Newest和Fail.默认策略是Newest,配置Fail模式: configurations.all { resolutionStrategy. ...
- java.util.concurrent包下集合类的特点与适用场景
java.util.concurrent包,此包下的集合都不允许添加null元素 序号 接口 类 特性 适用场景 1 Queue.Collection ArrayBlockingQueue 有界.阻塞 ...
- Arrays和String单元测试
20175227张雪莹 2018-2019-2 <Java程序设计> Arrays和String单元测试 要求 在IDEA中以TDD的方式对String类和Arrays类进行学习 测试相关 ...
- awesome资源包
.NET资源包 https://github.com/jobbole/awesome-dotnet-cn java资源包 https://github.com/jobbole/awesome-java ...
- windows环境 springboot+docker开发环境搭建与hello word
1,下载安装 docker toolbox 下载地址:http://mirrors.aliyun.com/docker-toolbox/windows/docker-toolbox/ docker t ...
- Nuget调用简单封装.
1. 项目引用Dapper作为直接访问, 为了使用方便, 封装一下.达到效果: - 数据库连接配置在webconfig.xml中. - 常用调用方法封装. 调用: //可以采用单例模式. //全局实 ...
- java构建工具——ant使用
Ant是跨平台的构建工具,它可以实现项目的自动构建和部署等功能.在本文中,主要让读者熟悉怎样将Ant应用到Java项目中,让它简化构建和部署操作. 一.安装与部署 1.1 下载 下载地址:https: ...
- react-native No bundle URL present
解决方案: 1.删除ios目录下的build的目录,关闭模拟器,重新react-native run-ios大多数情况下可以解决 2.