centos7下安装ngnix1.8.1
参考 http://www.linuxidc.com/Linux/2016-09/134907.htm
安装依赖
openssl zlib pcre gcc
下载安装包
[root@localhost src]# wget http://nginx.org/download/nginx-1.8.1.tar.gz
解压缩安装包
[root@localhost src]# tar -zxvf nginx-1.8.1.tar.gz -C /usr/local
安装 gcc
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装
[root@localhost nginx-1.8.1]# yum -y install gcc-c++
安装 pcre pcre-devel
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:
[root@localhost nginx-1.8.1]# yum -y install pcre-devel
安装 zlib-devel
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
[root@localhost nginx-1.8.1]# yum -y install zlib-devel
OpenSSL 安装
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
[root@localhost nginx-1.8.1]# yum install -y openssl openssl-devel
安装nginx
[root@localhost nginx-1.8.1]# ./configure #默认安装到/usr/local/nginx目录下
[root@localhost nginx-1.8.1]# make #编译
[root@localhost nginx-1.8.1]# make install #安装
启动ngnix
[root@localhost local]# cd /usr/local/nginx/sbin
[root@localhost sbin]# ./nginx #启动命令注意输入的 点和斜杠,如果直接输入 nginx会提示 "bash: nginx: 未找到命令..."
查看nginx进程
[root@localhost sbin]# ps -ef|grep nginx
root 5455 1 0 06:24 ? 00:00:00 nginx: master process ./nginx
nobody 5456 5455 0 06:24 ? 00:00:00 nginx: worker process
root 5500 4179 0 06:26 pts/1 00:00:00 grep --color=auto nginx
从容停止-杀死进程
kill -QUIT 5455
快速停止-杀死进程
kill -TERM 5455
强制停止-杀死进程
kill -9 5455
在浏览器访问 http://localhost
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at
nginx.com.
Thank you for using nginx.
nginx目录下内容
[root@localhost nginx]# ll
总用量 4
drwx------. 2 nobody root 6 3月 27 23:02 client_body_temp
drwxr-xr-x. 2 root root 4096 3月 27 23:04 conf
drwx------. 2 nobody root 6 3月 27 23:02 fastcgi_temp
drwxr-xr-x. 2 root root 40 3月 27 22:57 html
drwxr-xr-x. 2 root root 58 3月 28 06:24 logs
drwx------. 2 nobody root 6 3月 27 23:02 proxy_temp
drwxr-xr-x. 2 root root 19 3月 27 22:57 sbin
drwx------. 2 nobody root 6 3月 27 23:02 scgi_temp
drwx------. 2 nobody root 6 3月 27 23:02 uwsgi_temp
[root@localhost nginx]#
nginx常用命令
nginx -t:检查配置文件是否正确。这个命令可以检查nginx.conf配置文件其格式、语法是否正确。如果配置文件存在错误,则会出现相应提示;如果nginx.conf文件正确,也会出现相应的成功提示。
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
nginx -s reload:重加载/重启nginx——以新的nginx.conf配置文件中的定义。
nginx -s stop:停止nginx。必须有-s参数
centos7下安装ngnix1.8.1的更多相关文章
- CentOS7 下 安装 supervisor以及使用
CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...
- Linux CentOs7 下安装 redis
Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装 命令如下 $ yum install gcc-c++ $ wget ht ...
- Centos7下安装配置Redsocks
Redsocks是一个开源的网络程序,代码依赖开源的libevent网络库.Redsocks允许你将所有TCP连接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安装配 ...
- CentOS7下安装SVN服务端
CentOS7下安装SVN服务 1. yum命令即可方便的完成安装# sudo yum install subversion 测试安装是否成功:# svnserve --version 更改svn的默 ...
- centOS7下安装GUI图形界面
1.如何在centOS7下安装GUI图形界面 当你安装centOS7服务器版本的时候,系统默认是不会安装GUI的图形界面程序,这个需要手动安装CentOS7 Gnome GUI包. 2.在系统下使用命 ...
- CentOS7下安装MySQL并配置远程连接
一.CentOS7下安装MySQL数据库 CentOS7默认的安装包里面已经没有 MySQL-Server安装包了,远程镜像中也没有了. 默认的是MariaDB (MySQL的一个分支,开发这个分支的 ...
- Docker学习笔记3:CentOS7下安装Docker-Compose
Docker-Compose是一个部署多个容器的简单但是非常必要的工具. 安装Docker-Compose之前,请先安装 python-pip,请参考我的另一篇博文CentOS7下安装python-p ...
- docker(一) Centos7下安装docker
docker(一) Centos7下安装dockerdocker(二) windows10下安装dockerdocker(三) 镜像和容器常用命令 docker(四) 使用Dockerfile构建镜像 ...
- centos7 下 安装部署nginx
centos7 下 安装部署nginx 1.nginx安装依赖于三个包,注意安装顺序 a.SSL功能需要openssl库,直接通过yum安装: #yum install openssl b.gzip模 ...
随机推荐
- mstsc远程登录设置
mstsc终于可以连上了, 1.系统属性 远程允许, 2.开启三个服务: Remote Desktop ConfigurationRemote Desktop ServicesRemote Deskt ...
- android实现解析webservices
package com.example.ksoap2demo; import java.io.UnsupportedEncodingException; import org.ksoap2.SoapE ...
- 【谷歌浏览器】在任意页面运行JS
1.使用谷歌浏览器的调试功能: 在任何页面上运行代码片段 · Chrome 开发者工具中文文档 注:比较简单,直接,不过只能本地执行,只能自己使用.且需自行保存JS文件: 2.使用油猴插件: Tamp ...
- mybatis循环map
一.循环key <foreach collection="map.keys" item="key" separator="and"&g ...
- php strcmp()字典排序
字典排序(lexicographical order)是一种对于随机变量形成序列的排序方法.其方法是,按照字母顺序,或者数字小大顺序,由小到大的形成序列. 比如,字典中a-z,是依次递增的,a,b,c ...
- linux运维 vi vim q 的间接注释
w q --不发生写的写,无增删效果. 点q后,再次执行 vi /var/www/share/w.php 仍然会‘ Found a swap file by the name "/var/ ...
- php accumulation rockmongo
php -r 'echo substr(sprintf("%o",fileperms("./")),-4);'
- DRF(5) - 频率组件、url注册器、响应器、分页器
一.频率组件 1.使用DRF简单频率控制实现对用户进行访问频率控制 1)导入模块,定义频率类并继承SimpleRateThrottle # 导入模块 from rest_framework.throt ...
- 商业模式画布模板——From 《商业模式新生代》
看过<商业模式新生代>这本书,确实受益匪浅.书籍本身编写的形式很新颖,以此为模板可以启发自己对于商业模式的思考和定义,五星推荐!!! 下面是用PPT重新绘制的商业模式画布以及说明,希望对大 ...
- 批量处理任务进度条控制—基于BackgroundWorker
今天要做一个批量处理图层数据的功能,希望在处理任务过程中,各个任务都能在进度条中显示自己的当前进度,决定继续使用强大易用的BackgroundWorker组件.通过在RunWorkerComplete ...