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参数
最新文章
- ENode框架Conference案例分析系列之 - 业务简介
- native2ascii 使用说明
- 单位圆盘的全纯自同构群Aut B(0,1)
- java_method_下载导入模版
- 树链剖分求LCA
- SWT中各种参数大全
- Uva 10780 Again Prime? No Time.(分解质因子)
- leetcode--001 max point on a line
- vue 中监测滚动条加载数据(懒加载数据)
- Linux库多重依赖
- 【已解决】报异常:java.lang.ArithmeticException: / by zero
- 洛谷P1140 基因匹配 //DP真正意义上的一血
- Resource Agent:LSB和OCF
- ASP.NET WebApi服务接口如何防止重复请求实现HTTP幂等性
- 目标检测(四)Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
- synchronized 实现同步的基础
- Spring通知方法错误
- FOR ALL ENTRIES的使用
- react-native react-navigation使用
- [原]关于phycis集成到osgearth的(瞎写写)
热门文章
- 最近5年133个Java面试问题列表
- [多媒体] m3u8简介
- boost::archive::binary_iarchive
- HDU 5892 Resident Evil
- maven2报xxxServlet cannot be cast to javax.servlet
- Scala学习之For、Function、Lazy(4)
- java反射——构造方法
- Sublime text找不到.so文件
- :nohlsearch
- <;2014 04 26>; 《Coders at Work编程人生:15位软件先驱访谈录》