LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2421|回复: 19

如何实现同一IP不同端口打开不同网页

[复制链接]
发表于 2004-1-27 19:01:34 | 显示全部楼层 |阅读模式
例如
http://192.168.0.1:80   打开一个
http://192.168.0.1:81   打开另一个

是不是要修改那个httpd.conf?

谢谢指教。
发表于 2004-1-27 19:39:53 | 显示全部楼层
在httpd.conf中有
Listen 12.34.56.78:80
Port 80
NameVirtualHost 12.34.56.78:80
把这几行修改成为相应端口就可以了。
 楼主| 发表于 2004-1-27 20:12:46 | 显示全部楼层
最初由 wangguoqin1001 发表
在httpd.conf中有
Listen 12.34.56.78:80
Port 80
NameVirtualHost 12.34.56.78:80
把这几行修改成为相应端口就可以了。


您的意思是:
NameVirtualHost 192.168.0.1
<VirtualHost 192.168.0.12>
ServerName cn.gn.com
DocumentRoot /var/test
</VirtualHost>

能不能说详细一点,另外我的HTML文件如何定义放置的位置?

谢谢。
 楼主| 发表于 2004-1-27 20:17:54 | 显示全部楼层
我的意思是,我里面原来已经跑着一个端口81,我在IE中输入http://192.168.0.1:81会出现主页A,
我现在想再添加一个端口80
让他在输入http://192.168.0.1后出现主页B。

谢谢。
 楼主| 发表于 2004-1-27 20:23:33 | 显示全部楼层
##
## httpd.conf -- Apache HTTP server configuration file
##
## $Id: httpd.conf,v 1.3.2.4 2003/03/11 07:54:48 riddles Exp $
##
ServerType standalone
ServerRoot /etc/httpd

LoadModule env_module           modules/mod_env.so
LoadModule config_log_module    modules/mod_log_config.so
LoadModule referer_log_module   modules/mod_log_referer.so
LoadModule mime_module          modules/mod_mime.so
LoadModule autoindex_module     modules/mod_autoindex.so
LoadModule dir_module           modules/mod_dir.so
LoadModule cgi_module           modules/mod_cgi.so
LoadModule alias_module         modules/mod_alias.so
LoadModule access_module        modules/mod_access.so
LoadModule auth_module          modules/mod_auth.so
LoadModule setenvif_module      modules/mod_setenvif.so
LoadModule ssl_module           modules/libssl.so

LockFile /var/lock/httpd.lock
PidFile /var/run/httpd.pid
ScoreBoardFile /var/run/httpd.scoreboard
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 2
MaxSpareServers 6
StartServers 4
MaxClients 30
MaxRequestsPerChild 100
Port 81

<IfDefine SSL>
    Listen 81
    Listen 445
</IfDefine>
User nobody
Group nobody
ServerAdmin root@localhost
DocumentRoot /home/httpd/html
<Directory />
    Options None
    AllowOverride None
</Directory>
<Directory /home/httpd/html>
    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
<DirectoryMatch "/home/httpd/html/(mrtg|sgraph)">
    AuthName "Restricted"
    AuthType Basic
    AuthUserFile /var/ipcop/auth/users
    require user admin
</DirectoryMatch>
ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/
<Directory /home/httpd/cgi-bin>
    AllowOverride None
    Options None
    AuthName "Restricted"
    AuthType Basic
    AuthUserFile /var/ipcop/auth/users
    Require user admin
    <Files index.cgi>
        Satisfy Any
        Allow from All
    </Files>
    <Files dial.cgi>
        Require user admin dial
    </Files>
</Directory>
<IfModule mod_dir.c>
    DirectoryIndex index.html index.htm index.shtml index.cgi
</IfModule>
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>
<IfModule mod_mime.c>
    TypesConfig /etc/mime.types
</IfModule>
DefaultType text/plain
<IfModule mod_mime_magic.c>
    MIMEMagicFile share/magic
</IfModule>

