Zend Framework 2, vhosts and MAMP - apache

I think I've configured all files properly, but when I access the url: myapp.local, it points to the MAMP/htdocs/ directory instead of /MAMP/htdocs/ZendSkeletonApplication-master/public/ (going to this public directory displays correctly de zf2 example webpage), here is my configuration:
httpd-vhosts.conf
<VirtualHost *:8888>
ServerName myapp.local
DocumentRoot "/Applications/MAMP/htdocs/ZendSkeletonApplication-master/public/"
<Directory "/Applications/MAMP/htdocs/ZendSkeletonApplication-master/public/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
hosts
127.0.0.1 myapp.local
Can someone tell me what I'm doing wrong? I want my base url to point at the /Applications/MAMP/htdocs/ZendSkeletonApplication-master/public/ directory, not at htdocs.
Similar question here, but I can't get the answer. Vhost Zend Framework configuration MAMP - redirected to the index page of the server
Thanks

Just try this in the httpd.conf file (where you must have enabled to include the httpd-vhosts.conf file) -
<VirtualHost myapp.local>
DocumentRoot "/Applications/MAMP/htdocs/ZendSkeletonApplication-master/public/"
</VirtualHost>
There should be no need to enable the httpd-vhosts.conf file.

Related

MAMP Apache Won't Start with Virtual Host for SimpleSAMLphp

I'm attempting to configure simpleSAMLphp within a MAMP/Apache environment on Windows 10 and below is my httpd-vhosts.conf file:
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/MAMP/htdocs
</VirtualHost>
<VirtualHost *:80>
ServerName simplesamlphp
DocumentRoot C:/MAMP/htdocs/pro-dashboard
Alias /simplesaml C:/MAMP/simplesamlphp/www
<Directory C:/MAMP/simplesamlphp/www>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And here is my /etc/hosts file:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# Virtual Hosts
127.0.0.1 simplesamlphp
Apache starts via MAMP totally fine without including this httpd-vhosts.conf file in my httpd.conf file, but as soon as its included, Apache will not start so the issue appears to be with httpd-vhosts.conf. No errors are shown in the apache_error.log file. My Apache version is 2.2 so I believe my Directory directives in my second VirtualHost are correct.
I've tried double quoting the DocumentRoot's, directory paths etc, and also tried backslashes over forward slashes. I spent most of yesterday trying to figure this out while scouring the web but nothing I found has made this work.
Any help is much appreciated!
Try this modified config
The path in Directory header same as DocumentRoot!
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/MAMP/htdocs
</VirtualHost>
<VirtualHost *:80>
ServerName simplesamlphp
DocumentRoot C:/MAMP/htdocs/pro-dashboard
Alias /simplesaml C:/MAMP/simplesamlphp/www
<Directory C:/MAMP/htdocs/pro-dashboard>
Order allow,deny
Allow from all
AllowOverride All
</Directory>
</VirtualHost>
So oddly enough, taking out what I had in httpd-vhosts.conf and simply putting it in my httpd.conf file makes Apache start back up.

Creating Multiple Virtual Hosts on xampp apache server v-3.2.1 on windows-10

I am tried to create Multiple Virtual Hosts on my Windows 10, 64-bit, XAMPP 3.2.1
I did the following:
1- C:\Windows\System32\drivers\etc\hosts
I have added these line at the bottom of the hosts file:
127.0.0.1 smc
127.0.0.1 ocms
2- D:\xampp\apache\conf\httpd.conf
Virtual hosts is already is enabled see the following:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
3- D:\xampp\apache\conf\extra\httpd-vhosts.conf
Here i have added the following code block on httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName smc
DocumentRoot "D:/vhosts/smc"
SetEnv APPLICATION_ENV "development"
<Directory "D:/vhosts/smc/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName ocms
DocumentRoot "D:/vhosts/ocms/"
SetEnv APPLICATION_ENV "development"
<Directory "D:/vhosts/ocms">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Finally i have put both my directories in my D:/vhosts/ folder:
D:/vhosts/ocms
D:/vhosts/smc
After i have restarted my apache server and test the url like:
http://ocms
Or
http://smc
It returns the following error:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
ocms
Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8
I have googled it too many times for last three to four days and also followed some other posts on stackoverflow i.e. how to create virtual host on XAMPP but with no luck. Please let me know what i am missing.
Thanks
Ok i have done it. i had to put all my directories under the htdocs folder like this.
structure should be:
D:\xampp\htdocs
D:\xampp\htdocs\test\smc
D:\xampp\htdocs\test\ocms
Thank you all for your precious time
Your initial settings works fine for me.
I think your problem was that the index was missing.
This line will force Apache to accept only index.php file as entry point:
DirectoryIndex index.php
However, if your entry point has a different name or extension you get the error:
You don't have permission to access the requested directory. There is either no index document or the directory is read-protecte

Configure MAMP to treat each directory in Htdocs as Root in Apache mod_redirect

