setting a local host in xp - php

I created a project in zendframework:
zf create project dev.gamenomad.com
Then, I put this:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.localhost
DocumentRoot "C:/apache/docs/dev.gamenomad.com/public"
ServerName dev.gamenomad.com
ServerAlias dev.gamenomad.com
ErrorLog "logs/dev.gamenomad.com-error.log"
CustomLog "logs/dev.gamenomad.com-access.log" common
</VirtualHost>
and I put this:
127.0.0.1 dev.gamenomad.com in C:\WINDOWS\system32\drivers\etc
Then, restarted apached..
I get this message when putting this url:
http://dev.gamenomad.com/
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 dev.gamenomad.com 12/11/2011 8:12:29 PM Apache/2.2.17
(Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4
Perl/v5.10.1
Why do I get that error?

You get this error because directory listing isn't enabled and there's no default document found.
Add the following code to the VirtualHost to show a list of files in the directory
Options +Indexes
Or alternatively create a file called index.html (or any other supported extension which you've installed) and put some content into the file
You may also wish to consider adding the following to the VirtualHost in order to allow access to that directory
<Directory "c:\{path_to_directory}">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Edit in response to the OP's comment
You already have the following VirtualHost configuration.
ServerAdmin webmaster#dummy-host.localhost
DocumentRoot "C:/apache/docs/dev.gamenomad.com/public"
ServerName dev.gamenomad.com
ServerAlias dev.gamenomad.com
ErrorLog "logs/dev.gamenomad.com-error.log"
CustomLog "logs/dev.gamenomad.com-access.log" common
Changing your configuration to add the Options and Allow settings you'll be able to run your website on localhost but it'll fix your error.
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.localhost
DocumentRoot "C:/apache/docs/dev.gamenomad.com/public"
ServerName dev.gamenomad.com
ServerAlias dev.gamenomad.com
ErrorLog "logs/dev.gamenomad.com-error.log"
CustomLog "logs/dev.gamenomad.com-access.log" common
Options +Indexes
<Directory "c:\{path_to_directory}">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Refer to Apache's Allow and Options directives.

Related

apache2.conf and httpd.conf

After reading ubuntu AMP community and Apache 2.4 configuration.
I was wondering if there is a way to imitate the same behavior of the http docs used in XAMPP or bitnami stacks but using the default LAMP. Which uses apache 2.4
In XAMP you would assign an extra number to your httpd-vhost.conf like this:
Listen *:9000
<virtualhost *:9000>
ServerName localhost
DocumentRoot "~/xamp/apache2/htdocs/html/app-name/"
</virtualhost>
<Directory "~/xamp/apache2/htdocs/html/app-name/">
Options Indexes FollowSymLinks
AllowOverride all
</Directory>
Then Edit your httpd.conf files like:
//....Some code..... */
<Directory>
AllowOverride all
<Directory />
//...Some code...
and uncomment this line:
//....Some code..... */
# Virtual hosts
include conf/extra/httpd-vhosts.conf
//...Some code...
My question is:
Is there is a way to configure Apache 2.4 just by dropping all my vhost's in one single file, without having to go through the process of configuring etc/apache2/sites-available and then adding names to etc/hosts?
Then completing the process by including some things like above just like Bitnami or Xamp stacks will do so your localhost will be able to serve not only static html files but an entire application's folder.
What works is the following in (for example) your 000-default.conf:
<VirtualHost *:80>
ServerName site1.vm
ServerAdmin webmaster#localhost
DocumentRoot /var/www/site1/web/
ErrorLog ${APACHE_LOG_DIR}/site1_error.log
CustomLog ${APACHE_LOG_DIR}/site1_access.log combined
<Directory /var/www/site1/web/>
Options All
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName site2.vm
ServerAdmin webmaster#localhost
DocumentRoot /var/www/site2/web/
ErrorLog ${APACHE_LOG_DIR}/site2_error.log
CustomLog ${APACHE_LOG_DIR}/site2_access.log combined
<Directory /var/www/site2/web/>
Options All
AllowOverride All
</Directory>
</VirtualHost>
This way all you have to do is add the site to the conf file, add the host to your hosts file, and reload apache2 service. Hope that is what you were looking for.

Several virtual hosts on the same port with Apache 2.4

I'm trying to do something simple with virtual hosts in Apache 2.4 (using Wampserver 2.5)
I want to be able to have several virtual hosts and access them simply by :
www.project1.dev
www.project2.dev
So I made the following configuration in httpd.conf by reading the official guide :
NameVirtualHost \*:80
#
# Project 1
#
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/myProject1/"
ServerName www.project1.dev
ErrorLog "logs/project1-error_log "
CustomLog "logs/project1-access_log" common
<Directory "C:/wamp/www/myProject1/">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
#
# Project 2
#
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/myProject2/"
ServerName www.project2.dev
ErrorLog "logs/project2-error_log "
CustomLog "logs/project2-access_log" common
<Directory "C:/wamp/www/myProject2/">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
I also added them to my hosts file
127.0.0.1 http://project1.dev
127.0.0.1 http://project2.dev
But while I'm testing after restart wamp services, both http://project1.dev and http://project2.dev point at C:/wamp/www/myProject1/
The second path C:/wamp/www/myProject2/ related to project2.dev seems to be ignored.
Am I missing something?
Thanks.
You have not defined http://project2.dev anywhere - just http://www.project2.dev. So Apache defaults back to first config as it can't find a match.
Add the following config to the first vhost:
ServerAlias project1.dev
and similarly this to the second:
ServerAlias project2.dev
Then restart Apache.
The simple answer is that as of Apache 2.4 the NameVirtualHost *:80 syntax is no longer required or allowed! It throws an error and causes Apache not to start. The error will appear in the apache error log if you look for it.
Oh and NameVirtualHost \*:80 was never right!
So just remove the line NameVirtualHost \*:80 completely.
As soon as you define a Virtual Host, the localhost in httpd.conf gets ignored so you should define that in httpd-vhost.conf as well, otherwise the other 2 VH defs look fine, except for the ServerName and missing ServerAlias and the missing Options
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/"
ServerName localhost
<Directory "C:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require local
</Directory>
</VirtualHost>
#
# Project 1
#
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/myProject1/"
ServerName project1.dev
ServerAlias www.project1.dev
ErrorLog "logs/project1-error_log "
CustomLog "logs/project1-access_log" common
<Directory "C:/wamp/www/myProject1/">
AllowOverride all
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
</VirtualHost>
#
# Project 2
#
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/myProject2/"
ServerName project2.dev
ErrorLog "logs/project2-error_log "
CustomLog "logs/project2-access_log" common
<Directory "C:/wamp/www/myProject2/">
AllowOverride all
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
</VirtualHost>
Quote: But while I'm testing after restart wamp services, both http://project1.dev and http://project2.dev point at C:/wamp/www/myProject1/
If there is an error in your VH definitions, Apache will default to the first correctly defined VH in the httpd-vhosts.conf, so thats what is probably happening
As to your HOSTS file it should include references to the IPV4 and IPV6 stack, especially as windows seems to use the IPV6 stack more and more, afterall that where we are moving to, eventually, and it should not include httpd:// so it should be like this :-
#IPV4 stack ip addresses
127.0.0.1 localhost
127.0.0.1 project1.dev
127.0.0.1 project2.dev
#IPV6 stack ip addresses
::1 localhost
::1 project1.dev
::1 project2.dev
Once you have changed the HOSTS file, you either need to reboot, or do the following in a command windows launches with "Run as Administrator"
net stop dnscache
net start dnscache

Apache virtual host 404 not found

I just started learning php and I am trying to host locally my own php website by using XAMPP.
I wanted to create virtual host with:
URL: myphpwebsite.local
Port: 8088
But when I attempted to access this website through the browser I got a:
Not Found
HTTP Error 404. The requested resource is not found.
Does anyone know what the problem is?
My httpd-vhosts.conf
NameVirtualHost 127.0.0.1:8088
<VirtualHost 127.0.0.1:8088>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost myphpwebsite.local>
DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
ServerName myphpwebsite.local
ErrorLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.error.log"
CustomLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.custom.log" combined
<Directory "C:/Microsoft/Workspace/myphpwebsite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And my C:\Windows\System32\drivers\etc\hosts file:
127.0.0.1 localhost
127.0.0.1 myphpwebsite.local
Any help would be appreciated!
make sure there's file/htaccess/index or whatever in directory you want to open, 404 may comes from that ;)
try using one below, eventually replace your port:
<VirtualHost *:80>
DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
ServerName myphpwebsite.local
</VirtualHost>
the question is your Apache running/serving on port 8088?
For example my xamp is running on 80 and 443...
xamp control panel is very handy, it has nice logs button that will open your log files to show you php and apache errors etc. check it out.
Try going with default port, if it works it means that you need to play with ports if you really want to.
just a quick tip, .com is shorter than .local and if you're using chrome and it works like mine then most of the time something.local will redirect you to google search (and I like my search there, you can switch it off ;))
I don't know if I am much help, but using WAMP, here are my settings. I am listening on port 80, I use 8080 for my tomcat server.
hosts file
127.0.0.1 local.mysite.com
httpd-vhosts.conf
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
....
<Directory "c:/wamp/www">
Options Indexes MultiViews FollowSymLinks
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
<VirtualHost *:80>
ServerName localhost
DocumentRoot "c:/wamp/www"
</VirtualHost>
<Directory "c:/wamp/www/path/to/site/root">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerName local.mysite.com
DocumentRoot "c:/wamp/www/path/to/site/root"
ServerAdmin me#email.com
ProxyPreserveHost Off
RewriteEngine On
AllowEncodedSlashes NoDecode
#AllowEncodedSlashes On
ErrorLog "c:/wamp/www/path/to/logs/error.log"
CustomLog "c:/wamp/www/path/to/logs/access.log" common
</VirtualHost>
....
Then I can access my local site like this: http://local.mysite.com
Hope this helps...
The NameVirtualHost directive needs to match the value of VirtualHost exactly, and you need to specify the port in each instance. If you want to use port 8088 for myphpwebsite.local, you'd need to do:
NameVirtualHost 127.0.0.1:8088
<VirtualHost 127.0.0.1:8088>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1:8088>
DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
ServerName myphpwebsite.local
ErrorLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.error.log"
CustomLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.custom.log" combined
<Directory "C:/Microsoft/Workspace/myphpwebsite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Notice the VirtualHost opening tags are identical; it's the ServerName value that actually tells Apache which domain this particular directive applies to. Restart your server after making the changes. Check out this page for more information: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
Hope this helps!
Make sure that the port you are using is not being used by another service.

Setting up a virtual host Wamp

I know this question has been asked several times, and ive even done it alot of times in my company, but, now I wanted to set up a virtual host at home and Its not working.
What have I done:
Added xxx.localhost.de into the hosts
127.0.0.1 xxx.localhost.de
Uncommented include vhosts... in my httpd.conf
Include conf/extra/httpd-vhosts.conf
Set up a virtual host for my project
<VirtualHost *:80>
ServerAdmin asdr#web.de
DocumentRoot "D:\wamp\www\xxx"
ServerName xxx.localhost.de
ServerAlias xxx.localhost.de
ErrorLog "logs/xxx-error.log"
CustomLog "logs/xxx-access.log" common
</VirtualHost>
I dont get an error - wamp is still starting fine and I can access it by using the normal path
localhost/...
but when i try to reach it over xxx.localhost.de , I get on the website "www.localhost.de". It acts like he does NOT care about my hosts file...
What have I actually missed out? In my company it always worked like this. Ive checked tutorials aswell, and it always says this are all the steps which are needed.
Thanks!
I have had the same problem too, There are couple of things that can cause that, first try to add DirectoryIndex index.php to
<VirtualHost *:80>
ServerAdmin asdr#web.de
DocumentRoot "D:\wamp\www\xxx"
DirectoryIndex index.php
ServerName xxx.localhost.de
ServerAlias xxx.localhost.de
ErrorLog "logs/xxx-error.log"
CustomLog "logs/xxx-access.log" common
</VirtualHost>
then you can try to write in your browser "http://you_address.local
if this doesn't help,I will think of anything else that can cause that
Try this :-
Change the HOSTS file to :-
127.0.0.1 localhost
::1 localhost
127.0.0.1 project1.dev
::1 project1.dev
And the Vhost definition to
<VirtualHost *:80>
ServerAdmin asdr#web.de
DocumentRoot "D:\wamp\www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "D:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin asdr#web.de
DocumentRoot "D:\wamp\www\xxx"
ServerName project1.dev
ServerAlias www.project1.dev
ErrorLog "logs/project1-error.log"
CustomLog "logs/project1-access.log" common
<Directory "D:/wamp/www/xxx">
AllowOverride All
Require local
</Directory>
</VirtualHost>
It seems I had to make the changes to the hosts.ics file, and not the standard hosts file. It worked just fine then

routing in laravel3 not working properly

I am new bee in Laravel. I have set up Laravel by help of this tutorial. I have set virtual host, on my virtual host I wrote this.
<VirtualHost *:80>
ServerName ranjitalaravel.com
DocumentRoot "/var/www/html/laravel4/public"
<Directory "/var/www/html/laravel4/public">
</Directory>
</VirtualHost>
In my host file i.e. /etc/hosts
127.0.0.1 ranjitalaravel.com
When I type the http://ranjitalaravel.com/ on my browser all list of file inside my laravel directory is showing. But when I type home after it it shows me "The requested URL /home was not found on this server.". I have write this code in route.php inside application folder.
Route::any('home', function()
{
return View::make('home.index');
});
<VirtualHost *:80>
ServerAdmin postmaster#some_server
DocumentRoot "E:/xampp/htdocs/some_server"
ServerName some_server
ServerAlias some_server
ErrorLog "logs/some_server.localhost-error.log"
CustomLog "logs/some_server.localhost-access.log" combined
</VirtualHost>
this works fine to me, hope helps you
Try this configuration
<VirtualHost *:80>
ServerName ranjitalaravel.com
DocumentRoot /var/www/html/laravel4/public
<Directory /var/www/html/laravel4/public/>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
</VirtualHost>
are you using symlinks?
Instead of using VirtualHosts which can get nasty from time to time why not use PHP 5.4 inbuilt development server.
Here's how XAMPP localhost returns object not found after installing Laravel

Categories