Nginx配置示例和方法(虚拟主机)
来源:互联网 发布:python scope visiual 编辑:程序博客网 时间:2024/05/16 05:13
两个虚拟主机(纯静态-html 支持) - Two Virtual Hosts, Serving Static Files
http {: server {: listen 80;: server_name www.domain1.com;: access_log logs/domain1.access.log main;: location / {: index index.html;: root /var/www/domain1.com/htdocs;: }: }: server {: listen 80;: server_name www.domain2.com;: access_log logs/domain2.access.log main;: location / {: index index.html;: root /var/www/domain2.com/htdocs;: }: }}
虚拟主机标准配置(简化) - A Default Catchall Virtual Host
http {: server {: listen 80 default;: server_name _ *;: access_log logs/default.access.log main;: location / {: index index.html;: root /var/www/default/htdocs;: }: }}
在父文件夹中建立子文件夹以指向子域名 - Wildcard Subdomains in a Parent Folder
这是一个添加子域名(或是当DNS已指向服务器时添加一个新域名)的简单方法。需要注意的是,我已经将FCGI配置进该文件了。如果你只想使服务器为静态文件服务,可以直接将FCGI配置信息注释掉,然后将默认主页文件变成index.html。
这个简单的方法比起为每一个域名建立一个 vhost.conf 配置文件来讲,只需要在现有的配置文件中增加如下内容:
This is just a really easy way to keep adding new subdomains, or to add new domains automatically when DNS records are pointed at the server. Note that I have included FCGI here as well. If you want to just serve static files, strip out the FCGI config and change the default document to index.html. Rather than creating a new vhost.conf file for every domain, just create one of these:
server {: # Replace this port with the right one for your requirements: # 根据你的需求改变此端口: listen 80; #could also be 1.2.3.4:80 也可以是1.2.3.4:80的形式: # Multiple hostnames seperated by spaces. Replace these as well.: # 多个主机名可以用空格隔开,当然这个信息也是需要按照你的需求而改变的。: server_name star.yourdomain.com *.yourdomain.com www.*.yourdomain.com;: #Alternately: _ *: #或者可以使用:_ * (具体内容参见本维基其他页面): root /PATH/TO/WEBROOT/$host;: error_page 404 http://yourdomain.com/errors/404.html;: access_log logs/star.yourdomain.com.access.log;: location / {: root /PATH/TO/WEBROOT/$host/;: index index.php;: }: # serve static files directly: # 直接支持静态文件 (从配置上看来不是直接支持): location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$ {: access_log off;: expires 30d;: }: location ~ .php$ {: # By all means use a different server for the fcgi processes if you need to: # 如果需要,你可以为不同的FCGI进程设置不同的服务信息: fastcgi_pass 127.0.0.1:YOURFCGIPORTHERE;: fastcgi_index index.php;: fastcgi_param SCRIPT_FILENAME /PATH/TO/WEBROOT/$host/$fastcgi_script_name;: fastcgi_param QUERY_STRING $query_string;: fastcgi_param REQUEST_METHOD $request_method;: fastcgi_param CONTENT_TYPE $content_type;: fastcgi_param CONTENT_LENGTH $content_length;: fastcgi_intercept_errors on;: }: location ~ /\.ht {: deny all;: }: }
0 0
- Nginx配置示例和方法(虚拟主机)
- 【NGINX】虚拟主机配置示例
- Nginx nginx.conf虚拟主机配置(基于IP)示例
- nginx基本配置和虚拟主机配置
- nginx 配置虚拟主机的三种方法
- nginx入门安装和虚拟主机配置
- Apache、Nginx和Tomcat之虚拟主机配置
- apache虚拟主机配置示例
- Tomcat虚拟主机配置示例
- Tomcat虚拟主机配置示例
- Tomcat虚拟主机配置示例
- Tomcat虚拟主机配置示例
- Tomcat虚拟主机配置示例
- Tomcat虚拟主机配置示例
- Nginx 配置虚拟主机
- nginx配置虚拟主机
- Nginx虚拟主机配置教程
- Nginx 虚拟主机 VirtualHost 配置
- 1消息类Message
- [LeetCode] 12. Integer to Roman
- ubuntu12.04更新源update不成功
- [JZSC2016]【NOIP2016提高组A组7.16】(A_Crazy_Czy命题) 总结
- hdu5700区间交
- Nginx配置示例和方法(虚拟主机)
- Hbase-0.98.6源码分析--负载均衡过程
- 面试题38:数字在排序数字中出现的次数
- android studio 通过新建Library module的方式来导入SDK
- matlab调用VS生成的DLL
- LinkedList 基本属性
- UVA-340 Master-Mind Hints
- 无法解析的外部符号 __imp__curl_easy_init
- 布局属性的设置