您的位置:首页 > 运维架构 > Apache

linux下apache 配置虚拟主机

2012-10-28 15:24 549 查看

Virtual host

You now need to create an Apache virtual host for the application and edit yourhosts file so that
http://zf2-tutorial.localhost will serve
index.php from thezf2-tutorial/public directory.

Setting up the virtual host is usually done within
httpd.conf orextra/httpd-vhosts.conf. If you are using
httpd-vhosts.conf, ensurethat this file is included by your main
httpd.conf file. Some Linux distributions(ex: Ubuntu) package Apache so that configuration files are stored in
/etc/apache2and create one file per virtual host inside folder
/etc/apache2/sites-enabled. Inthis case, you would place the virtual host block below into the file/etc/apache2/sites-enabled/zf2-tutorial.

Ensure that NameVirtualHost is defined and set to “*:80” or similar, and thendefine a virtual host along these lines:

<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot /path/to/zf2-tutorial/public
SetEnv APPLICATION_ENV "development"
<Directory /path/to/zf2-tutorial/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


Make sure that you update your /etc/hosts orc:\windows\system32\drivers\etc\hosts file so that
zf2-tutorial.localhostis mapped to
127.0.0.1. The website can then be accessed usinghttp://zf2-tutorial.localhost.

127.0.0.1               zf2-tutorial.localhost localhost
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: