http://nginx.org/
安装
主要有两种方式,编译源码和yum安装,源码的依赖太多,没试了;
yum安装
http://nginx.org/en/linux_packages.html
服务器是centos 6.3
先安装这个http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
给yum添加nginx仓库
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install nginx
出现的问题,安装的时候yum命令报错(yum的所有操作都用不了),
Cannot retrieve repository metadata (repomd.xml) for repository: Media
file:///media/cdrom/repodata/repomd.xml 不存在之类的
网上找了很久的资料都没搞定;
后来根据根据错误提示搜索 /etc/yum.repos.d/目录下的文件repo文件
grep Media /etc/yum.repos.d/*.repo
终于有所发现
/etc/yum.repos.d/CentOS-Media.repo:# CentOS-Media.repo
/etc/yum.repos.d/CentOS-Media.repo:name=CentOS-$releasever - Media
/etc/yum.repos.d/MariaDB.repo:[Media]
在MariaDB.repo中发现一个错误的配置
[Media]
name=Local Sources
baseurl=file:///media/cdrom/
file:///media/cdrom1/
这段不知道谁加上去的,导致yum命令错误。我将该文件备份了下;yum命令正常使用了;
yum install nginx
又出问题了:
No package nginx available
没有资源,google下,这个问题好解决
1 down vote accepted
Answer :
nginx isn't in the 'normal' Centos repositories. You can install the EPEL repository to gain access to it. There's a how to guide here - and a more up to date one here.
Once you have added the EPEL repo, you can then install with the yum command you referenced.
EPEL:
http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x
安装成功了!
==================
主配置文件(/etc/nginx/nginx.conf)
worker_processes 4; #根据cpu核数设置
events {
use epoll; # 添加这个
worker_connections 1024;
}
http {
underscores_in_headers on; #请求头中如果有“_”的变量(有一个项目自定义了带下划线的请求头),加上这个配置
}
其他的默认
虚拟主机配置
server {
listen 80;
server_name xxxx.com;
location / {
proxy_pass http://openapiserver/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
upstream openapiserver {
server x.x.x.x:8988 weight=10;
}
分享到:
相关推荐
2) Nginx配置 - 1 - a)对c:\nginx\conf\nginx.conf文件进行配置: - 1 - b)常用的 Nginx 参数 - 3 - c)静态文件处理 - 4 - d)动态页面请求处理 - 4 - e)下面为nginx.conf配置实例: - 5 - f)Nginx 启动,停止等命令 ...
Nginx安装配置
提供nginx的安装配置,根据这就可傻瓜式安装配置。http节点下的upstream表示负载均衡,圆圈中的为前置机地址,提供给医院访问,方框中地址为服务端实际部署的地址(端口需一致,如果只有一个端口则只需要一个listen...
nginx安装配置全攻略:都是实际安装配置经验,傻瓜式步骤
nginx 安装 配置 明细文档
centos 6 nginx 安装配置手册,最适合新手的安装配置教程,从0开始。
linuxnginx安装配置文件支持php.pdf
Nginx安装配置1.源码安装上传openssl-1.0.1s.tar.gz、pcre-8.38.tar.bz2、ngx_cache_purge-2.3.tar
Linux nginx安装配置步骤.txt
linux系统下的nginx安装配置文档,nginx主要用于web服务器的负载均衡及流量代理,提高系统的安全性和稳定性。
Linux环境下nginx安装配置.docx
「linux命令大全Nginx安装配置」.docx
CentOS6环境FastDFS+Nginx安装配置笔记.pdf
Nginx安装配置PageSpeed模块实现网站加速.docx
linux下安装nginx被配置sticky模块的相关软件包,包含nginx.conf的简单实例
nginx安装、不同配置含义、常用命令、安全等方面的介绍
nginx安装、配置、负载均衡.ppt