nginx学习(一):基本安装
转载自http://summervast.blog.51cto.com/690507/385511
注意:可能因版本不同,个别指令不起作用,需要注意版本灵活安装,我在安装时也遇到过此问题
开始学习nginx,初步安装nginx,先熟悉一下;参考网上的资料和涨宴老师书籍。
http://nginx.org/en/download.html
下载需要的版本,0.7版本的是稳定版本,0.8的是开发版本,看个人所好,我用的是nginx-0.8.48;
一、安装
1、检查安装nginx的依赖性,nginx的模块需要第三方库的支持,检查是否安装下列库:
zlib、zlib-devel、openssl、openssl-devel、prce、prce-devel
[root@mgmserver ~]# rpm -qa |grep zlib
zlib-devel-1.2.3-3
zlib-1.2.3-3
[root@mgmserver tar_packet]# rpm -qa |grep openssl
openssl-0.9.8e-12.el5
openssl-devel-0.9.8e-12.el5
[root@mgmserver tar_packet]# rpm -qa |grep pcre
pcre-6.6-2.el5_1.7
pcre-devel-6.6-2.el5_1.7
[root@mgmserver tar_packet]# rpm -qa |grep gcc
compat-libgcc-296-2.96-138
compat-gcc-34-g77-3.4.6-4
gcc-c++-4.1.2-46.el5
libgcc-4.1.2-46.el5
compat-gcc-34-3.4.6-4
compat-gcc-34-c++-3.4.6-4
gcc-java-4.1.2-46.el5
gcc-4.1.2-46.el5
gccp-gfortran-4.1.2-46.el5
[root@mgmserver tar_packet]# rpm -qa |grep autoconf
autoconf-2.59-12
[root@mgmserver tar_packet]# rpm -qa |grep automake
automake-1.9.6-2.1
automake16-1.6.3-8
automake15-1.5-16
automake17-1.7.9-7
automake14-1.4p6-13
2、添加nginx使用的用户和组 ,
[root@mgmserver ~]# groupadd nginx #nginx使用的组;
[root@mgmserver ~]# useradd -g nginx nginx #nginx使用用户;
3、安装
[root@mgmserver ~]# cd /home/tar_packet/
[root@mgmserver tar_packet]# tar -zxvf nginx-0.8.48.tar.gz -C /home/install_packet/
[root@mgmserver tar_packet]# cd ../install_packet/
[root@mgmserver install_packet]# cd nginx-0.8.48/
[root@mgmserver nginx-0.8.48]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE README src
[root@mgmserver nginx-0.8.48]# ./configure --prefix=/usr/local/nginx \
> --user=nginx \
> --group=nginx \
> --with-http_stub_status_module \ #启用“server status"页
> --with-http_ssl_module #开启http ssl模块,使nginx可以支持https请求,这个模块需要已经
安装openssl
checking for OS
+ Linux 2.6.18-164.el5 i686
checking for C compiler ... found
checking for gcc builtin atomic operations ... not found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for sched_setaffinity() ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for SO_SETFIB ... not found
checking for PCRE library ... found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/Makefile
checking for int size ... 4 bytes
checking for long size ... 4 bytes
checking for long long size ... 8 bytes
checking for void * size ... 4 bytes
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system endianess ... little endianess
checking for size_t size ... 4 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 4 bytes
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for strerror_r() ... found but is not working
checking for gnu style strerror_r() ... found
checking for sys_errlist[] ... found
checking for localtime_r() ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1 library is not used
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@mgmserver nginx-0.8.48]#make
[root@mgmserver nginx-0.8.48]#make install
二、启动nginx
[root@mgmserver nginx]# /usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf
参数"-c"指定了配置文件的路径,如果不加'-c"参数, nginx,会默认加载其安装目录中conf子目录中的nginx.conf文件。


[root@mgmserver nginx-0.8.48]# ps -ef |grep nginx

