Nginx安装配置详解
http://nginx.org/download/ 下载对应的Nginx
安装nginx之前需要安装依赖包
yum install gcc gcc-c++ zlib-devel pcre-devel openssl-devel openssl-libs
cd /usr/local/src
我下载的是最新稳定版本 nginx-1.8.0.tar.gz
下载下来后解压
tar -zxvf nginx-1.8.0.tar.gz
文件夹下就有个nginx的文件夹
cd nginx-1.8.0
./configu --配置安装nginx的路径
make --编译
make install --安装
安装成功之后记得 在cd /usr/local/nginx/sbin ./nginx启动
./nginx -s reload 重启nginx
./nginx -s stop 停掉
配置 vi /usr/local/nginx/conf/nginx.conf
#user nobody;worker_processes 2;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { accept_mutex on; #设置网路连接序列化,防止惊群现象发生,默认为on multi_accept on; #设置一个进程是否同时接受多个网络连接,默认为off worker_connections 1024;#最大连接数}http { include mime.types;#文件扩展名与文件类型映射表,此映射表主要用于部署在本nginx上的静态资源 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65;#连接超时时间 gzip on; #反向代理 #【配置1】此配置是[配置4]和[配置5]的结合 #此配置将请求转发到两个WEB服务器,根据客户端IP分配目标主机,同时按权重分配流量 upstream app1 { ip_hash; server 192.168.14.132:8080 weight=5; server 192.168.14.133:80 weight=3; } #【配置2】 #默认负载平衡配置,nginx应用HTTP负载平衡来分发请求。 #upstream app1 { # server 192.168.14.132:8080; # server 192.168.14.133:80; #} #【配置3】 #最小连接负载平衡配置,nginx将尽量不使用繁忙的服务器,而是将新请求分发给不太忙的服务器。 #upstream app1 { # least_conn; # server 192.168.14.132:8080; # server 192.168.14.133:80; #} #【配置4】 #会话持久性配置,使用ip-hash,客户端的IP地址用作散列密钥, #以确定应为客户端请求选择服务器组中的哪个服务器。 #此方法确保来自同一客户端的请求将始终定向到同一服务器,除非此服务器不可用。 #upstream app1 { # ip_hash; # server 192.168.14.132:8080; # server 192.168.14.133:80; #} #【配置5】 #加权负载平衡配置,通过使用服务器权重进一步影响nginx负载平衡算法。 #未配置权重的服务器,意味着所有指定的服务器被视为对特定负载平衡方法同等资格。 #upstream app1 { # ip_hash; # server 192.168.14.132:8080 weight=3; # server 192.168.14.133:80 weight=2; # server 192.168.14.134:80; # server 192.168.14.135:80; #} server {#可配置多个server以监听不同IP和不同端口 listen 80;#监听的端口 server_name localhost;#监听的服务器 #charset koi8-r; #access_log logs/host.access.log main; #反斜杆代表所有连接,此配置目的是将所有连接交给名为app1的upstream代理,实现负载平衡 location / { proxy_pass http://app1; } #图片文件路径,一般来说,静态文件会部署在本机以加快响应速度 #可配置多个这样的location,满足各种需求 location ~\.(gif|jpg|png)$ { root /home/root/images; } location ~\.(iso|zip|txt|doc|docx)$ { root /home/root/files; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # FastCGI是CGI全称是“公共网关接口”(Common Gateway Interface) #对于我来说,使用Tomcat代替即可,请忽略此配置。 #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # 添加黑名单,禁止某某访问特定文件 # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #}}Nginx安装配置详解的更多相关文章
- lvs keepalived 安装配置详解【转】
lvs keepalived 安装配置详解 张映 发表于 2012-06-20 分类目录: 服务器相关 前段时间看了一篇文章,lvs做负载均衡根F5差不多,说实话不怎么相信,因为F5没玩过,也无法比较 ...
- Nginx安装目录详解
Nginx安装目录详解 1. 查看有关nginx的所有目录列表,输入命令 rpm -ql nginx 可以查看有关nginx目录信息,但是注意 这种命令只能是在基于yum安装的方式才可以. 2. 下 ...
- Eclipse IDE for C/C++ Developers安装配置详解
Eclipse IDE for C/C++ Developers安装配置详解(转) 转自:http://hi.baidu.com/ltb6w/item/986532efd712460f570f1ddc ...
- Cloudera CDH 、Impala本地通过Parcel安装配置详解及什么是Parcel
本文引用自:Cloudera CDH .Impala本地通过Parcel安装配置详解及什么是Parcelhttp://www.aboutyun.com/forum.php?mod=viewthread ...
- ubuntu14.04 server ftp 服务安装配置详解
ubuntu14.04 server ftp 服务安装配置详解 cheungmine 2016-01-27 http://wiki.ubuntu.com.cn/Vsftpd 0 安装好vsftpd服务 ...
- JDK10安装配置详解
JDK10安装配置详解 1. 下载jdk10 1.1 官网下载jdk7的软件包: 地址:http://www.oracle.com/technetwork/java/javase/dow ...
- (转)python中调用R语言通过rpy2 进行交互安装配置详解
python中调用R语言通过rpy2 进行交互安装配置详解(R_USER.R_HOME配置) 2018年11月08日 10:00:11 luqin_ 阅读数:753 python中调用R语言通过r ...
- (转)使用LVS实现负载均衡原理及安装配置详解
使用LVS实现负载均衡原理及安装配置详解 原文:https://www.cnblogs.com/liwei0526vip/p/6370103.html
- redis cluster 集群 安装 配置 详解
redis cluster 集群 安装 配置 详解 张映 发表于 2015-05-01 分类目录: nosql 标签:cluster, redis, 安装, 配置, 集群 Redis 集群是一个提供在 ...
随机推荐
- drawable转mitmap 以及图片base64编码
static Bitmap drawableToBitmap(Drawable drawable) // drawable 转换成bitmap { int width = drawable.getIn ...
- WebDriver API 实例详解(一)
一.访问某网页地址 被测试网页的网址: http://www.baidu.com Java语言版本的API实例代码: 方法1: package test; import org.testng.anno ...
- Excel error 64-bit version of SSIS
问题是 在windows server 2008 64位的计划任务执行 ssis 的错误 ,ssis你们带有读取excel 日期 2015/3/17 11:50:34日志 作业历史记录 (SSIS_U ...
- smarty简单语法
什么是smarty及其安装 Smarty是一个php模板引擎,它分开了逻辑程序和外在的内容,提供了一种易于管理的方法. Smarty要求web服务器运行php4.0.6和以上版本. smarty安装需 ...
- 20145307陈俊达《网络对抗》Exp3 免杀原理与实践
20145307陈俊达<网络对抗>Exp3 免杀原理与实践 基础问题回答 杀软是如何检测出恶意代码的? 恶意代码中一般会有一段有较明显特征的代码也就是特征码,如果杀毒软件检测到有程序包含的 ...
- linux第七周
可执行程序的装载 一.预处理.编译.链接和目标文件的格式 可执行文件的创建——预处理.编译和链接 cd Code vi hello.c gcc -E -o hello.cpp hello.c -m32 ...
- Ubuntu Budgie 18.04 是最好的Remix【转】
本文转载子:https://www.linuxidc.com/Linux/2018-05/152223.htm [日期:2018-05-05] 来源:Linux公社 作者:醉落红尘 [字体:大 中 ...
- 【bzoj5170】Fable(树状数组)
题目传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=5170 我们会发现,经过一轮冒泡后,若a[i]的前面有比它大的数,就一定会有一个被丢到后 ...
- pybedtools --bedtools的python包
http://daler.github.io/pybedtools/ 用个下面这个 >>> fn = pybedtools.example_filename('test.fa') & ...
- BZOJ 4013 【HNOI2015】 实验比较
题目链接:实验比较 如果我们把相等关系全部缩起来的话,这道题给出的小于关系如果有环,那么就是不合法的,否则就构成了一片森林. 定义等于号连起来的所有变量看做一个块. 然后我们就可以令\(f_{i,j} ...