全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 3509|回复: 8

[nginx] nginx前端,apache后端,如何修改和添加主机?

[复制链接]
发表于 2010-11-29 18:34:29 | 显示全部楼层 |阅读模式
服务器用nginx作为前端,apache作为后端,之前朋友帮忙架设的,设置了三个站点A、B、C。现在临时想增加一个域名,不会增加。
于是把C域名改成了新需要的域名D。
对应修改了/usr/local/nginx/conf/nginx.conf
和/usr/local/apache/conf/httpd.conf
把这两个配置文件中的域名C都改成了域名D。
然后把web/wwwroot/域名C/ 改成web/wwwroot/域名D/
再执行kill -HUP `cat /usr/local/nginx/logs/nginx.pid

随后访问域名D,访问的是域名A,请问是不是哪里没设置到啊

域名D是域名A的二级域名,nginx里如果按照子域名添加的话,是不是不要单独设置站点?

1、2楼贴上了两个配置文件,另外在115也传了份http://u.115.com/file/f9e4ddc048

[ 本帖最后由 chimney 于 2010-11-29 18:40 编辑 ]
 楼主| 发表于 2010-11-29 18:39:29 | 显示全部楼层
两个配置文件我把域名用字母替代后发上来。
httpd.conf
  1. ServerRoot "/usr/local/apache"
  2. <IfModule !mpm_netware.c>
  3. PidFile logs/httpd.pid
  4. </IfModule>
  5. Timeout 30
  6. ServerLimit 1024
  7. KeepAlive Off
  8. MaxKeepAliveRequests 100
  9. KeepAliveTimeout 15
  10. <IfModule prefork.c>
  11. StartServers         5
  12. MinSpareServers      5
  13. MaxSpareServers     10
  14. MaxClients         128
  15. MaxRequestsPerChild  10000
  16. </IfModule>
  17. Listen 127.0.0.1:80

  18. #LoadModule access_module modules/mod_access.so
  19. #LoadModule auth_module modules/mod_auth.so
  20. #LoadModule auth_anon_module modules/mod_auth_anon.so
  21. #LoadModule auth_dbm_module modules/mod_auth_dbm.so
  22. #LoadModule auth_digest_module modules/mod_auth_digest.so
  23. #LoadModule file_cache_module modules/mod_file_cache.so
  24. #LoadModule charset_lite_module modules/mod_charset_lite.so
  25. #LoadModule cache_module modules/mod_cache.so
  26. #LoadModule disk_cache_module modules/mod_disk_cache.so
  27. #LoadModule include_module modules/mod_include.so
  28. #LoadModule deflate_module modules/mod_deflate.so
  29. #LoadModule log_config_module modules/mod_log_config.so
  30. #LoadModule logio_module modules/mod_logio.so
  31. #LoadModule env_module modules/mod_env.so
  32. #LoadModule mime_magic_module modules/mod_mime_magic.so
  33. #LoadModule cern_meta_module modules/mod_cern_meta.so
  34. #LoadModule expires_module modules/mod_expires.so
  35. #LoadModule headers_module modules/mod_headers.so
  36. #LoadModule usertrack_module modules/mod_usertrack.so
  37. #LoadModule unique_id_module modules/mod_unique_id.so
  38. #LoadModule setenvif_module modules/mod_setenvif.so
  39. #LoadModule mime_module modules/mod_mime.so
  40. #LoadModule dav_module modules/mod_dav.so
  41. #LoadModule status_module modules/mod_status.so
  42. #LoadModule autoindex_module modules/mod_autoindex.so
  43. #LoadModule asis_module modules/mod_asis.so
  44. #LoadModule info_module modules/mod_info.so
  45. #LoadModule cgi_module modules/mod_cgi.so
  46. #LoadModule dav_fs_module modules/mod_dav_fs.so
  47. #LoadModule vhost_alias_module modules/mod_vhost_alias.so
  48. #LoadModule negotiation_module modules/mod_negotiation.so
  49. #LoadModule dir_module modules/mod_dir.so
  50. #LoadModule imap_module modules/mod_imap.so
  51. #LoadModule actions_module modules/mod_actions.so
  52. #LoadModule speling_module modules/mod_speling.so
  53. #LoadModule userdir_module modules/mod_userdir.so
  54. #LoadModule alias_module modules/mod_alias.so
  55. #LoadModule rewrite_module modules/mod_rewrite.so
  56. #LoadModule php5_module        modules/libphp5.so
  57. LoadModule php5_module        /usr/lib/apache/libphp5.so
  58. LoadModule rpaf_module /usr/lib/apache/mod_rpaf-2.0.so
  59. RPAFenable On
  60. RPAFsethostname On
  61. RPAFproxy_ips 127.0.0.1    # 填写Nginx的来访IP
  62. RPAFheader X-Forwarded-For

  63. AddType application/x-httpd-php .php
  64. AddType application/x-httpd-php-source .phps
  65. ExtendedStatus On
  66. <IfModule !mpm_winnt.c>
  67. <IfModule !mpm_netware.c>
  68. User www
  69. Group www
  70. </IfModule>
  71. </IfModule>

  72. ServerAdmin vip@comsenz.com
  73. #ServerName www.example.com:80
  74. UseCanonicalName Off
  75. DocumentRoot "/usr/local/apache/htdocs"

  76. <Directory />
  77.     Options FollowSymLinks
  78.     AllowOverride None
  79. </Directory>

  80. <Directory "/usr/local/apache/htdocs">
  81.     Options Indexes FollowSymLinks
  82.     AllowOverride None
  83.     Order allow,deny
  84.     Allow from all
  85. </Directory>

  86. DirectoryIndex index.html index.html.var index.htm index.php
  87. AccessFileName .htaccess

  88. <FilesMatch "^\.ht">
  89.     Order allow,deny
  90.     Deny from all
  91. </FilesMatch>

  92. TypesConfig conf/mime.types
  93. DefaultType text/plain

  94. <IfModule mod_mime_magic.c>
  95.     MIMEMagicFile conf/magic
  96. </IfModule>

  97. HostnameLookups Off
  98. #ErrorLog logs/error_log
  99. ServerTokens Full
  100. ServerSignature On
  101. Alias /icons/ "/usr/local/apache/icons/"

  102. <Directory "/usr/local/apache/icons">
  103.     Options Indexes MultiViews
  104.     AllowOverride None
  105.     Order allow,deny
  106.     Allow from all
  107. </Directory>

  108. AliasMatch ^/manual(?:/(?:de|en|es|fr|ja|ko|ru))?(/.*)?$ "/usr/local/apache/manual$1"

  109. <Directory "/usr/local/apache/manual">
  110.     Options Indexes
  111.     AllowOverride None
  112.     Order allow,deny
  113.     Allow from all
  114.     <Files *.html>
  115.         SetHandler type-map
  116.     </Files>
  117.     SetEnvIf Request_URI ^/manual/(de|en|es|fr|ja|ko|ru)/ prefer-language=$1
  118.     RedirectMatch 301 ^/manual(?:/(de|en|es|fr|ja|ko|ru)){2,}(/.*)?$ /manual/$1$2
  119. </Directory>

  120. ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"

  121. <Directory "/usr/local/apache/cgi-bin">
  122.     AllowOverride None
  123.     Options None
  124.     Order allow,deny
  125.     Allow from all
  126. </Directory>

  127. IndexOptions FancyIndexing VersionSort
  128. AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
  129. AddIconByType (TXT,/icons/text.gif) text/*
  130. AddIconByType (IMG,/icons/image2.gif) image/*
  131. AddIconByType (SND,/icons/sound2.gif) audio/*
  132. AddIconByType (VID,/icons/movie.gif) video/*
  133. AddIcon /icons/binary.gif .bin .exe
  134. AddIcon /icons/binhex.gif .hqx
  135. AddIcon /icons/tar.gif .tar
  136. AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
  137. AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
  138. AddIcon /icons/a.gif .ps .ai .eps
  139. AddIcon /icons/layout.gif .html .shtml .htm .pdf
  140. AddIcon /icons/text.gif .txt
  141. AddIcon /icons/c.gif .c
  142. AddIcon /icons/p.gif .pl .py
  143. AddIcon /icons/f.gif .for
  144. AddIcon /icons/dvi.gif .dvi
  145. AddIcon /icons/uuencoded.gif .uu
  146. AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
  147. AddIcon /icons/tex.gif .tex
  148. AddIcon /icons/bomb.gif core

  149. AddIcon /icons/back.gif ..
  150. AddIcon /icons/hand.right.gif README
  151. AddIcon /icons/folder.gif ^^DIRECTORY^^
  152. AddIcon /icons/blank.gif ^^BLANKICON^^

  153. DefaultIcon /icons/unknown.gif
  154. ReadmeName README.html
  155. HeaderName HEADER.html

  156. IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

  157. AddLanguage ca .ca
  158. AddLanguage cs .cz .cs
  159. AddLanguage da .dk
  160. AddLanguage de .de
  161. AddLanguage el .el
  162. AddLanguage en .en
  163. AddLanguage eo .eo
  164. AddLanguage es .es
  165. AddLanguage et .et
  166. AddLanguage fr .fr
  167. AddLanguage he .he
  168. AddLanguage hr .hr
  169. AddLanguage it .it
  170. AddLanguage ja .ja
  171. AddLanguage ko .ko
  172. AddLanguage ltz .ltz
  173. AddLanguage nl .nl
  174. AddLanguage nn .nn
  175. AddLanguage no .no
  176. AddLanguage pl .po
  177. AddLanguage pt .pt
  178. AddLanguage pt-BR .pt-br
  179. AddLanguage ru .ru
  180. AddLanguage sv .sv
  181. AddLanguage zh-CN .zh-cn
  182. AddLanguage zh-TW .zh-tw
  183. LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
  184. ForceLanguagePriority Prefer Fallback
  185. AddCharset ISO-8859-1  .iso8859-1  .latin1
  186. AddCharset ISO-8859-2  .iso8859-2  .latin2 .cen
  187. AddCharset ISO-8859-3  .iso8859-3  .latin3
  188. AddCharset ISO-8859-4  .iso8859-4  .latin4
  189. AddCharset ISO-8859-5  .iso8859-5  .latin5 .cyr .iso-ru
  190. AddCharset ISO-8859-6  .iso8859-6  .latin6 .arb
  191. AddCharset ISO-8859-7  .iso8859-7  .latin7 .grk
  192. AddCharset ISO-8859-8  .iso8859-8  .latin8 .heb
  193. AddCharset ISO-8859-9  .iso8859-9  .latin9 .trk
  194. AddCharset ISO-2022-JP .iso2022-jp .jis
  195. AddCharset ISO-2022-KR .iso2022-kr .kis
  196. AddCharset ISO-2022-CN .iso2022-cn .cis
  197. AddCharset Big5        .Big5       .big5
  198. AddCharset WINDOWS-1251 .cp-1251   .win-1251
  199. AddCharset CP866       .cp866
  200. AddCharset KOI8-r      .koi8-r .koi8-ru
  201. AddCharset KOI8-ru     .koi8-uk .ua
  202. AddCharset ISO-10646-UCS-2 .ucs2
  203. AddCharset ISO-10646-UCS-4 .ucs4
  204. AddCharset UTF-8       .utf8
  205. AddCharset GB2312      .gb2312 .gb
  206. AddCharset utf-7       .utf7
  207. AddCharset utf-8       .utf8
  208. AddCharset big5        .big5 .b5
  209. AddCharset EUC-TW      .euc-tw
  210. AddCharset EUC-JP      .euc-jp
  211. AddCharset EUC-KR      .euc-kr
  212. AddCharset shift_jis   .sjis
  213. AddType application/x-compress .Z
  214. AddType application/x-gzip .gz .tgz
  215. AddHandler type-map var
  216. BrowserMatch "Mozilla/2" nokeepalive
  217. BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
  218. BrowserMatch "RealPlayer 4\.0" force-response-1.0
  219. BrowserMatch "Java/1\.0" force-response-1.0
  220. BrowserMatch "JDK/1\.0" force-response-1.0
  221. BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
  222. BrowserMatch "MS FrontPage" redirect-carefully
  223. BrowserMatch "^WebDrive" redirect-carefully
  224. BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully
  225. BrowserMatch "^gnome-vfs" redirect-carefully
  226. BrowserMatch "^XML Spy" redirect-carefully
  227. BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully

  228. NameVirtualHost 127.0.0.1:80

  229. <VirtualHost 127.0.0.1:80>
  230.     ServerAdmin webmaster@aaaa.com
  231.     DocumentRoot "/web/wwwroot/aaaa.com"
  232.     ServerName aaaa.com
  233.     ServerAlias aaaa.com
  234. <Directory "/web/wwwroot/aaaa.com">
  235.     AllowOverride all
  236.     Options None
  237.     Order allow,deny
  238.     Allow from all
  239. </Directory>
  240. </VirtualHost>

  241. <VirtualHost 127.0.0.1:80>
  242.     ServerAdmin webmaster@www.bbbb.com
  243.     DocumentRoot "/web/wwwroot/www.bbbb.com"
  244.     ServerName www.bbbb.com
  245.     ServerAlias www.bbbb.com
  246. <Directory "/web/wwwroot/www.bbbb.com">
  247.     AllowOverride all
  248.     Options None
  249.     Order allow,deny
  250.     Allow from all
  251. </Directory>
  252. </VirtualHost>

  253. <VirtualHost 127.0.0.1:80>
  254.     ServerAdmin webmaster@dddd.aaaa.com
  255.     DocumentRoot "/web/wwwroot/dddd.aaaa.com"
  256.     ServerName dddd.aaaa.com
  257.     ServerAlias dddd.aaaa.com
  258. <Directory "/web/wwwroot/dddd.aaaa.com">
  259.     AllowOverride all
  260.     Options None
  261.     Order allow,deny
  262.     Allow from all
  263. </Directory>
  264. </VirtualHost>
复制代码
 楼主| 发表于 2010-11-29 18:39:55 | 显示全部楼层
nginx.conf
  1. user  www www;

  2. worker_processes 8;

  3. error_log  logs/nginx_error.log  crit;

  4. pid        logs/nginx.pid;

  5. worker_rlimit_nofile 65535;

  6. events
  7. {
  8.   use epoll;
  9.   worker_connections 65535;
  10. }

  11. http
  12. {
  13.   include       mime.types;
  14.   default_type  application/octet-stream;

  15.   #charset  gb2312;
  16.       
  17.   server_names_hash_bucket_size 128;
  18.   client_header_buffer_size 32k;
  19.   large_client_header_buffers 4 32k;
  20.   client_max_body_size 8m;
  21.       
  22.   sendfile on;
  23.   tcp_nopush     on;

  24.   keepalive_timeout 30;

  25.   tcp_nodelay on;

  26.   fastcgi_connect_timeout 300;
  27.   fastcgi_send_timeout 300;
  28.   fastcgi_read_timeout 300;
  29.   fastcgi_buffer_size 64k;
  30.   fastcgi_buffers 4 64k;
  31.   fastcgi_busy_buffers_size 128k;
  32.   fastcgi_temp_file_write_size 128k;

  33.   gzip on;
  34.   gzip_min_length  1k;
  35.   gzip_buffers     4 16k;
  36.   gzip_http_version 1.0;
  37.   gzip_comp_level 2;
  38.   gzip_types       text/plain application/x-javascript text/css application/xml;
  39.   gzip_vary on;

  40. server {
  41. listen 192.204.196.74:80 default;
  42. listen 192.204.196.78:80;
  43. return 400;
  44. access_log off;
  45. }
  46. server {
  47. listen   192.204.196.74:80;
  48. server_name  www.aaaa.com;
  49. rewrite ^/(.*) http://aaaa.com/$1 permanent;
  50. access_log off;
  51. }
  52.   server
  53.   {
  54.     listen      192.204.196.74:80;
  55.     server_name aaaa.com;
  56.     index index.html index.htm index.php;
  57.     root  /web/wwwroot/aaaa.com;
  58.   location ~ \.php$ {
  59.                 proxy_pass   http://127.0.0.1:80;
  60.                 proxy_redirect          off;
  61.                 proxy_set_header Host $host;
  62.                 proxy_set_header X-Real-IP $remote_addr;
  63.                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  64.                 proxy_connect_timeout 300;
  65.                         proxy_send_timeout 300;
  66.                         proxy_read_timeout 300;
  67.         }
  68.    
  69.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  70.     {
  71.       expires      30d;
  72.     }

  73.     location ~ .*\.(js|css)?$
  74.     {
  75.       expires      1h;
  76.     }   

  77.     access_log  off;
  78.       }

  79. server
  80.   {
  81.     listen      192.204.196.78:80;
  82.     server_name www.bbbb.com;
  83.     index index.html index.htm index.php;
  84.     root  /web/wwwroot/www.bbbb.com;

  85.     location / {
  86.         rewrite ^(.*)/bbs(.*)-(.*)$ $1/thread.php?fid=$2&page=$3;
  87.         rewrite ^(.*)/bbs(.*)$      $1/thread.php?fid=$2;
  88.         rewrite ^(.*)/z(.*)-(.*)-(.*).html$  $1/read.php?tid=$2&page=$3&fpage=$4;
  89.         rewrite ^(.*)/z(.*)-(.*).html$       $1/read.php?tid=$2&page=$3;  
  90.         rewrite ^(.*)/z(.*).html$         $1/read.php?tid=$2;

  91.         rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
  92.         rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
  93.     }

  94.   location ~ \.php$ {
  95.                 proxy_pass   http://127.0.0.1:80;
  96.                 proxy_redirect          off;
  97.                 proxy_set_header Host $host;
  98.                 proxy_set_header X-Real-IP $remote_addr;
  99.                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  100.                 proxy_connect_timeout 300;
  101.                         proxy_send_timeout 300;
  102.                         proxy_read_timeout 300;
  103.         }
  104.    
  105.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  106.     {
  107.       expires      30d;
  108.     }

  109.     location ~ .*\.(js|css)?$
  110.     {
  111.       expires      1h;
  112.     }   

  113.     access_log  off;
  114.       }

  115. server
  116.   {
  117.     listen       192.204.196.78:80;

  118.     server_name  dddd.aaaa.com;
  119.     index index.html index.htm index.php;
  120.     root  /web/wwwroot/dddd.aaaa.com;                        
  121. location / {
  122. rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
  123. rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
  124. rewrite ^([^\.]*)/bbs(\w+)-([0-9]+)$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
  125. rewrite ^([^\.]*)/yy([0-9]+)-([0-9]+)-([0-9]+)$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
  126. rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
  127. rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
  128. rewrite ^([^\.]*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last;
  129. }

  130.    location ~ \.php$ {
  131.                 proxy_pass   http://127.0.0.1:80;
  132.                 proxy_redirect          off;
  133.                 proxy_set_header Host $host;
  134.                 proxy_set_header X-Real-IP $remote_addr;
  135.                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  136.                 proxy_connect_timeout 300;
  137.                         proxy_send_timeout 300;
  138.                         proxy_read_timeout 300;
  139.         }
  140.     access_log  off;
  141.       }          

  142. }
复制代码
发表于 2010-11-29 19:12:52 | 显示全部楼层
看下一键包里的相关shell,就知道怎么加了
发表于 2010-11-29 21:01:14 | 显示全部楼层
两个位置都要添加。

评分

参与人数 1威望 +3 收起 理由
chimney + 3 两个位置我是都添加了啊

查看全部评分

 楼主| 发表于 2010-11-30 09:11:45 | 显示全部楼层
原帖由 ramonde 于 2010-11-29 19:12 发表
看下一键包里的相关shell,就知道怎么加了

因为是朋友帮忙安装的,朋友你说的是?
发表于 2010-11-30 09:21:52 | 显示全部楼层
是不是前两天谁发布的那个lnamp一键包
发表于 2010-11-30 09:31:02 | 显示全部楼层
楼主是忘了重启apache了
service httpd restart就好了

评分

参与人数 1威望 +3 收起 理由
chimney + 3 我重启了,还是不行,还是访问aaaa.com ...

查看全部评分

 楼主| 发表于 2010-11-30 12:07:10 | 显示全部楼层
原帖由 cuijz 于 2010-11-30 09:31 发表
楼主是忘了重启apache了
service httpd restart就好了

我重启了,还是不行,还是访问aaaa.com
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-23 21:44 , Processed in 0.070280 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表