HostnameLookups Off
ErrorLog /var/log/httpd/error_log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /var/log/httpd/access_log common
ServerSignature On
<IfModule mod_mime.c>
    AddEncoding x-compress Z
    AddEncoding x-gzip gz tgz
    AddLanguage da .dk
    AddLanguage nl .nl
    AddLanguage en .en
    AddLanguage et .ee
    AddLanguage fr .fr
    AddLanguage de .de
    AddLanguage el .el
    AddLanguage he .he
    AddCharset ISO-8859-8 .iso8859-8
    AddLanguage it .it
    AddLanguage ja .ja
    AddCharset ISO-2022-JP .jis
    AddLanguage kr .kr
    AddCharset ISO-2022-KR .iso-kr
    AddLanguage no .no
    AddLanguage pl .po
    AddCharset ISO-8859-2 .iso-pl
    AddLanguage pt .pt
    AddLanguage pt-br .pt-br
    AddLanguage ltz .lu
    AddLanguage ca .ca
    AddLanguage es .es
    AddLanguage sv .se
    AddLanguage cz .cz
    AddLanguage ru .ru
    AddLanguage zh-tw .tw
    AddLanguage tw .tw
    AddCharset Big5         .Big5    .big5
    AddCharset WINDOWS-1251 .cp-1251
    AddCharset CP866        .cp866
    AddCharset ISO-8859-5   .iso-ru
    AddCharset KOI8-R       .koi8-r
    AddCharset UCS-2        .ucs2
    AddCharset UCS-4        .ucs4
    AddCharset UTF-8        .utf8
    <IfModule mod_negotiation.c>
        LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw
    </IfModule>
    AddType application/x-tar .tgz
    AddHandler cgi-script .cgi
    AddType text/html .shtml
    AddHandler server-parsed .shtml
    AddHandler imap-file map
</IfModule>
<IfModule mod_setenvif.c>
    BrowserMatch "Mozilla/2" nokeepalive
    BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
    BrowserMatch "RealPlayer 4\.0" force-response-1.0
    BrowserMatch "Java/1\.0" force-response-1.0
    BrowserMatch "JDK/1\.0" force-response-1.0
</IfModule>

<IfDefine SSL>
    AddType application/x-x509-ca-cert .crt
    AddType application/x-pkcs7-crl    .crl
</IfDefine>

<IfModule mod_ssl.c>
    SSLPassPhraseDialog  builtin
    SSLSessionCache         dbm:/var/log/httpd/ssl_scache
    SSLSessionCacheTimeout  300
    SSLMutex  file:/var/log/httpd/ssl_mutex
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
    SSLLog      /var/log/httpd/ssl_engine_log
   SSLLogLevel info
</IfModule>

<IfDefine SSL>
<VirtualHost _default_:445>
    DocumentRoot /home/httpd/html
    ServerAdmin root@localhost
    ErrorLog /var/log/httpd/error_log
    TransferLog /var/log/httpd/access_log
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile /etc/httpd/server.crt
    SSLCertificateKeyFile /etc/httpd/server.key
    <Files ~ "\.(cgi|shtml?)$">
        SSLOptions +StdEnvVars
    </Files>
    <Directory /home/httpd/cgi-bin>
        SSLOptions +StdEnvVars
    </Directory>
    SetEnvIf User-Agent ".*MSIE.*" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
    CustomLog /var/log/httpd/ssl_request_log \
        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

</IfDefine>

include /etc/httpd/conf/hostname.conf
发表于 2004-1-27 20:23:41 | 显示全部楼层
原来是这样……没理解清楚。:p
我估计你写两个Listen,然后在VirtualHost里面分开来写就可以了。没试过。
你这apache,该是2.0的吧?咱还用着1.3.26呢。
 楼主| 发表于 2004-1-28 07:36:48 | 显示全部楼层
不会没人搞过吧。
发表于 2004-1-28 13:34:44 | 显示全部楼层
装两个apache
分别监听80,81端口,就可以了
发表于 2004-1-28 14:51:22 | 显示全部楼层
最初由 pangdae 发表
装两个apache
分别监听80,81端口,就可以了


装只要装一个。
要做两个配置文件,就可以了。
是个办法。
 楼主| 发表于 2004-1-28 17:39:25 | 显示全部楼层
最初由 Glue 发表
装只要装一个。
要做两个配置文件,就可以了。
是个办法。


老大,能不能具体指教一二,我是刚入门的。
或从哪里能够找到相关资料?

谢谢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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