Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

Apache如果搭建虚拟主机?

[复制链接]
飞翔的希望 发表于 2006-2-11 10:19:53 | 显示全部楼层 |阅读模式
偶搞了半天也没搞懂,偶嘀最后是这么写的
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

<VirtualHost *:80>
    ServerAdmin lcx165@gmail.com
    DocumentRoot D:/usr/www/localhost/public_html/bbs
    ServerName bbs.nmjld.com
    ErrorLog logs/bbs-error_log
    CustomLog logs/bbs-access_log common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin lcx165@gmail.com
    DocumentRoot D:/usr/www/localhost/public_html
    ServerName www.nmjld.com
    ErrorLog logs/www-error_log
    CustomLog logs/www-access_log common
</VirtualHost>
Include D:/usr/local/httpd/conf/vhosts/[^.#]*

结果,配置成功,但是无法运行PHP,打开PHP就显示源代码,怎么回事啊?

[ 本帖最后由 飞翔的希望 于 2006-2-11 12:55 编辑 ]
 楼主| 飞翔的希望 发表于 2006-2-11 15:14:28 | 显示全部楼层
终于搞定了,编辑localhost文件就OK了
<VirtualHost *:80>

# 主机名 #
ServerName localhost
# 主机别名 #
ServerAlias www.nmjld.com
# 管理员邮件 #
ServerAdmin lcx165@gmail.com

# 安全重写规则 #
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

# 启动或禁止 PHP 引擎 #
php_admin_flag engine on
AddType application/x-httpd-php .php
#PHP 路径限制#
php_admin_value open_basedir "D:/usr/www/localhost/public_html;D:/usr/www/localhost/public_html/bbs;D:/usr/tmp"

# 文档目录 #
DocumentRoot D:/usr/www/localhost/public_html
    <Directory "D:/usr/www/localhost/public_html">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

# CGI 脚本目录 #
ScriptAlias /cgi-bin "D:/usr/www/localhost/cgi-bin"
    <Directory "D:/usr/www/localhost/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

# 允许执行的 CGI 扩展名 #
AddHandler cgi-script .cgi .pl

# 日志 #
CustomLog D:/usr/www/localhost/logs/access.log common

</VirtualHost>


<VirtualHost *:80>

# 主机名 #
ServerName localhost
# 主机别名 #
ServerAlias bbs.nmjld.com
# 管理员邮件 #
ServerAdmin lcx165@gmail.com

# 安全重写规则 #
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

# 启动或禁止 PHP 引擎 #
php_admin_flag engine on
AddType application/x-httpd-php .php
#PHP 路径限制#
php_admin_value open_basedir "D:/usr/www/localhost/public_html/bbs;D:/usr/tmp"

# 文档目录 #
DocumentRoot D:/usr/www/localhost/public_html/bbs
    <Directory "D:/usr/www/localhost/public_html/bbs">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

# CGI 脚本目录 #
ScriptAlias /cgi-bin "D:/usr/www/localhost/cgi-bin"
    <Directory "D:/usr/www/localhost/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

# 允许执行的 CGI 扩展名 #
AddHandler cgi-script .cgi .pl

# 日志 #
CustomLog D:/usr/www/localhost/logs/bbs-access.log common

</VirtualHost>
回复

使用道具 举报

help365 发表于 2006-2-11 17:31:15 | 显示全部楼层
好东西
回复

使用道具 举报

welcomef 发表于 2006-11-10 16:03:49 | 显示全部楼层
好文章,顶一下。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-1-11 03:48 , Processed in 0.027315 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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