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- 因为我们需要编译安装, ...
随机推荐
- Vue基础开发笔记
以下实例代码地址:https://github.com/NewBLife/VueDev 1,Vue组件导入 新建组件:Header.vue <template> <div> & ...
- [蓝桥杯]PREV-26.历届试题_最大子阵
问题描述 给定一个n*m的矩阵A,求A中的一个非空子矩阵,使这个子矩阵中的元素和最大. 其中,A的子矩阵指在A中行和列均连续的一块. 输入格式 输入的第一行包含两个整数n, m,分别表示矩阵A的行数和 ...
- windows下的端口转发命令netsh
使用下面的命令查看语法 netsh interface portproxy add v4tov4 /? add v4tov4 [listenport=]<integer>|<serv ...
- MD5 Hashing in Java
参考: MD5 Hashing in Java
- matlab画台风轨迹图小tip
<写在前面> 关于台风轨迹图,这次由于作业需要就画了一幅轨迹图,参考原图选自论文: LIU Zenghong, XU Jianping, SUN Chaohui, WU Xiaofen. ...
- Egret飞行模拟-开发记录02
1.Egret异步加载资源制作loading界面 使用EUI,EXML组件制作loading界面时,需要皮肤主题资源加载控制.即default.thm.json配置文件. 下一篇专门记录这部分. 2. ...
- 服务注册中心,Eureka比Zookeeper好在哪里?
著名的CAP理论指出,一个分布式系统不可能同时满足C(一致性).A(可用性).和P(分区容错性).由于分区容错性P在分布式系统中必须要保证的,因此我们只能在A和C之间进行权衡. 因此: Zookeep ...
- windows server 2003产生的 Minidmp蓝屏文件分析求助
在机房运行的四台服务器中均出现了蓝屏dmp文件,经过整理发现CDMS主备服务器最近(2018年1月开始)蓝屏的dmp很多.经过自己的学习分析发现不足以找到先关的原因和处理方法,希望得到大牛们的帮助.以 ...
- docker镜像的常用操作
获取镜像 比如说我们可以这样操作 当然把这个镜像拉过来时间非常长. 查看镜像列表 命令: docker images 说明: 使用docker images命令可以列出本地主机上已有的镜像. 信息 ...
- SpringMvc实现的简单原理
1.浏览器发送请求 2.服务器执行servlet的(前端控制器)解析器 3.servlet通过(前端控制器)解析器拿到所有带有@Controller注解的类,并遍历类中的所有方法 4.将遍历的方法中带 ...