apache虚拟主机:Apache虚拟主机快速搭建攻略来源: 发布时间:星期四, 2009年1月15日 浏览:35次 评论:0
在单个机器上
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 我们将在独立 ![]() ![]() ![]() ![]() ![]() ![]() </body> </html> 将内容修改为你想要 ![]() ![]() ![]() ![]() ![]() 步骤2:配置基于ip ![]() Suse在/etc/apache2/vhosts.d目录下存储虚拟主机配置文件 ![]() ![]() ![]() ![]() 使用模板文件 ![]() ![]() ![]() cd /etc/apache2/vhosts.d/ cp vhost.template vhost-port80.conf 这样拷贝默认 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() vi vhost-port80.conf 正如你所看到 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 下面这些行是你应该修改 ![]() VirtualHost 设置ip地址和端口 ServerAdmin web管理员 ![]() DocumentRoot web页面 ![]() ErrorLog ![]() CustomLog 访问日志文件路径 UseCanonicalName 本例中将其保留为off ScriptAlias 如果你想在你 ![]() ![]() ![]() 文件样例: <VirtualHost 192.168.33.101:80> ServerAdmin [email protected] e-mail address is being protected from spam bots, you need JavaScript enabled to view it ServerName server.myserver.com DocumentRoot /srv/www/htdocs/server_port80 ErrorLog /var/log/apache2/server_port80.log CustomLog /var/log/apache2/access_port80.log combined HostnameLookups Off UseCanonicalName Off ServerSignature On ScriptAlias /cgi-bin/ "/srv/www/htdocs/server_port80/cgi-bin/" <Directory "/srv/www/htdocs/server_port80/cgi-bin"> AllowOverride None Options +ExecCGI -Includes Order allow,deny Allow from all </Directory> <Directory "/srv/www/htdocs/server_port80"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> 如果你想在区别 ![]() ![]() ![]() ![]() <VirtualHost 192.168.33.101:8090> ServerAdmin [email protected] e-mail address is being protected from spam bots, you need JavaScript enabled to view it ServerName server.myserver.com DocumentRoot /srv/www/htdocs/server_port8090 ErrorLog /var/log/apache2/server_port8090.log CustomLog /var/log/apache2/access_port8090.log combined HostnameLookups Off UseCanonicalName Off ServerSignature On ScriptAlias /cgi-bin/ "/srv/www/htdocs/server_port8090/cgi-bin/" <Directory "/srv/www/htdocs/server_port8090/cgi-bin"> AllowOverride None Options +ExecCGI -Includes Order allow,deny Allow from all </Directory> <Directory "/srv/www/htdocs/server_port8090"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> 正常情况下 ![]() ![]() ![]() ![]() ![]() ![]() 步骤3:配置 ![]() ![]() 使用类似步骤2中 ![]() ![]() ![]() cd /etc/apache2/vhosts.d cp vhost.template vhost-www.conf 下面这两行是需要你修改 ![]() ServerName 使用在URL看到 ![]() UseCanonicalName On 注释:在Apache上开启了UseCanonicalName后 ![]() ![]() ![]() ![]() ![]() ![]() 如果你 ![]() ![]() ![]() ![]() VirtualHost 192.168.33.101:80 整个文件看起来应该象: <VirtualHost 192.168.33.101:80> ServerAdmin [email protected] e-mail address is being protected from spam bots, you need JavaScript enabled to view it ServerName www.myserver.com DocumentRoot /srv/www/htdocs/server_www ErrorLog /var/log/apache2/server_www.log CustomLog /var/log/apache2/access_www.log combined HostnameLookups Off UseCanonicalName On ServerSignature On ScriptAlias /cgi-bin/ "/srv/www/htdocs/server_www/cgi-bin/" <Directory "/srv/www/htdocs/server_www/cgi-bin"> AllowOverride None Options +ExecCGI -Includes Order allow,deny Allow from all </Directory> <Directory "/srv/www/htdocs/server_www"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> 步骤4:hack listen.conf文件 下面 ![]() ![]() Listen 添加运行web页面 ![]() ![]() ![]() NameVirtualHost 这个指令告诉Apache在哪个ip地址 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 这个文件 ![]() Listen 80 Listen 8090 <IfDefine SSL> <IfDefine !NOSSL> <IfModule mod_ssl.c> Listen 443 </IfModule> </IfDefine> </IfDefine> NameVirtualHost 192.168.33.101:80 要对你 ![]() ![]() ![]() tail –f /var/log/messages 在修改了配置文件后别忘了使用下面 ![]() ![]() service apache2 restart 或 /etc/init.d/apache2 restart 0
相关文章
读者评论
发表评论 |