nginx的安装及基本配置,及多个域名服务
2016-06-24 16:34
603 查看
centos6.x yum默认没有nginx的软件包
安装方式:
到nginx下载页面http://nginx.org/en/linux_packages.html#stable,复制CENTOS 6的nginx软件源安装包
运行命令:wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
安装rpm包 yum install nginx-release-centos-6-0.el6.ngx.noarch.rpm -y , 此步实际只是加入了nginx的软件包源
执行 yum install nginx -y 就可以安装好nginx了
nginx默认安装为linux的服务
使用service nginx start, stop, restart, try-restart, reload, force-reload, status来操作nginx
nginx的配置文件默认读取/etc/nginx/nginx.conf文件
nginx的配置都是由 directives组成,directives由简单指令或者区块指令组成
简单指令:listen 80;
区块指令由{}包含,区块指令又可以包含多个简单指令和区块指令:
http可以有多个server,多个server可以监听多个端口在同一服务器为多个应用提供服务。
但如果你同时有多个域名www.you.com,news.you.com, mail.you.com在同一个服务器进行服务,那么www.you.com,mail.you.com:8080, news.you.com:81这样的访问方式显然是不合适显然是不合适的,幸运的是nginx已经提供了通过域名过滤的规则
最终分别运行各个应用监听对应端口即可。
安装方式:
到nginx下载页面http://nginx.org/en/linux_packages.html#stable,复制CENTOS 6的nginx软件源安装包
运行命令:wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
安装rpm包 yum install nginx-release-centos-6-0.el6.ngx.noarch.rpm -y , 此步实际只是加入了nginx的软件包源
执行 yum install nginx -y 就可以安装好nginx了
nginx默认安装为linux的服务
使用service nginx start, stop, restart, try-restart, reload, force-reload, status来操作nginx
nginx的配置文件默认读取/etc/nginx/nginx.conf文件
nginx的配置都是由 directives组成,directives由简单指令或者区块指令组成
简单指令:listen 80;
区块指令由{}包含,区块指令又可以包含多个简单指令和区块指令:
http { server { } }
http可以有多个server,多个server可以监听多个端口在同一服务器为多个应用提供服务。
但如果你同时有多个域名www.you.com,news.you.com, mail.you.com在同一个服务器进行服务,那么www.you.com,mail.you.com:8080, news.you.com:81这样的访问方式显然是不合适显然是不合适的,幸运的是nginx已经提供了通过域名过滤的规则
server { listen 80; server_name www.you.com; location / { #.... proxy_pass http://localhost:8880; } ##### other directive } server { listen 80; server_name news.you.com; location / { #.... proxy_pass http://localhost:8881; } ##### other directive } server { listen 80; server_name mail.you.com; location / { #.... proxy_pass http://localhost:8882; } ##### other directive }
最终分别运行各个应用监听对应端口即可。
相关文章推荐
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Nginx 学习笔记(一)
- 网站502与504错误分析
- 用zabbix监控nginx_status状态
- 艰难完成 nginx + puma 部署 rails 4的详细记录
- 把Lua编译进nginx步骤方法
- web 应用中常用的各种 cache详解
- Linux系统上配置Nginx+Ruby on Rails+MySQL超攻略
- window+nginx+php环境配置 附配置搭配说明
- apache tomcat 一个网站多域名的实现方法
- 解析CI即CodeIgniter框架在Nginx下的重写规则
- 将PHP从5.3.28升级到5.3.29时Nginx出现502错误