nginx 安装 (一)
来源:互联网 发布:时间戳java显示gmt时间 编辑:程序博客网 时间:2024/05/16 14:49
1. 环境
硬件:CORE I5 4核 + 4G DDR3 + 1Gb网卡 + 100Mb交换机
OS:centos 5.62. 安装步骤
a. 安装nginx-release-centos-5-0.el5.ngx.noarch.rpm,安装后可以通过yum来安装nginx
[root@x ~]# wget http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm [root@x ~]# rpm -ivh nginx-release-centos-5-0.el5.ngx.noarch.rpmb. 安装nginx
[root@x ~]# yum install nginxc. 配置nginx.conf
[root@x nginx]# pwd /etc/nginx [root@x nginx]# vi nginx.conf user nginx; worker_processes 4; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { use epoll; worker_connections 65535; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 15; #gzip on; include /etc/nginx/conf.d/*.conf; }d. 测试配置文件格式是否正确
[root@x nginx]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: [warn] 65535 worker_connections are more than open file resource limit: 1024 nginx: configuration file /etc/nginx/nginx.conf test is successfule. 修改OS参数
[root@x conf.d]# vi /etc/security/limits.conf # /etc/security/limits.conf#
#Each line describes a limit for a user in the form:##<domain> <type> <item> <value>##Where:#<domain> can be:# - an user name# - a group name, with @group syntax# - the wildcard *, for default entry# - the wildcard %, can be also used with %group syntax,# for maxlogin limit##<type> can have the two values:# - "soft" for enforcing the soft limits# - "hard" for enforcing hard limits##<item> can be one of the following:# - core - limits the core file size (KB)# - data - max data size (KB)# - fsize - maximum filesize (KB)# - memlock - max locked-in-memory address space (KB)# - nofile - max number of open files# - rss - max resident set size (KB)# - stack - max stack size (KB)# - cpu - max CPU time (MIN)# - nproc - max number of processes# - as - address space limit# - maxlogins - max number of logins for this user# - maxsyslogins - max number of logins on the system# - priority - the priority to run user process with# - locks - max number of file locks the user can hold# - sigpending - max number of pending signals# - msgqueue - max memory used by POSIX message queues (bytes)# - nice - max nice priority allowed to raise to# - rtprio - max realtime priority##<domain> <type> <item> <value>##* soft core 0#* hard rss 10000#@student hard nproc 20#@faculty soft nproc 20#@faculty hard nproc 50#ftp hard nproc 0#@student - maxlogins 4* - nofile 65535# End of file修改配置后,重启主机使配置生效。
f. 再次测试nginx配置
[root@x ~]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successfulg. 启动nginx
[root@x ~]# nginx[root@x ~]# ps -ef|grep nginxroot 4062 1 0 12:12 ? 00:00:00 nginx: master process nginxnginx 4063 4062 0 12:12 ? 00:00:00 nginx: worker processnginx 4064 4062 0 12:12 ? 00:00:00 nginx: worker processnginx 4065 4062 0 12:12 ? 00:00:00 nginx: worker processnginx 4066 4062 0 12:12 ? 00:00:00 nginx: worker processroot 4068 3898 0 12:12 pts/1 00:00:00 grep nginx
h. 重启nginx
编写restart.sh脚本
[root@x ~]# vi renginx.sh#/bin/shkill -HUP `cat /var/run/nginx.pid`[root@x ~]# chmod +x renginx.sh [root@x ~]# ps -ef|grep nginxroot 4062 1 0 12:12 ? 00:00:00 nginx: master process nginxnginx 4063 4062 0 12:12 ? 00:00:00 nginx: worker processnginx 4064 4062 0 12:12 ? 00:00:00 nginx: worker processnginx 4065 4062 0 12:12 ? 00:00:00 nginx: worker processnginx 4066 4062 0 12:12 ? 00:00:00 nginx: worker processroot 4083 3898 0 12:16 pts/1 00:00:00 grep nginx[root@x ~]# ./renginx.sh[root@x ~]# ps -ef|grep nginroot 4062 1 0 12:12 ? 00:00:00 nginx: master process nginxnginx 4087 4062 0 12:16 ? 00:00:00 nginx: worker processnginx 4088 4062 0 12:16 ? 00:00:00 nginx: worker processnginx 4089 4062 0 12:16 ? 00:00:00 nginx: worker processnginx 4090 4062 0 12:16 ? 00:00:00 nginx: worker processroot 4099 3898 0 12:17 pts/1 00:00:00 grep ngini. 关闭nginx
[root@x ~]# nginx -s stop [root@x ~]# ps -ef|grep nginx root 4104 3898 0 12:18 pts/1 00:00:00 grep nginx
- nginx 安装 (一)
- nginx学习(一)nginx安装
- Nginx系列(一.安装nginx)
- 初识Nginx(一):nginx的安装
- nginx安装配置(一)
- Nginx安装使用(一)
- 实战nginx基础知识(一)1.2 windows 安装nginx
- Nginx学习笔记(一):nginx的安装和配置
- cent7配置nginx(一),nginx基础安装
- nginx 学习笔记(一)nginx 编译安装
- cent7配置nginx(一),nginx编译安装
- Nginx系列(一)Linux安装
- Nginx的安装与配置(一)
- Fastdfs+nginx---(一) 安装前准备
- Mac安装Nginx、配置PHP(一)
- nginx实践(一)、安装和部署
- CentOS 6.5安装Nginx (一)
- Nginx详细安装部署教程(一)
- 怎么判断一帧的开始
- 程序员们 不要想一辈子靠技术混饭吃 金典
- Hibernate知识总结
- Chrome浏览器强制http重定向到https的简单方法
- 注册 内部类BroadcaseReceive
- nginx 安装 (一)
- Iterator迭代的过程中使用list.remove
- launcher修改--获取屏幕缩略(预览)图
- 微博也参与搜索结果排名
- 关于DWR的某个纠结的问题
- 产品设计 - 从产品的角度调研网站
- 圆的面积
- [Android] Adapter:SimpleAdapter SimpleCursorAdapter ArrayAdapter 与ListView的用法
- 《软件架构师应该知道的97件事》