可以看到一个主nginx的进程信息,一个子进程;如果在安装过程指定了“-pid-path=<path>那么该文件就指定了nginx的主进程号,如果没有指定pid文件的存放路径,nginx.pid默认存放在nginx安装目录的logs子目录下,
[root@mgmserver logs]# ls
access.log error.log nginx.pid
[root@mgmserver logs]# cat nginx.pid
6019
三、nginx的信号控制
◆ TERM,INT 快速关闭
◆ QUIT 从容关闭
◆ HUP 平滑重启,重新加载配置文件
◆ USR1 重新打开日志文件,在切割日志时用途较大;
◆ USR2 平滑升级可执行程序
◆ WINCH 从容关闭工作进程
我们可以直接通过以下命令来完成平滑重启,省下寻找nginx主进程号的步骤;
kill -"信号类型” ‘/usr/local/nginx/logs/nginx.pid'或者nginx的主进程号
(1)、从容停止nginx
[root@mgmserver ~]# kill -QUIT 6019 #nginx主进程号
[root@mgmserver logs]# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid`
(2)、快速停止nginx
[root@mgmserver logs]# kill -TERM /INT nginx主进程号
[root@mgmserver logs]# kill -TERM /INT `cat /usr/local/nginx/logs/nginx.pid
(3)、强制停止所有的nginx进程
#pkill -9 nginx
(4)、平滑重启nginx
修改了nginx的配置文件要重启nginx;重启之前要检查配置文件是否正确:
[root@mgmserver html]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@mgmserver conf]# kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
注意符号;
nginx的平滑重启
kill -HUP Nginx主进程号
或者
kill -HUP ·nginx.pid文件按存放路径·
nginx学习(一):基本安装的更多相关文章
- Nginx 学习笔记之安装篇
在windows下安装Nginx其实非常简单,只需如下几个步骤: 1. 在Nginx官网下载相应版本的安装程序,上面有最新版.稳定版等各种版本,正式运营的项目建议下载最新的稳定版 2.将下载后的压缩包 ...
- nginx学习(一):安装nginx
学习下nginx,本篇文章主要讲解下在linux下安装nginx 下载nginx 安装包 1.去官网http://nginx.org/下载对应的nginx包,推荐使用稳定版本: 2.上传tar包到li ...
- (Nginx学习一)安装和启动及对应文件夹介绍
nginx 安装和启动及对应文件夹介绍 1 安装 官网下载nginx文件 http://nginx.org/en/download.html 解压即可 2 文件夹介绍 在解压后nginx压缩包后发现 ...
- nginx学习与配置-安装与启动关闭管理
nginx服务器的安装 安装准备: nginx依赖于pcre库,要先安装pcre yum install pcre pcre-devel cd /usr/local/src/ wget wget ht ...
- nginx学习之详细安装篇(二)
1. 选择稳定版还是主线版 主线版:包含最新的功能和bug修复,但该版本可能会含有一些属于实验性的模块,同时可能会有新的bug,所以如果只是做测试使用,可以使用主线版. 稳定版:不包含最新的功能,但修 ...
- nginx学习之简化安装篇(一)
环境:CentOS 6.5 1. 安装依赖环境 [root@localhost ~]# yum install pcre-devel zlib-devel openssl-devel -y 2. 安装 ...
- Nginx学习笔记之应用篇
Nginx服务器的安装请参考Nginx学习笔记之安装篇 关于Nginx配置文档的API在这里就不一一列出,现在我们来配置第一个Nginx架构实现负载均衡的网站. 1.打开IIS,配置如下站点 重复上述 ...
- [转帖]nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件
nginx学习,看这一篇就够了:下载.安装.使用:正向代理.反向代理.负载均衡.常用命令和配置文件 2019-10-09 15:53:47 冯insist 阅读数 7285 文章标签: nginx学习 ...
- Windows+Nginx+Tomcat整合的安装与配置学习笔记
以下全部是nginx在window7下运行的: nginx学习总结: 我的是放在F盘 1.启动:F:\nginx-1.10.2\nginx-1.10.2>start nginx.exe(找到相应 ...
- CentOS学习笔记--Tomcat安装
Tomcat安装 通常情况下我们要配置Tomcat是很容易的一件事情,但是如果您要架设多用户多服务的Java虚拟主机就不那么容易了.其中最大的一个问题就是Tomcat执行权限.普通方式配置的Tomca ...
随机推荐
- 机器学习中的矩阵方法04:SVD 分解
前面我们讲了 QR 分解有一些优良的特性,但是 QR 分解仅仅是对矩阵的行进行操作(左乘一个酉矩阵),可以得到列空间.这一小节的 SVD 分解则是将行与列同等看待,既左乘酉矩阵,又右乘酉矩阵,可以得出 ...
- Servlet学习 (HttpServletRequest HttpServletResponse)
1.什么事servlet? 答:服务器端程序, 自定义的服务类型.tomcat是一个容器,这个容器提供各种菜的服务, 我们需要为里面放菜! web服务器就是我们的开发环境和开发基础. 实现了servl ...
- 【转】div居中代码 DIV水平居中显示CSS代码
原文地址:http://www.divcss5.com/rumen/r622.shtml 如何使用CSS让DIV居中显示,让div水平居中有哪些CSS样式呢? 需要的主要css代码有两个,一个为tex ...
- sort+awk+uniq三者结合使用
(1)统计文件中出现次数最多的前10个单词 #ps -ef > ps.file #cat ps.file | awk ‘{print $1}’ | sort | uniq -c | sort - ...
- 【BZOJ-2818】Gcd 线性筛
2818: Gcd Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 3347 Solved: 1479[Submit][Status][Discuss ...
- 【poj1236】 Network of Schools
http://poj.org/problem?id=1236 (题目链接) 题意 给定一个有向图,求:1.至少要选几个顶点,才能做到从这些顶点出发,可以到达全部顶点:2.至少要加多少条边,才能使得从任 ...
- Erlang第三课 ---- 创建和使用module
----------------小技巧----------------------------- 因为这一课开始,我们要使用Erlang文件操作,所以,我们期待启动shell的时候,当前目录最好是是我 ...
- android4.0浏览器在eclipse中编译的步骤
工程源码: 注意: 如果下载已经修过的源码,只要进行3.4.8步骤就应该可以了. eclipse版本:adt-bundle-windows (Android Developer Tools Build ...
- 02 C语言指针
今天发帖记录自己学习C语言精髓的心理历程,人生就像是一次旅途,沿途总是能看到最美的风景,让我们的思想相逢在C语言中. 一 初识指针,指针的定义 指针是C语言中的一种类型,类似于整形,字符型等.既然C指 ...
- hdu 2050 折线分割平面
训练递推用题,第一次做这个题,蒙的,而且对了. #include <stdio.h> int main(void) { int c,a; scanf("%d",& ...