How to configure a vhost for zendframework?
I would like to configure a vhost to zf, but 开发者_运维技巧I have no idea how to do it, please if you could help would be great. Thanks
The process of creating a virtual host, depends on the version of APACHE, but overall remains the same.
APACHE (Scroll Down for APACHE2)
If your using regular apache, such as apache on the MAMP stack or Centos, You do the following.
Edit your httpd.conf file, in your apache conf directory, Add this to the end of the file.
(if using mamp, its in applications/mamp/conf/apache otherwise it should be in /etc/apache/conf)
NameVirtualHost *:80
<VirtualHost *:80>
ServerName quickstart.local
DocumentRoot /Applications/MAMP/htdocs/quickstart/public
SetEnv APPLICATION_ENV "development"
<Directory /Applications/MAMP/htdocs/quickstart/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
After this, restart apache,
sudo /etc/init.d/apache restart
or restart via your xamp stack client if it exists.
You now need to let your browser be aware of the domain name "quickstart.local" in this case.
Go into your hosts file.
sudo vim /etc/hosts
add the following line.
127.0.0.1 quickstart.local
exit
All done.
If your using APACHE2, you do the same thing, but instead of editing the httpd.conf file. Go into your /etc/apache2.conf
make sure
# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/
Is uncommented.
Now go into sites-available.
Create a new file name it the domain name, in this case "quickstart.local"
<VirtualHost *:80>
ServerName quickstart.local
ServerAlias quickstart.local
DocumentRoot /var/www/quickstart/public #or whatever the path is.
SetEnv APPLICATION_ENV "development"
<Directory /var/www/quickstart/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
save
Now go into your sites-enabled folder.
do the following
sudo ln -s /etc/apache2/sites-available/quickhost.local .
Now go edit the Hosts file like discussed above (If a made up domain name). You should be good.
If if this is not working , it may be that you dont have your directory enabled for .htaccess.
For Zend to work, you need to make sure that the directory is set to
"AllowOveride ALL"
<Directory <Path to whatever>>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
This allows the Zend routing system to work. This is set to off by default sometimes.
I usually had these in my apache's config in /etc/apache/sites-enabled/000-default
in this case i am using ubuntu +apache 2 :
NameVirtualHost zf.local:80
<VirtualHost zf.local:80>
DocumentRoot "/home/devlor/Sites/zf/public"
ServerName symfony.local
SetEnv APPLICATION_ENV development
<Directory "/home/devlor/Sites/zf/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
@ tawfekov:
Won't work if /home/devlor
isn't in Apache's trusted dir list:
<Directory /home>
Order allow,deny
Deny from none
Allow from all
</Directory>
<VirtualHost *:80>
ServerName overstock.local
DocumentRoot "C:\xampp\htdocs\overstock"
<Directory "C:\xampp\htdocs\overstock">
AllowOverride All
</Directory>
</VirtualHost>
Then change htaccess to
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /overstock/
RewriteCond %{REQUEST_URI} !/public [NC]
RewriteRule ^(.*)$ public/$1 [L]
精彩评论