i use xampp on mac os and i want to add virtual host on it
i use this code on apaceh config
<VirtualHost 127.0.0.1:80>
ServerName mvcproject.local
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/mvcproject/public"
</VirtualHost>
<Directory "/Applications/XAMPP/xamppfiles/htdocs/mvcproject/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
and change my host like this
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 Masouds-MacBook-Pro.local # added by Apache Friends XAMPP
127.0.0.1 mvcproject.local
but i have this error
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
mvcproject.local
Apache/2.4.33 (Unix) OpenSSL/1.0.2o PHP/7.2.5 mod_perl/2.0.8-dev Perl/v5.16.3
How can i solve this problem?!
thanks.!
These are some point to help in create virtual host on mac
/Applications/XAMPP/xamppfiles/etc/httpd.conf in this file uncomment the
include line
Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
Add your site into vhosts file
/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
My custom host
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "/Users/yourusername/path/to/your/site"
<Directory "/Users/yourusername/path/to/your/site">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/mysite.local-error_log"
</VirtualHost>
Edit your host file
sudo nano /etc/hosts
#Add the following line
127.0.0.1 mysite.local
Restart your XAMPP
Related
Setting up a new dev server to work on PHP7 and get some training in and run across an impasse.
I can access the server from localhost, 127.0.0.1 no problem. However when I go to another computer on the LAN. I get the dreaded:
Forbidden
You don't have permission to access /dev/lab.php on this server.
So just to be on the safe side I used the new interface to see how the new setup would create a vhost. The vhost works fine locally but not from another PC on the LAN. The apache_error.log shows:
[authz_core:error] [pid 3408:tid 928] [client 192.168.1.38:54761] AH01630: client denied by server configuration: C:/wamp64/www/dev/lab.php
From everything I was reading it should have been a simple change of this
<VirtualHost *:80>
ServerName dev
DocumentRoot c:/wamp64/www/dev
<Directory "c:/wamp64/www/dev/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Which you can see I changed the Require local to Require all granted.
No JOY!
Still getting Forbidden access on the other LAN PC.
Once I changed the localhost to all granted. The sub-directories started working. Then I could get to http://192.168.1.36/dev with no problem.
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Thanks for the tips. i was stuck with WampServer Version 3.0.6 64bit access (Apache Version 2.4.23) and this code worked.
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
in case if you have changed port no of apache server you have to give same port no in below configuration. for example if your apache port no is 8080 then it you need to replace existing code in httpd-conf file
<VirtualHost *:8080>
ServerName dev
DocumentRoot c:/wamp64/www/dev
<Directory "c:/wamp64/www/dev/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
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
When I try to install simpleSAMLPH I have this message:
Forbidden
You don't have permission to access /simplesaml/module.php/core/frontpage_welcome.php on this server.
Apache/2.4.9 (Win64) PHP/5.5.12 Server at simplesaml.dev Port 80
And I don't understand why their is my file httpd-vhosts.conf :
NameVirtualHost simplesaml.dev
<VirtualHost simplesaml.dev>
ServerName simplesaml.dev
DocumentRoot C:/wamp/www/var/simplesamlphp/www
Alias /simplesaml /var/simplesamlphp/www
</VirtualHost>
I also do all the change in the file config.php of the library simpleSAMLphp.
Try to add the following configuration to your VirtualHost configuration:
<VirtualHost simplesaml.dev>
ServerName simplesaml.dev
DocumentRoot C:/wamp/www/var/simplesamlphp/www
Alias /simplesaml /var/simplesamlphp/www
<Directory />
Require all granted
</Directory>
</VirtualHost>
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.
I created a virtual host in xampp. I cannot use port 80 so I'm using port 8080. I then call servername:8080 to get the index.php. It works fine but I cannot do an ajax call, then an error occurs. What is wrong?
vhost
<VirtualHost 127.0.0.1:8080>
DocumentRoot "somepath"
ServerName servername
<directory "somepath">
usual stuff here
</directory>
</VirtualHost>
Call index.php
http://servername:8080
Error ajax
GET http://servername:8080/contact.html 404 (Not Found)
jquery-2.1.0.min.js:4l.cors.a.crossDomain.send jquery-2.1.0.min.js:4o.extend.ajax
jquery- 2.1.0.min.js:4o.(anonymous function) jquery-2.1.0.min.js:4start_loading
main.js:516click_internal_link main.js:547(anonymous function)
main.js:670o.event.dispatch jquery-2.1.0.min.js:3r.handle
Try this: (open by xampp panel the Apache config and in the end add the following:)
Setting Up Your VHOST
=====================
The following is a sample VHOST you might want to consider for your project.
NameVirtualHost 127.0.0.1:80
VHOST for Windows
=====================
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/..."
ServerName localhost
# This should be omitted in the production environment
#SetEnv APPLICATION_ENV development
#SetEnv APPLICATION_ENV production
<Directory "C:/xamp/htdocs/...">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
AND this: in your windows hosts
C:\WINDOWS\system32\drivers\etc
Edit hosts:
127.0.0.1 localhost
Good luck ;)