介紹Zend Framework的入門(mén)資料, 多數(shù)都是教人在Apache下創(chuàng)建一個(gè)新的Virtual Host。用Zend_Tool生成的代碼也有一個(gè)doc,說(shuō)明這個(gè)Virtual Host如何來(lái)創(chuàng)建。我們真的需要?jiǎng)?chuàng)建Virtual Host嗎? 特別是開(kāi)發(fā)階段,為每一個(gè)項(xiàng)目創(chuàng)建Virtual Host,有意義嗎?個(gè)人感覺(jué)這是一種誤導(dǎo)。
一個(gè)Virtual Host, 要么監(jiān)聽(tīng)不同的端口,要么使用新的域名。開(kāi)發(fā)階段,大概傾向前者。但是,盡管如此,配置一個(gè)監(jiān)聽(tīng)不同端口的Virtual Host干嗎?如果是開(kāi)發(fā)階段,我倒是傾向于在apache的配置中(比如/etc/apache2/sites-enabled/000-default)增加一個(gè)了事,簡(jiǎn)單但是管用。例如:
Alias /helloZend/ "/home/brian/Dev/PHP/ZendStudio-7.1.2/workspace/helloZend/public/"
<Directory "/home/brian/Dev/PHP/ZendStudio-7.1.2/workspace/helloZend/public/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
項(xiàng)目建在/home/brian/Dev/PHP/ZendStudio-7.1.2/workspace/下,項(xiàng)目名為helloZend。這是用Eclipse創(chuàng)建的(Zend Studio類(lèi)似)一個(gè)項(xiàng)目,具有典型的目錄結(jié)構(gòu)(其實(shí)與IDE并無(wú)關(guān)系,關(guān)鍵是目前結(jié)構(gòu))。測(cè)試一下便可以知道,這樣的配置一樣可以工作,例如: http://localhost/helloZend/,別忘記了最后的那個(gè)斜線(xiàn),否則是會(huì)出錯(cuò)的。
ps: 同時(shí)建議將SetEnv APPLICATION_ENV development移到public/.htaccess中。
一個(gè)Virtual Host, 要么監(jiān)聽(tīng)不同的端口,要么使用新的域名。開(kāi)發(fā)階段,大概傾向前者。但是,盡管如此,配置一個(gè)監(jiān)聽(tīng)不同端口的Virtual Host干嗎?如果是開(kāi)發(fā)階段,我倒是傾向于在apache的配置中(比如/etc/apache2/sites-enabled/000-default)增加一個(gè)
Alias /helloZend/ "/home/brian/Dev/PHP/ZendStudio-7.1.2/workspace/helloZend/public/"
<Directory "/home/brian/Dev/PHP/ZendStudio-7.1.2/workspace/helloZend/public/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
項(xiàng)目建在/home/brian/Dev/PHP/ZendStudio-7.1.2/workspace/下,項(xiàng)目名為helloZend。這是用Eclipse創(chuàng)建的(Zend Studio類(lèi)似)一個(gè)項(xiàng)目,具有典型的目錄結(jié)構(gòu)(其實(shí)與IDE并無(wú)關(guān)系,關(guān)鍵是目前結(jié)構(gòu))。測(cè)試一下便可以知道,這樣的配置一樣可以工作,例如: http://localhost/helloZend/,別忘記了最后的那個(gè)斜線(xiàn),否則是會(huì)出錯(cuò)的。
ps: 同時(shí)建議將SetEnv APPLICATION_ENV development移到public/.htaccess中。