深刻理解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下 ...
随机推荐
- Node.js:路由
ylbtech-Node.js:路由 1.返回顶部 1. Node.js 路由 我们要为路由提供请求的 URL 和其他需要的 GET 及 POST 参数,随后路由需要根据这些数据来执行相应的代码. 因 ...
- javascript设计模式-单体模式
场景:假设有一个Girl(美女)实体,该实体拥有姓名.年龄两个属性,拥有显示姓名和洗澡两个方法,下面分步骤构造该实体. 1.用简单基本单体模式: var Girl1 = { name:"昭君 ...
- HTML中href、src区别
href是Hypertext Reference的缩写,表示超文本引用.用来建立当前元素和文档之间的链接.常用的有:link.a.例如: <link href="reset.css&q ...
- Mysql数据类型(一)
介绍 存储引擎决定了表的类型,而表内存放的数据也要有不同的类型,每种数据类型都有自己的宽度,但宽度是可选的 详细参考链接:http://www.runoob.com/mysql/mysql-data- ...
- Mysql数据的增删改
插入数据 INSERT 更新数据 UPDATE 删除数据 DELETE 再来回顾一下之前我们练过的一些操作,相信大家都对插入数据.更新数据.删除数据有了全面的认识.那么在mysql中其实最重要的不 ...
- python之路——二分查找算法
楔子 如果有这样一个列表,让你从这个列表中找到66的位置,你要怎么做? l = [2,3,5,10,15,16,18,22,26,30,32,35,41,42,43,55,56,66,67,69,72 ...
- python简易版学生管理系统
#coding=utf- def showInfo(): print("**************") print(" 学生管理系统") print(&quo ...
- Hadoop MapReduce编程 API入门系列之统计学生成绩版本2(十八)
不多说,直接上代码. 统计出每个年龄段的 男.女 学生的最高分 这里,为了空格符的差错,直接,我们有时候,像如下这样的来排数据. 代码 package zhouls.bigdata.myMapRedu ...
- 超级简单的利用javascript实现文件拖拽事件
1.效果图: 2.源码 <%@ page contentType="text/html;charset=UTF-8" language="java" %& ...
- RGB_D_开发征程(使用Kinect)
学习历程依此为纲! Kinect学习资料: kinect和openNI开发资料汇总:http://blog.csdn.net/chenli2010/article/details/6887646 原始 ...