The issue is that when using MAMP for local development, the .htaccess file needs to differ in that the RewriteBase needs to specify the subdirectory for the specific site (as shown here on SO).
Is there a way to configure MAMP MAMP/conf/apachehttpd.conf so that each virtual site gets it's own "root"?
UPDATE
After getting a clue about Virtual Hosts:
Have updated /etc/hosts file to include:
127.0.0.1 ClientSite.localhost
Uncommented the line:
`#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf`
in /Applications/MAMP/conf/apache/httpd.conf.
There is a directory called ClientSite in /Users/myname/Sites/.
This is the /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf content:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
ServerName localhost
ServerAlias *.localhost
VirtualDocumentRoot /Users/myname/Sites/%0
RewriteLogLevel 3
RewriteLog "/Applications/MAMP/logs/rewrite.log"
<Directory /Users/myname/Sites>
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Restarted the MAMP servers (and even ran dscacheutil -flushcache).
When browser is pointed to ClientSite.localhost it returns a 404: The requested URL / was not found on this server.
so that each virtual site gets it's own "root"?
You need to use VirtualDocumentRoot.
This is how I am using this on my MAMP in my /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf file:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
ServerName localhost
ServerAlias *.localhost
VirtualDocumentRoot /Users/admin/htdocs/%0
RewriteLogLevel 3
RewriteLog "/Applications/MAMP/logs/rewrite.log"
<Directory /Users/admin/htdocs>
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Take note of VirtualDocumentRoot /Users/admin/htdocs/%0 directive. That makes each virtual site's root as:
VirtualDocumentRoot /Users/admin/htdocs/localhost
VirtualDocumentRoot /Users/admin/htdocs/dev.localhost
VirtualDocumentRoot /Users/admin/htdocs/client2.localhost
etc.
Then simply create a directory within /Users/admin/htdocs/ for each site named as above, like:
dev.localhost
client2.localhost
Remove (or rename) any .htaccess files during the process - and once websites confirmed to be accessible via url like: http://client2.localhost, .htaccess files should behave as expected.
Also be sure that in the /etc/hosts file, there's an entry like:
127.0.0.1 client2.localhost
for each URL in question.

Server set up of project with vhosts config

Zend framework is new to me and I'm working from a book so I can get a rudimentary grasp of things (book is Zend Framework A Beginners Guide).
I have my project set up and have created it in a folder called "test"
I have also added a vhost, vhosts file contains:
<VirtualHost *:80>
DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public"
ServerName .localtest
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "C:/Program Files/Zend/Apache2/htdocs/test/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I have called the vhosts file from within apaches conf file
I have also added a line to system32 hosts file:
127.0.0.1 test.localtest
My problem is that when I browse to http://test.localtest/ I get the zend server test page, when as from what I am reading I should be getting the Zend Framework projects Main Page splash, this I can reach by browsing to http://test.localtest/test/public/
Am I missing something?
Try changing
<VirtualHost *:80>
DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public"
ServerName .localtest
to
<VirtualHost *:80>
DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public"
ServerName test.localtest
EDIT
ok i have check on my system and it work perfectly, but i am using ubuntu hope this helps
edit this file
C:\Program Files\Zend\Apache2\conf (Zend Server on Windows machines)
and add this code
<VirtualHost *:80>
ServerName test.localtest
DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/Program Files/Zend/Apache2/htdocs/test/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
then edit this file
C:\WINDOWS\system32\drivers\etc\hosts
and add this line
127.0.0.1 test.localtest
and then dont forget to restart you apache server (wamp or xampp or anything you are using)
and then open this link
http://test.localtest
try to write the url with http:// sometimes the browser does not work without http://
try it comment if it does not work
one thing most everyone misses is that Zf needs FollowSymlinks to work most of the time.
this is the directory definition I usually use in my vhosts
<directory "C:\www\project">
Options Indexes FollowSymlinks
AllowOverride all
Order Deny,Allow
Allow from all
</directory>
not sure how DirectoryIndex will affect this.
make sure mod_rewrite is enabled in Apache:
LoadModule rewrite_module modules/mod_rewrite.so //make sure this line is uncommented httpd.conf
make vhosts is enabled in apache:
Include conf/extra/httpd-vhosts.conf //make sure this line is uncommented httpd.conf
make sure this line is present in your vhosts file usually above the vhosts definitions:
NameVirtualHost *:80

How do I create a VirtualHost on Zend Server?

I am using zend server and I added one VirtualHost into the extra/httpd-vhosts.conf file and removed # from the httpd.conf file.
This is what I added into the extra/httpd-vhosts.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName quickstart.local
DocumentRoot D:/quickstart/Code
<Directory D:/quickstart/Code>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I access quickstart.local it is working fine, but it also affects localhost (i.e when I try to load http://localhost/, I see the same site I do for http://quickstart.local/.
How do I resolve this issue? I want both localhost (I use this for another project) and quickstart.local to be separate.
I have the same problem. Try to add a host to zend.conf or
add
Include conf/extra/httpd-vhosts.conf
to htppd.conf
You can add a new vhost by adding the directives to a new file:
/path/to/zend/etc/sites.d/vhost_[my-site].conf
Replace [my-site] with whatever you want (no spaces).
Then, be sure you restart apache:
sudo /path/to/zend/bin/apachectl restart
I had similar issue when trying to add own sites. Solution for me was to comment both vhost examples in vhosts file and also uncomment or add the
127.0.0.1 localhost
into hosts file in %windir%/system32/drivers/etc folder
... ofcourse if you need to uncomment vhost_alias module and include for httpd-vhosts file..
[FILE PATH] \xampp\apache\conf\extra\httpd-vhosts.conf or, if you are
using Apache 2.4 or above:
<VirtualHost *:80>
ServerName dev.zendapp
DocumentRoot "G:/xampp/htdocs/io2018/zend2018/zendApps"
SetEnv APPLICATION_ENV "development"
<Directory "G:/xampp/htdocs/io2018/zend2018/zendApps">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
After change. C:\Windows\System32\drivers\etc\hosts
127.0.0.1 dev.zendapp
Restart Your xampp Server