深刻理解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下 ...
随机推荐
- [JavaEE] Spring事务配置的五种方式
前段时间对Spring的事务配置做了比较深入的研究,在此之间对Spring的事务配置虽说也配置过,但是一直没有一个清楚的认识.通过这次的学习发觉Spring的事务配置只要把思路理清,还是比较好掌握的. ...
- 常见Java集合的实现细节
1. Set和Map Set代表一种集合元素无序.集合元素不可重复的集合,Map则代表一种由多个key-value对组成的集合,Map集合类似于传统的关联数组.表面上看它们之间相似性很少,但实际上Ma ...
- OCC 矩阵变换
在OpenCADCADE中, 通过gp_Trsf类来进行矩阵变换操作, 采用矩阵在左的方式: 新点 = 变换矩阵 * 点 基本原理如下: //! Defines a non-persistent tr ...
- python基本数据类型之元祖tuple
元祖tuple 是对列表的二次加工,书写格式为括号(),里面放元素 元组的一级元素不可被修改,且不能被增加和删除 一般写元组的时候,推荐在最后加入逗号, 能加则加 创建元组 ? 1 tu = (11 ...
- LeetCode Weekly Contest 18B
1. 496. Next Greater Element I 暴力的话,复杂度也就1000 * 1000 = 1e6, 在1s的时限内完全可以. 当然,有许多优化方法,利用stack维护递减序列的方法 ...
- Hadoop MapReduce编程 API入门系列之自定义多种输入格式数据类型和排序多种输出格式(十一)
推荐 MapReduce分析明星微博数据 http://git.oschina.net/ljc520313/codeexample/tree/master/bigdata/hadoop/mapredu ...
- Hadoop MapReduce编程 API入门系列之wordcount版本4(八)
这篇博客,给大家,体会不一样的版本编程. 是将map.combiner.shuffle.reduce等分开放一个.java里.则需要实现Tool. 代码 package zhouls.bigdata. ...
- 同一sql程序执行比数据库执行慢
最近项目发现同一个sql在java端执行比在数据库执行慢很多,原因可能是程序的sql参数类型与数据库字段的类型不一致.
- WPF 资源管理器 WPF Explorer
最近项目中有个功能是读取外部设备的中的文件,同时由于项目样式限制,因此需要需要简单实现一个Window资源管理器功能. 由于为了接下来工作更好地完善功能,因此先一步做了一个DEMO用于参照和不断的修正 ...
- T对象序列化后T对象中属性字段不见了?
序列化:JsonConvert.SerializeObject(T) 直接在类的上面添加[Table("表名")] 在类上添加属性[DataContract] 在属性上添加属性[D ...