深刻理解Nginx之Nginx完整安装
1. Nginx安装
1.1预先准备
CentOS系统下,安装Nginx的库包依赖。
安装命令例如以下:
sudo yum groupinstall "DevelopmentTools"
sudo yum install pcre pcre-devel
sudo yum install zlib zlib-devel
yum install perl-ExtUtils-Embed
sudo yum install openssl openssl-devel
1.2 安装
最重要的特性和基于http和https内容的模块化,configuration參数能够这样:
./configure --prefix=/usr/local/nginx-1.5.13--user=app --group=app --with-http_ssl_module --with-http_realip_module
安装全部必要的模块:
./configure --user=app --group=app--with-http_ssl_module --with-http_realip_module --with-http_addition_module--with-http_xslt_module --with-http_image_filter_module--with-http_geoip_module --withhttp_sub_module --with-http_dav_module--with-http_flv_module --withhttp_mp4_module --with-http_gzip_static_module--with-http_random_index_module --with-http_secure_link_module--with-http_stub_status_module --with-http_perl_module--with-http_degradation_module
使用root用户,或者管理员用户来运行这个命令。
sudo make & sudo make install
….
cp conf/scgi_params '/usr/local/nginx-1.5.13/conf/scgi_params.default'
test -f '/usr/local/nginx-1.5.13/conf/nginx.conf' || cp conf/nginx.conf'/usr/local/nginx-1.5.13/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx-1.5.13/conf/nginx.conf.default'
test -d '/usr/local/nginx-1.5.13/logs' || mkdir -p'/usr/local/nginx-1.5.13/logs'
test -d '/usr/local/nginx-1.5.13/logs' || mkdir -p'/usr/local/nginx-1.5.13/logs'
test -d '/usr/local/nginx-1.5.13/html' || cp -R html'/usr/local/nginx-1.5.13'
test -d '/usr/local/nginx-1.5.13/logs' || mkdir -p'/usr/local/nginx-1.5.13/logs'
make[1]: Leaving directory `/home/app/Downloads/nginx-1.5.13'
1.3 測试
測试Nginx配置是否正确。能够使用下列命令:
启动Nginx
#sudo /usr/local/nginx-1.5.13/sbin/nginx
浏览页面http://localhost,得到的结果:
Welcome to nginx!
2 使用命令
成功安装Nginx后,有必要了解一下主要的命令。
nginx –s stop Stops the daemon immediately (using the TERM signal)
nginx –s quit Stops the daemon gracefully (using the QUIT signal)
nginx –s reopen Reopens the log files
nginx –s reload Reloads the configuration
停掉nginx进程,输入命令:
killall nginx
測试配置是否成功:
[app@hadoop-master sbin]$ sudo/usr/local/nginx/sbin/nginx -t
[sudo] password for app:
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命令,输入:
[app@hadoop-mastersbin]$ ./nginx -h
nginxversion: nginx/1.5.13
Usage:nginx [-?hvVtq] [-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
-q : suppress non-error messages during configuration testing
-ssignal : send signal to a masterprocess: 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 ofconfiguration file
以下一个表中呈现了不同执行级别和它们的含义。
对系统的进程的执行级别有一定了解后,我们将Nginx加到系统服务(service)中。
须要在/etc/init.d文件夹下,创建nginx脚本。比如,nginx脚本能够这样配置:
---------------------------------------------------------------------------------------------------
保持后,改动运行权限。
#sudo chmod +x /etc/init.d/nginx
又一次启动Nginx:
sudo /usr/init.d/nginx reload
加入nginx到自己主动启动文件列表中:
sudo chkconfig –add nginx
检測nginx的执行级别:
[app@hadoop-master~]$ sudo chkconfig --list nginx
nginx 0:off 1:off 2:off 3:off 4:off 5:off 6:off
深刻理解Nginx之Nginx完整安装的更多相关文章
- centos下gitlab私服完整安装部署(nginx+MySQL+redis+gitlab-ce+gitlab-shell+)
系统环境cat /etc/redhat-release CentOS release 6.8 (Final) nginx -vnginx version: nginx/1.9.15 redis-cli ...
- 深刻理解Nginx之基本配置和升级(2)
3 Nginx基本配置 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvam9obl9mX2xhdQ==/font/5a6L5L2T/fontsize/400 ...
- Nginx 运维(安装与使用)
Nginx 运维(安装与使用) 普通安装 Windows安装 (1)进入官方下载地址,选择合适版本(nginx/Windows-xxx). (2)解压到本地 (3)启动 下面以 C 盘根目录为例说明下 ...
- nginx(五)nginx与php的安装配置
经过前面学习,对nginx有个大概的了解,来配置LNMP;只要是在系统安装过程中选择安装比较齐全的包,基本上系统都能满足安装要求,下面是我一个一个测试的,基本上全部安装所需的库文件,放心安装: [ro ...
- centos LNMP第一部分环境搭建 LAMP LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/php/{p.conf.default,p.conf} php运行方式SAPI介绍 第二十三节课
centos LNMP第一部分环境搭建 LAMP安装先后顺序 LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/local/php/{ ...
- linux服务器nginx的卸载和安装
刚接触的linux服务器上,nginx配置乱的有点令人发指,就把老的卸载了重新装一下. 卸载 linux有一系列的软件管理器,比如常见的linux下的yum.Ubuntu下的apt-get等等.通过这 ...
- 好记性不如烂笔头-nginx安装环境与Linux安装ftp组件
Nginx安装环境 1. Nginx安装环境 Nginx是C语言开发,建议在linux上运行,我参加工作这些年来一直使用Linux发行版之一的 Centos作为安装环境. 1.1 gcc 安装Ngin ...
- nginx初探,下载安装配置负载均衡
上一篇我讲了正向代理和反向代理的概念,这个是为nginx做准备的前置技能,网上百度nginx可以知道nginx是什么: Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/PO ...
- Nginx在linux下安装及简单命令
安装环境:Centos7 创建目录及切换至目录 # mkdir /usr/local/nginx # cd /usr/local/nginx/ 下载nginx包,访问http://nginx.org下 ...
随机推荐
- Socket server
Socket server的使用方法(精华部分),仅供自用. class MyServer(socketserver.BaseRequestHandler): def handle(self): wh ...
- Unity3d 销毁
using UnityEngine; using System.Collections; public class destroy : MonoBehaviour { void Start () { ...
- JavaScript操作HTML&CSS简单入门
- Java攻城狮学习路线 - 一. JavaScript基础 输出 使用 window.alert() 弹出警告框. 使用 document.write() 方法将内容写到 HTML 文档中. 使用 ...
- 数据结构——单链表java简易实现
巩固数据结构 单链表java实现 单链表除了表尾 每个几点都有一个后继 结点有数据和后继指针组成 通过构建表头和表尾(尾部追加需要)两个特殊几点 实现单链表的一些操作,代码如下 package co ...
- Docker的特性解析
Docker简介与入门:http://segmentfault.com/blog/p_chou/1190000000448808 Docker是个新生的事物,概念类似虚拟化.网上关于Docker入门的 ...
- 从ReadImage到ML- 一个不错的博客
实在对不起原作者,为了不把文章淹没在 转载的海洋里.... 原文链接: http://www.cnblogs.com/tornadomeet/archive/2012/09/26/270404 ...
- 0xc000007b:vs2012+Opencv2.4.4出现"0xc000007b"问题
在64位系统中,VS2012+opencv2.4.4下编程出现一个问题,我简单的读取图片就出现"应用程序无法正常启动0xc000007b"的问题:如图: 注意事项:把运行环境改成 ...
- HashMap以及ConcurrentHashMap
HashMap源码相关 HashMap实现原理及源码分析 总之就是这个博客,简直就是源码带逛,开心,最关键的是下面的图像 另外,自己的理解加上源码,总结如下 hash,原义散列,就是一对一: hash ...
- SDL2源代码分析
1:初始化(SDL_Init()) SDL简介 有关SDL的简介在<最简单的视音频播放示例7:SDL2播放RGB/YUV>以及<最简单的视音频播放示例9:SDL2播放PCM>中 ...
- 应用五:Vue之ElementUI 表格Table与分页Pagination组件化
(注:本文适用于有一定Vue基础或开发经验的读者,文章就知识点的讲解不一定全面,但却是开发过程中很实用的) 在平时的web项目开发过程中,列表分页查询展示应用的很频繁,为了便于阅读并减少代码的冗余,所 ...