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完整安装的更多相关文章

  1. 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 ...

  2. 深刻理解Nginx之基本配置和升级(2)

    3 Nginx基本配置 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvam9obl9mX2xhdQ==/font/5a6L5L2T/fontsize/400 ...

  3. Nginx 运维(安装与使用)

    Nginx 运维(安装与使用) 普通安装 Windows安装 (1)进入官方下载地址,选择合适版本(nginx/Windows-xxx). (2)解压到本地 (3)启动 下面以 C 盘根目录为例说明下 ...

  4. nginx(五)nginx与php的安装配置

    经过前面学习,对nginx有个大概的了解,来配置LNMP;只要是在系统安装过程中选择安装比较齐全的包,基本上系统都能满足安装要求,下面是我一个一个测试的,基本上全部安装所需的库文件,放心安装: [ro ...

  5. 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/{ ...

  6. linux服务器nginx的卸载和安装

    刚接触的linux服务器上,nginx配置乱的有点令人发指,就把老的卸载了重新装一下. 卸载 linux有一系列的软件管理器,比如常见的linux下的yum.Ubuntu下的apt-get等等.通过这 ...

  7. 好记性不如烂笔头-nginx安装环境与Linux安装ftp组件

    Nginx安装环境 1. Nginx安装环境 Nginx是C语言开发,建议在linux上运行,我参加工作这些年来一直使用Linux发行版之一的 Centos作为安装环境. 1.1 gcc 安装Ngin ...

  8. nginx初探,下载安装配置负载均衡

    上一篇我讲了正向代理和反向代理的概念,这个是为nginx做准备的前置技能,网上百度nginx可以知道nginx是什么: Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/PO ...

  9. Nginx在linux下安装及简单命令

    安装环境:Centos7 创建目录及切换至目录 # mkdir /usr/local/nginx # cd /usr/local/nginx/ 下载nginx包,访问http://nginx.org下 ...

随机推荐

  1. B1260 [CQOI2007]涂色paint 区间dp

    这个题和我一开始想的区别不是很大,但是要我独自做出来还是有一些难度. 每一次涂色 只有这两种可能: 1) 把一段未被 覆盖过的区间 涂成 * 色 2) 把一段被一种颜色覆盖的区间涂成 * 色 (并且 ...

  2. Node.js:目录

    ylbtech-Node.js:目录 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部 1. http://www.runoob.com/nodejs/nodejs ...

  3. [Java] 总结1.5/1.6/1.7版本的特性

    开发过程中接触到了从jdk1.5---jdk1.7的使用,在不同的阶段,都使用过了jdk的一些新特性,操作起来更加方面啦!特此总结了下,以下是测试代码: JDK1.5新特性: 1.自动装箱与拆箱: I ...

  4. ubantu下NiFi单节点安装部署

    第一步,首先下载安装包:http://nifi.apache.org/download.html,博主下载的是1.4.0版本,直接下载的是编译后的文件. 第二步:将压缩包上传到服务器相应目录下,并且解 ...

  5. office2016专业版激活码

    office2016专业版激活密钥 Office 2016 Pro Plus Retail 版激活密钥:office2016专业版激活码 [Key]:3XJTG-YNBMY-TBH9M-CWB2Y-Y ...

  6. LeetCode Weekly Contest 21

    1. 530. Minimum Absolute Difference in BST 最小的差一定发生在有序数组的相邻两个数之间,所以对每一个数,找他的前驱和后继,更新结果即可!再仔细一想,bst的中 ...

  7. 同一sql程序执行比数据库执行慢

    最近项目发现同一个sql在java端执行比在数据库执行慢很多,原因可能是程序的sql参数类型与数据库字段的类型不一致.

  8. Html Ajax上传文件,form表单下载文件

    Html中的代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type&quo ...

  9. css3 边框、背景、文本效果

    浅玩CSS3 边框.背景.文本效果 一.边框 box-shadow box-shadow: h-shadow v-shadow blur spread color inset(ontset); //h ...

  10. css relative设置top为百分比值

    前言: 最近在学习HTML.CSS的过程中,想模仿一下百度首页.发现搜索框这一部分与上下其它元素的空白距离可以随着窗口大小变化(效果如下图所示),于是自己研究了一下并记录下来. 效果实现 <!D ...