nginx虚拟主机配置实例
nginx虚拟主机配置实例
1、在/usr/local/nginx/conf/nginx.conf文件末尾加入虚拟主机配置,实例如下:
server
{
listen 80;
server_name www.hebaodans.com;
index index.html index.htm index.php;
root /wwwroot/www.hebaodans.com;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
#include rewite rule file or you can directly write here
include rewrite.conf;
log_format hebaodanscom ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $http_x_forwarded_for’;
access_log /logs/hebaodanscom.log hebaodanscom;
}
2、vi /usr/local/nginx/conf/rewrite.conf 输入以下规则:
location / {
if (!-e $request_filename)
{
#————START —————WORLDPRESS————
rewrite ^ /index.php last;
#————END —————WORLDPRESS————
#————————zen-cart start——————
# From Ultimate SEO URLs
rewrite “^(.*)-p-(.*).html” /index.php?main_page=product_info&products_id=$2&% last;
rewrite “^(.*)-c-(.*).html” /index.php?main_page=index&cPath=$2&% last;
rewrite “^(.*)-m-([0-9]+).html” /index.php?main_page=index&manufacturers_id=$2&% last;
rewrite “^(.*)-pi-([0-9]+).html” /index.php?main_page=popup_image&pID=$2&% last;
rewrite “^(.*)-pr-([0-9]+).html” /index.php?main_page=product_reviews&products_id=$2&% last;
rewrite “^(.*)-pri-([0-9]+).html” /index.php?main_page=product_reviews_info&products_id=$2&% last;
# For Open Operations Info Manager
rewrite “^(.*)-i-([0-9]+).html” /index.php?main_page=info_manager&pages_id=$2&% last;
# For dreamscape’s News & Articles Manager
rewrite “^news/?” /index.php?main_page=news&% last;
rewrite “^news/rss.xml” /index.php?main_page=news_rss&% last;
rewrite “^news/archive/?” /index.php?main_page=news_archive&% last;
rewrite “^news/([0-9]{4})-([0-9]{2})-([0-9]{2}).html” /index.php?main_page=news&date=$1-$2-$3&% last;
rewrite “^news/archive/([0-9]{4})-([0-9]{2}).html” /index.php?main_page=news_archive&date=$1-$2&% last;
rewrite “^news/(.*)-a-([0-9]+)-comments.html” /index.php?main_page=news_comments&article_id=$2&% last;
rewrite “^news/(.*)-a-([0-9]+).html” /index.php?main_page=news_article&article_id=$2&% last;
# All other pages
# Don’t rewrite real files or directories
#RewriteCond %{REQUEST_FILENAME} !-f [NC]
#RewriteCond %{REQUEST_FILENAME} !-d
rewrite “^(.*).html” /index.php?main_page=$1&% last;
#—————————-zen-cart end—————–
}
}
保存后,运行 kill -HUP `cat /usr/local/nginx/nginx.pid` 平滑重启即可生效。
nginx虚拟主机配置实例相关推荐
- nginx---ngix虚拟主机配置实例
2019独角兽企业重金招聘Python工程师标准>>> ngix虚拟主机配置实例 http://www.cnblogs.com/eoiioe/archive/2009/05/09/1 ...
- Nginx 虚拟主机配置及负载均衡
虚拟主机配置: 在现实中,公司为了充分利用服务器资源 , 一台 Nginx 服务器会同时挂多个站点,这些站点可以基于80端口配置 N 多不同域名的服务器,那么,怎样实现这一功能呢,接下来就让我们学习一 ...
- Nginx 虚拟主机配置
Nginx虚拟主机 虚拟主机提供了在同一台服务器上运行多个网站的功能,启动的是一个nginx实例,部署多个虚拟主机来发布多个门户网站.虚拟主机标识是server,一个server对应一个虚拟主机. 虚 ...
- Nginx虚拟主机配置
nginx的虚拟主机就是通过nginx.conf中server节点指定的,想要设置多个虚拟主机,配置多个server节点即可 先看一个最简单的虚拟主机配置示例 server { listen 80; ...
- 设置ngxin服务器虚拟主机,详解Nginx 虚拟主机配置的三种方式(基于端口)
Nginx配置虚拟主机支持3种方式:基于IP的虚拟主机配置,基于端口的虚拟主机配置,基于域名的虚拟主机配置. 2.Nginx基于端口的虚拟主机配置 如一台服务器只有一个IP或需要通过不同的端口访问不同 ...
- Nginx教程(二) Nginx虚拟主机配置
Nginx管理虚拟主机 虚拟主机使用的是特殊的软硬件技术,它把一台运行在因特网上的服务器主机分成一台台"虚拟"的主机,每台虚拟主机都可以是一个独立的网站,可以具有独立的域名,具有完 ...
- tomcat 虚拟主机配置实例
jsp+tomcat 虚拟主机配置 第一步 打开Tomcat\conf 下面的 server.xml 本例 域名 jsp.com 源码文件夹放置在d:\jsp 文件夹 <Host n ...
- nginx虚拟主机配置和反向代理
虚拟主机有三种配置方式(常用于本机测试使用,将一个ip和端口的请求根据域名不同分配到不同的应用服务器) 基于ip 不常用 基于端口 可选 基于域名 可选 1 #user nobody; 2 worke ...
- 配置Nginx虚拟主机
首先确保你的域名已经设置了域名解析. 如果没有的话 自己去百度下. 我本书用的演示网站域名为 magento2demo.texiaoyao.cn. 这个域名是在美称互联上买的,所以直接到美称互联里去解 ...
- nginx虚拟主机概念和类型介绍
nginx虚拟主机配置实战 1,虚拟主机概念和类型介绍 所谓虚拟主机,在web服务里就是一个独立的网站站点,这个站点对应独立的域名(也可能是IP或端口),具有独立的程序及资源目录,可以独立地对外提供服 ...
最新文章
- 程序员接活利器,dataTable组件带你快速开发,摆脱CRUD
- 2015年科技巨头的十个开源产品,不只是.NET、Swift
- 图标和文字跟着div比例放大缩小_Word文档页面显示比例与单页多页,文本的输入、修改、删除与插入...
- ppt flash倒计时器_PPT三大神器之iSlide插件
- c语言递归汉诺塔次数,汉诺塔问题(C语言经典递归问题(一))
- VB 实现UTF-8 与GB2312互转
- edge安装包_Chromium版Edge浏览器将支持多平台,Windows版支持IE模式
- fcpx教程,如何在 final cut pro 中导出视频的图文?
- 算法:Number of Islands(岛屿的个数)
- 怎样把mp3转换成mp4?
- jmeter +ant实现接口的自动生成测试报告
- 几个名词解释 TBB VPP KKK
- 岳不群认识独孤九剑吗?
- SQL-根据生日计算年龄
- Nvidia30系显卡+Ubuntu系统的CUDA 11安装100%成功教程
- 变电站综合自动化系统的选型与应用
- true在php中代表,true是什么意思
- Tkinter 1. 基本介绍
- 2021/12/14 nginx包下载安装步骤记录
- BitLocker密码破解工具--部分代码