I am using XAMPP in Windows.I want to set vhost for my symfony project so I have set the vhost in apache through (httpd-vhosts.conf) file as :
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:80
# This is the configuration for drberg.com
Listen 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
ServerName drberg.com.local
DocumentRoot "D:/xampp/htdocs/DrBerg.com/web"
DirectoryIndex index.php
<Directory "D:/xampp/htdocs/DrBerg.com/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf "D:/xampp/htdocs/DrBerg.com/web/sf"
<Directory "D:/xampp/htdocs/DrBerg.com/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
So I can't access it it's not opening anything also when I access my symfony project through manual link so it redirects me to my localhost as :
http://localhost/DrBerg.com/web/
So it redirects me to :
http://localhost/xampp/
Set in your hosts (in WINDOWS/system32/drivers/etc/) your ServerName:
127.0.0.1 drberg.com.local
(it works immediately after save this file)
and point to:
http://drberg.com.local
(use http:// because sometimes chrome send the address to google.com instead go there)
and don't use localhost in the ServerName because XAMPP filter this word (local can be).
Related
I'm using XAMPP v3.2.4 and I don't know if this makes any difference but Joomla 3.9.14
In my local environment I access my Joomla site by visiting localhost/mysite. I now want to have a sub domain localhost/apps.mysite.
I've created a folder called apps and placed this in my Joomla root directory, which is C:\xampp\htdocs\mysite\apps. This folder contains a single index.html file.
I've made the following changes;
In my Windows hosts file I added the following line;
127.0.0.1 localhost/apps.mysite
In my httpd-vhosts.conf file I added;
NameVirtualHost 127.0.0.1:80
<virtualhost *:80="">
DocumentRoot "C:/xampp/htdocs/mysite/apps"
ServerName localhost/apps.mysite
ServerAlias www.apps.mysite.localhost.com
</virtualhost>
I haven't made any other changes to config files. I've restarted Apache a few times, no change.
When I visit the URL http://localhost/apps.mysite I see the following error;
Object not found! The requested URL was not found on this server. If
you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404 localhost Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.3.9
What do I need to change in order to access my subdomain at http://localhost/apps.mysite
First host file does not handle folders, just map IP addresses to hostname.
Host file should be
127.0.0.1 localhost apps.mysite
or
127.0.0.1 localhost
127.0.0.1 apps.mysite
I prefer the second method because I can comment the line..
Second Your virtual host ServerName localhost/apps.mysite does not work with sub folders.
Valid Servername values can be: domain.com, example.com, site1.example.com, user.site1.example.com and son on.
A virtual host example to map the apps.mysite should be:
<VirtualHost *:80>
ServerName apps.mysite
ServerAlias www.apps.mysite
## Vhost Document Root
DocumentRoot "C:/xampp/htdocs/mysite/apps"
</VirtualHost>
This is a minimal example, no logs defined or directory specific rules. With this configuration you will be able to reach your site by using http://apps.mysite only on your computer because the host file is resolving the "apps.mysite" to your localhost (127.0.0.1).
What do I need to change in order to access my subdomain at http://localhost/apps.mysite
http://localhost/apps.mysite is not a sub-domain is a domain localhost with a folder apps.mysite, a valid subdomain is subDomain.domain.com.
.com is a top level domain
domain.com is a domain name
subDomain.domain.com is a subdomain of domain.com
Hope it helps.
Start by creating a VirtualHost for localhost in case you want to use that for a bit of fiddling
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs"/>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
## then add main site
<VirtualHost *:80>
ServerName mysite.local
ServerAlias www.mysite.local
DocumentRoot "C:/xampp/htdocs/mysite/"
<Directory "C:/xampp/htdocs/mysite/"/>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
## then add the sub domain
<VirtualHost *:80>
ServerName aps.mysite.local
ServerAlias www.aps.mysite.local
DocumentRoot "C:/xampp/htdocs/mysiteapps/"
<Directory "C:/xampp/htdocs/mysiteapps/"/>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
You will need to add these 2 sites to your C:\windows\system32\drivers\etc\hosts file like this
127.0.0.1 mysite.local aps.mysite.local
::1 mysite.local aps.mysite.local
For the change to the HOSTS file you will either need to reboot or refresh the DNS Cache like this from a command window
>ipconfig /flushdns
I installed genymotion emulator on my PC and I want to access my WAMP local server to it and I ran ipconfig on my cmd so I got this IP_address 192.168.56.1 but the problem is that I always get this error
403 Forbidden
You don't have permission to access / on this server
I tried all the answers given in this question yet none solved my problem.
I am running
Mysql 5.5.8,
PHP 5.3.5 and
Apache 2.2.17
Please do anyone know how I can fix this error?
#KANAYOAUSTINKANE. This is my code or the Subdomain
<Virtualhost *:80>
DocumentRoot "C:/wamp/www/mobile"
ServerName localhost
ServerAlias m.local host
</Virtualhost>
Please help me out, I have been so disturbed
Okay, here is a solution.
First step
Change the location of your virtual host and add a / at the end like this
DocumentRoot "C:/wamp/www/mobile/"
Second step
Go to your httpd.conf file located at C:/camp/bin/apache/Apache2.2.17/conf/httpd.conf the go to the line that has Listen 80 and change it to Listen *:80 this will make it to listen to any IP address
Finally
You go to the end of your httpd.conf file and add this
# Tells Apache to identify which site by name
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wamp/www"
</VirtualHost>
# Tells Apache to serve your mobile pages to "m.localhost"
<VirtualHost 127.0.0.1>
# The name to respond to ServerName m.localhost
# Folder where the file is located which in your case is
DocumentRoot "C:/wamp/www/mobile/"
<Directory "C:/wamp/www/mobile/">
Allow from all
Order Allow,Deny
AllowOverride All
</Directory>
# Apache will look for these files, in this order, if no file is specified in the URL, but you can add more files apart from the two I listed depending on what you are having
DirectoryIndex index.html index.php
</VirtualHost>
#Here you duplicate the code for your mobile site to also accept your IP address which is 192.168.56.1
<VirtualHost 192.168.56.1>
# The name to respond to ServerName m.localhost
# Folder where the file is located which in your case is
DocumentRoot "C:/wamp/www/mobile/"
<Directory "C:/wamp/www/mobile/">
Allow from all
Order Allow,Deny
AllowOverride All
</Directory>
# Apache will look for these files, in this order, if no file is specified in the URL, but you can add more files apart from the two I listed depending on what you are having
DirectoryIndex index.html index.php
</VirtualHost>
Tested and working. Please don't forget to mark the answer
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 ;)
I need to set my url for my site to appear as mydomain.com/ and have apache recognize that as the webroot.
Currently my url looks like:
###.###.##.##/laravel/public
and I want it to become:
mydomain.com/
This is the first site I've worked on from scratch, so I'm not completely sure what information I should include here.
Current apache httpd.conf:
NameVirtualHost *:80
NOTE: NameVirtualHost cannot be used without a port specifier
(e.g. :80) if mod_ssl is being used, due to the nature of the
SSL protocol.
VirtualHost example:
Almost any Apache directive may go into a VirtualHost container.
The first VirtualHost section is used for requests without a known
server name.
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot /var/www/html/foo_bar/public
ServerName foo.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
<Directory /var/www/html/foo/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
First you'll need to edit your httpd.conf (usually located somewhere like /etc/apache2/conf).
Look for a line like <Directory "/var/www">. This is telling apache the root directory from which you want to work. /var/www in your case will be whatever directory laravel/public is living in on your websever currently.
If you change that line to <Directory "/var/www/laravel/public"> (assuming /var/www is where your laravel app is), save the file and restart apache, then you should be serving mydomain.com from inside laravel/public.
Im trying to redirect to a web page on my localhost, I have done all the nessesary configurations from my hosts files and v-hosts it picks up my address from my C:\Windows\System32\drivers\etc hosts file which is name.local but does not show the main page. Keeping in mind the site has both front and backend access. I'm new and wanna work on my application locally before i can start editing it on the server.
You posted this additional comment containing your vhost definition and hosts file contents
v-host file
<VirtualHost 127.0.0.1:80>
DocumentRoot "c:/xampp/htdocs/intranet"
ServerName gep.local
ServerAlias gep.local
CustomLog "c:gep.local-access_log" combined
ErrorLog "c:gep.local-error_log"
<Directory "c:/xampp/htdocs/intranet">
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
host file:
127.0.0.1 gep.local
Here are a few suggestions:-
Have you rebooted or restarted the DNS Client to activate your HOSTS file changes.
from a command window run started using 'Run as Administrator' do this
net stop "DNS Client"
then once it reports as STOPPED
net start "DNS Client"
This will refresh the windows DNS Cache. ( Double quotes are required as there is a space in the service name )
First change <VirtualHost 127.0.0.1:80> to <VirtualHost *:80>
If you are using Apache 2.2.x you also need a NameVirtualHost *:80 parameter as the first parameter in the vhost definition file. If you are using Apache 2.4.x I believe they removed this requirement so it is not necessary on that version of Apache.
So
new v-host file
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/intranet"
ServerName gep.local
ServerAlias gep.local
CustomLog "c:/gep.local-access_log" combined
ErrorLog "c:/gep.local-error_log"
<Directory "c:/xampp/htdocs/intranet">
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Then of course to test it use the address `http://gep.local' in your browser address bar to get to this new virtual host.