lnmp的安装--nginx
1.nginx的安装
安装所需环境
Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 CentOS 7 作为安装环境。
一. gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
yum install gcc-c++
二. PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:
yum install -y pcre pcre-devel
三. zlib 安装
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
yum install -y zlib zlib-devel
四. OpenSSL 安装
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
yum install -y openssl openssl-devel
五.安装nginx
1.直接下载.tar.gz
安装包,地址:https://nginx.org/en/download.html
wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
2.使用默认配置
./configure
3.自定义配置(不推荐)
./configure \
--prefix=/usr/local/nginx
4.编译安装
make
make install
启动、停止nginx
cd /usr/local/nginx/sbin/
./nginx #启用
./nginx -s stop
./nginx -s quit
./nginx -s reload
./nginx -s quit
:此方式停止步骤是待nginx进程处理任务完毕进行停止。./nginx -s stop
:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
查询nginx进程:
ps aux|grep nginx
重启 nginx
1.先停止再启动(推荐):
对 nginx 进行重启相当于先停止再启动,即先执行停止命令再执行启动命令。如下:
./nginx -s quit
./nginx
2.重新加载配置文件:
当 ngin x的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用-s reload
不用先停止 ngin x再启动 nginx 即可将配置信息在 nginx 中生效,如下:
./nginx -s reload
启动成功后,在浏览器可以看到这样的页面:
开机自启动
即在rc.local
增加启动代码就可以了。
vi /etc/rc.local
增加一行 /usr/local/nginx/sbin/nginx
设置执行权限:
chmod 755 rc.local
nginx的一些参数:
1、验证nginx配置文件是否正确
方法一:进入nginx安装目录sbin下,输入命令./nginx -t
方法二:在启动命令-c前加-t: ./nginx -t -c
# /usr/www/nginx/sbin/nginx -h
nginx version: nginx/0.7.63
Usage: nginx [-?hvVt] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file
参考资料:http://www.linuxidc.com/Linux/2016-09/134907.htm
最新文章
- 虚拟机上装uoj
- [手机取证] CelleBrite UFED Touch系列使用视频
- [No00003D]操作系统Operating Systems信号量的代码实现Coding Semaphore &;死锁处理Deadlock
- 关于Quartus II 13.0对应开发NIOS II软件程序时报错Symbol 'NULL' could not be resolved问题的解决方法
- 多线程相关Interlocked.Increment问题
- 视频最后用使用了function(i,ot)一笔带过,但我看不懂i和ot这2个参数的具体值是怎么获取得到的,能不能说一下参数传递过程?
- Delphi 实现任务栏多窗口图标显示(使用WS_EX_APPWINDOW风格)
- 模拟在内存中的数据库DataSet相关的类
- Redis -->; Redis架构设计
- [Codeforces 864A]Fair Game
- Markdown-----Markdown使用文档
- 博客编辑器Open Live Writer的安装以及配置
- Linux系统安装IonCube的方法详解教程
- swift--CATransform3D的简单介绍
- 20172325 2017-2018-2 《Java程序设计》第十周学习总结
- 一维maxpooling
- Mac下进行基于java服务端语言的微信公众号本地js-sdk调试的大致方法
- 知识共享图文直播---(一)将数据库中的数据加载到MSFlexGrid空间中再导入Excel
- CSS3饼状loading效果
- selenium 实现浏览器 前进和后退
热门文章
- Java 链式写法
- 【WIP_S3】链表
- springboot(二)整合mybatis,多数据源和事务管理
- Spring Cloud学习(一)
- [ CodeForces 515 D ] Drazil and Tiles
- CF842C Ilya And The Tree
- python--12、pymysql模块
- Ubuntu下查看服务器cpu是否支持VT
- 【sqli-labs】 less65 GET -Challenge -Blind -130 queries allowed -Variation4 (GET型 挑战 盲注 只允许130次查询 变化4)
- HDU_1233_还是畅通工程