How to create multiple virtual hosts with apache2 and zend - zend-framework

I have created zend application in /var/www/zendapp , but i have also installed mediawiki app
in /var/www/mediawiki
Now i want to access mediawiki app with http://mediawiki.local
and http://zendapp.local.
How can i do that?
I had couple of unsuccessful atempts. So far i edited /etc/hosts and added these two lines:
127.0.0.1 zendapp.local
127.0.0.1 mediawiki.local
I also created two files in /etc/apache2/sites-available/ :
zendapp
mediawiki
mediawiki :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mediawiki.local
DocumentRoot /var/www/mediawiki
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/mediawiki>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
zendapp :
ServerName zendapp.local
SetEnv APPLICATION_ENV "development"
DocumentRoot /var/www/zendapp/public
<Directory /var/www/zendapp/public>
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
But now it semes that only zendapp.local works, and if I go to :
http://mediawiki.local
it redirects me to http://zendapp.local/mediawiki/index.php/Main_Page

Do this: Separate virtualhost blocks:
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mediawiki.local
DocumentRoot /var/www/mediawiki
#all other settings
.
.
.
</VirtualHost>
<VirtualHost *:80>
ServerName zendapp.local
DocumentRoot /var/www/zendapp/public
#all other settings
.
.
.
</VirtualHost>

Check out this blog, his answer worked!
http://justanswersnobullshit.wordpress.com/
I tried this out myself, after being frustrated by online video tutorials on how to setup multiple virtual hosts

And you do not accidentally forgot to include this site? That is, in the 'sites-enabled' directory should be by appropriate reference. Usually you should run the following commands:
sudo a2ensite host_name
sudo service apache2 reload
As a second variant, I can suppose, that 'DocumentRoot' should be ended by a slash:
DocumentRoot /var/www/zendapp/public/

Related

Zend Project: Links don't work on local Server

im new to Zend Framework. Now i have to make some changes to an existing Zend Project. But on my local Xampp Installiation all links doesn't work.
I already set up a virtual host. Since then the Start page work correctly.
<VirtualHost *:80>
DocumentRoot "C:\xampp_54_zend\htdocs\myproject\public"
ServerName myproject
</VirtualHost>
But on every Link i get an error: "Link incorrect oder doesn't exist".
Edit: 404 Error
On the Live-Server everything works correctly.
What can i do to find the error and make the links working?
Try using below configuration:
<VirtualHost *:80>
ServerName myproject
DocumentRoot "C:/xampp_54_zend/htdocs/myproject/public"
DirectoryIndex index.htm index.html index.php
<Directory "C:/xampp_54_zend/htdocs/myproject/public">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Setting Up Virtual hosts for XAMPP on windows

XAMPP for Windows 1.8.2 PHP 5.4,
Operating System : windows xp
I am using username and passowrd on XAMPP
c:\windows\system32\drivers\etc\hosts
127.0.0.1 hindustans.local
127.0.0.1 read.local
E:\My Projects\wesites\read
index.html
httpd-vhosts.conf
<Directory "E:/My Projects/wesites/read">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:/My Projects/wesites/read"
ServerName read
Options +Indexes
</VirtualHost>
read.local works fine with c:\xampp\htdocs
But
read.local doesn't work with E:\My Projects\wesites\read\index.html
I brief want to run my project from E:\My Projects\wesites\read
You need match the ServerName to the address you have in hosts and give it permission
<VirtualHost *:80>
DocumentRoot "E:/My Projects/wesites/read"
ServerName read.local
<Directory "E:/My Projects/wesites/read" >
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
then try to access the site at read.local.
More info here

zf2 virtual host loading localhost/xampp

I'm trying to get zf2 running on my xampp.
I have this vhosts.conf file
NameVirtualHost 127.0.0.1:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot "C:/xampp/htdocs/zf2-tutorial"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/zf2-tutorial">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
and this host file
127.0.0.1 zf2-tutorial.localhost
Now, when I run zf2-tutorial.localhost, the browser goes to zf2-tutorial.localhost/xampp and shows xampp page.
When I run localhost it goes to localhost/xampp too.
Please help.
Try http://zf2-tutorial.localhost/public
If that works you could change the following entries in your vhosts file
DocumentRoot "C:/xampp/htdocs/zf2-tutorial/public"
<Directory "C:/xampp/htdocs/zf2-tutorial/public">

Zend Framework - don't have permission to access file in public

That is my iframe:
<iframe allowtransparency="true" class="igm" src="/flash/dewplayer-vol.xml&
amp;container=enterprise&view=default&lang=en&country=ALL&sanitize=0&
amp;v=cb90d5949f2275bc&up_CCOL=%23d1dae3&up_START=No&
amp;up_MP3=http://www.youtube-mp3.org/get?video_id=z0FERtqhwHs&
h=6a29a4973a0431d2638ba3f5a1aecfeb&r=1373776845504&up_LOOP=No&
amp;libs=analytics:core:flash&mid=55&rpctoken=-1666220716119396559"
frameborder="0" height="400" scrolling="yes" width="500"></iframe>
But when I open my page it appears:
Forbidden
You don't have permission to access /flash/dewplayer-vol.xml&container=enterprise&view=default&lang=en&country=ALL&sanitize=0&v=cb90d5949f2275bc&up_CCOL=#d1dae3&up_START=No&up_MP3=http://www.youtube-mp3.org/get on this server.
Apache/2.2.8 (Win32) PHP/5.2.6 Server at 212.43.43.254 Port 80
That is my httpd.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot C:\AppServ\www\site\public
</VirtualHost>
<Directory "C:/AppServ/www/site/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
There some several step you have to follow in web server just go throw all this
1. Find the httpd.conf file (usually you will find it in a folder called conf, config or something along those lines)
2. Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound '#' sign from in front of the line)
Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out.
And still you have more query then go to this LINK
Also
If you set up your virtual host the default way, i.e.
<VirtualHost *:80>
DocumentRoot "D:/Users/user/www/yourwebsite.dev/public"
ServerName .local
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "D:/Users/user/www/yourwebsite.dev/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
You may access the public dir, by:
http://yourwebsite.dev/
and files in public dir by:
http://yourwebsite.dev/filename.ext
It is all about DocumentRoot.
i hope this will sure help you.

Can't open localhost after configuring httpd.conf

I've installed Zend Framework, and I've created my project "zendy" to the path: D:\wamp\www\zendy. So I modified the file "httpd.conf" (I use WAMPSERVER) by adding:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName zendy
DocumentRoot D:\wamp\www\zendy\public
<Directory D:\wamp\www\zendy\public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And then I restarted all the services of WAMPSERVER. I add a line "127.0.0.1 zendy" in the file C:\Windows\System32\divers\etc\hosts
Then I type "zendy/" or "localhost" in my navigator but it displays something like:
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request."
I totally follow the tutorial for installing zend frameline like :
http://www.youtube.com/watch?v=m7svJHmgJqs and http://framework.zend.com/manual/en/learning.quickstart.create-project.html
Who can help me?? Thanks a lot!!
Verify virtual configuration syntax using “httpd -S”
Also find something like this in httpd.conf and uncomment it by removing the preceding # sign before Include
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
Please don't remove the # sign before Virtual hosts as depicted above.
Also, add
Options Indexes FollowSymLinks
before
AllowOverride All
and restart wamp
Here is the correct configuration:
<VirtualHost *:80>
ServerName zendy
DocumentRoot D:\wamp\www\zendy\public
</VirtualHost>
You do not need to mention directory under this.
Try and revert! :)
PS: Also, check for AllowOverride in your main httpd.conf or apache2.conf file. Hope it helps!