I installed latest x64 wamp server : wampserver3.1.0_x64.exe On Windows 7.
I changed it's default 80 port to 8080, because of IIS & now every thing is ok.
I added a simple project to this path : C:\wamp64\www like below :
C:\wamp64\www\php_test\index.php
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Now when i go to this path http://localhost:8080/ > Your Projects Area >
php_test > It's link is like this > http://php_test:8080/ > That does not work & is invalid.
The true link is : http://localhost:8080/php_test
How can i fix this problem?
I found the link below for that :
Project Links do not work on Wamp Server
I followed the answer.
Now the new problem is after adding virtual hosts, phptest does not work again.
Here is httpd-vhosts.conf file :
# Virtual Hosts
#
<VirtualHost *:8080>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerName phptest
DocumentRoot "${INSTALL_DIR}/www/php_test"
<Directory "${INSTALL_DIR}/www/php_test/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
I did restart all services after adding phptest to virtual hosts.
My questions :
1. How can i fix that invalid link?
2. How make virtual hosts workable?
EDIT After Comments > Here is my HOSTS file content :
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
#
#
Your HOSTS file is basically empty as a # is a comment.
You have to add a reference to each VHOST into your HOSTS file like this so that the browser can find your development domains
Hosts file
127.0.0.1 localhost
::1 localhost
127.0.0.1 phptest
::1 phptest
Now you must restart the DNS Cache like this, from a command prompt that you have started "As an Administrator" or just reboot the PC
>net stop dnscache
When that has completed do
>net start dnscache
Or there is a menu item on WAMPServers menus
[Right Click] wampmanager-> Tools -> Restart DNS
Related
I need to add virtual host in Mac using MAMP Pro.
First step:(Edit hosts in /etc/hosts) like This
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
27.0.0.1 BSDs-iMac.local # added by Apache Friends XAMPP
127.0.0.1 symfony.local # MAMP PRO - Do NOT remove this entry!
::1 symfony.local # MAMP PRO - Do NOT remove this entry!
Next Step:(Open MAMP's vhosts file) and remove #
/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Next Step: (edit httpd conf)
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "/Applications/MAMP/Library/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/Applications/MAMP/Library/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Desktop/avinar/my-project/public"
ServerName symfony.local
</VirtualHost>
Last Step add virtual host into mamp pro like this:
Now when I check Url: symfony.local i see this error:
>
Forbidden
>
You don't have permission to access / on this server.
When I check this url: symfony.local/my-projet/public server work and i see page.
How do fix this problem?!
That virual host may be lacking a Directory directive:
<Directory "/Desktop/avinar/my-project/public">
Options -Indexes +MultiViews +FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
Require all granted
</Directory>
If it doesn't work, recursively set apache (or however the user may be called) as the owner (or owner group) of /Desktop/avinar/my-project.
I am having issues with my xampp and locahost and laravel projects. When I create a new laravel project: composer create-project --prefer-dist laravel/laravel fmvcei in my C:/xampp/htdocs folder, when I type in localhost/fmvcei/public, nothing appears. I pulled from another stack overflow question on this where it suggested removing the NameVirtualHost *:80. When I try to configure my host files to be able to type fmvcei.test in the browser, still nothing. I have restarted xampp each time. Here are my httpd/vhost and host files:
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
##ServerAdmin webmaster#dummy-host.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
##ServerName dummy-host.example.com
##ServerAlias www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>
##<VirtualHost *:80>
##ServerAdmin webmaster#dummy-host2.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host2.example.com"
##ServerName dummy-host2.example.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerAdmin admin#localhost
ServerName localhost
<Directory "C:/xampp/htdocs/">
Options Indexes FollowSymLinks
AllowOverride all
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/fmvcei/public"
ServerAdmin admin#localhost
ServerName fmvcei.test
ServerAlias www.fmvcei.test
<Directory "C:/xampp/htdocs/fmvcei/public">
AllowOverride All
Options Indexes FollowSymLinks
Require local
# if you want access from other pc's on your local network
#Require ip 192.168.1
# Only if you want the world to see your site
#Require all granted
</Directory>
</VirtualHost>
hosts file:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 tbhtoat.app
127.0.0.1 fmvcei.test
First things, make sure both Apache and MySQL are running.
Move to the root project directory, fmvcei in your case, then run this command php artisan serve. you can browse by 127.0.0.1:8000
NB. you need to install composer if you don't yet.
I have been trying to configure Laravel but it seems to have some kind of error: "IP address could not be found."
This is my configuration in my httpd-vhost.conf
Configuration on httpd-vhost
and this is what I put in my host
enter image description here
I tried restarting and checking my syntax through httpd.exe -t in apache but it seems okay
You can try this.
In your httpd-vhost.conf file write this, If you want virtual host of reviewer then try this,
<VirtualHost *:80>
ServerName reviewer.test
ServerAlias reviewer.test
DocumentRoot "C:/xampp/htdocs/reviewer/public"
DirectoryIndex index.php
<Directory "C:/xampp/htdocs/reviewer/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
And in your hosts file write this,
127.0.0.1 reviewer.test
Then restart your all xampp server services.
Problem in your files
You haven't removed the comment ( # this symbol represents that it is comment.)
This is your file configuration.
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# 127.0.0.1 reviewer.dev
You have to remove # this symbol, and replace dev with test . Get more knowledge from this link.
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
127.0.0.1 reviewer.test
I hope this stuff will help you.
I have been following this steps setup apache virtualhost (windows) to create a Virtual Host in Windows but I don't know what is wrong because it doesn't work.
I want a virtual host with this url: http://local.shop.
httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/Apache24/htdocs/"
ServerName localhost
ServerAlias localhost
<Directory "C:/Apache24/htdocs/">
AllowOverride All
</Directory>
<VirtualHost *:80>
DocumentRoot "C:/Apache24/htdocs/shop/"
ServerName local.shop
ServerAlias local.shop
<Directory "C:/Apache24/htdocs/shop/">
AllowOverride All
</Directory>
ErrorLog "logs/localhost.html-error.log"
CustomLog "logs/localhost.html-access.log" common
</VirtualHost>
hosts
127.0.0.1 localhost
127.0.0.1 local.shop
If I try to access to http://localhost the page served is the page which is on C:/Apache24/htdocs/shop/ but if I try to access to http://local.shop I've got the next error ERR_NAME_NOT_RESOLVED
What am I doing wrong?
Edit 1:
I have removed ServerAlias directives and now If I try to access to http://localhost the page served is the right page, but if I try to acces to http://local.shop still doesn't work. I've got the same error ERR_NAME_NOT_RESOLVED
Edit 2:
I have used "ping" command from windows to try to reach to each host. And I get a response from localhost but not from local.shop
Edit 3:
I have made a change in my definition of localhost in httpd-vhosts.conf. I have changed DocumentRoot to "C:/Apache24/htdocs/shop"
<VirtualHost *:80>
DocumentRoot "C:/Apache24/htdocs/shop"
ServerName localhost
ServerAlias localhost
<Directory "C:/Apache24/htdocs/">
AllowOverride All
</Directory>
</VirtualHost>
Instead of getting the default page from shop directory, I still getting the default page from original localhost. It seems like Apache ignore httpd-vhosts.conf file.
Apache maybe listening (in case you restarted it after editing vhosts file), but nothing points to it. You need to edit your hosts file (located under C:\Windows\System32\drivers\etc\hosts) and point domain "local.shop" to IP address 127.0.0.1 so Apache can pickup from there. You may edit that file with Notepad, opened with admin rights.
It should looks something like this:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 local.shop
I encountered this same issue installing Apache 2.4 on Nov. Tuesday 2nd, 2021 at 2:37 pm.
Things you need to do if you are installing Apache without WAMP or LAMP:
If you do not want to do much configurations, unzip your downloaded files on c:\Apache 2.4 as many tutorials asked you to do.
If you want to use httpd command variable you need to add c:\Apache 2.4\bin into your Environment Variables path.
THIS IS WHAT MOST PEOPLE FAILED TO ADDRESS :: If you are going to create Virtual Hosts you need to open c:\Apache 2.4\bin\conf\httpd.conf in your favorite text editor or IDE and look for the line or statement #Include conf/extra/httpd-vhosts.com and uncomment it, which means removing the # (pound) sign at the beginning. At the time of this writing is line 510. It should look as follow:
509 #Virtual hosts
510 Include conf/extra/httpd-vhosts.conf
You need to open you text editor as admin and edit c:\windows\system32\drivers\etc\hosts file and add all your virtual hosts as so, you get the idea:
127.0.0.1 vhOne.com #your virtual host server name
127.0.0.1 vhTwo.com #your second virutal host server name
After doing that close any terminal and open that again, and you should be able to go to your terminal, without having to cd to the Apache directory all the time, just by typing:
> httpd -k install
> httpd -v
> httpd -k restart
You should also be able to ping your virtual host from the terminal and expect the response desired:
ping vhOne.com
And you should be able to visit your virtual host URL. Keep in mind that at first most browsers won't recognized 127.0.0.1 URL to be web addresses but search string so you have to type http://vhOne.com with the http:// in the URL. After that first visit you can go back by typing the server name without the http://
I am new to Mac but used Ubuntu for development for a long time. I know how to create virtual hosts in Ubuntu but have no idea about Mac. I have created a hosts entry like below :
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost mysite.loc
255.255.255.255 broadcasthost
::1 localhost
But what to do next?
While googling, I found these steps to easily create virtual hosts on MAMP:
Open your console in mac and edit your hosts file like this
sudo vim /etc/hosts
This opens a system file that contains the following line:
127.0.0.1 localhost
add your desired host name after local host:
127.0.0.1 localhost mysite.loc
press ESC, then :wq! to overwrite and close the file.
Now go to your MAMP directory and open apache config file located at /Applications/MAMP/conf/apache/httpd.conf in any text editor and locate the following lines:
# Virtual Hosts
# Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Remove the hash (pound) sign from the beginning of the line that begins with Include
# Virtual Hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Save the file, and then open Applications/MAMP/conf/apache/extra/httpd-vhosts.conf. This is where you define the virtual hosts.
At the bottom of the page are two examples of how to define virtual hosts in Apache. They look like this:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "/Applications/MAMP/Library/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/Applications/MAMP/Library/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
Edit both examples. Virtual hosts override the existing localhost, so the first one needs to re-establish localhost. Edit the second one for the virtual host you want to add. Only the DocumentRoot and ServerName directives are required. To add a virtual host for mysite, the edited definitions should look like this:
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/username/Sites/mysite"
ServerName mysite.loc
</VirtualHost>
This assumes that you want to locate the files for mysite in your Sites folder. Replace "username" in the second definition with your own Mac username. If you want to store the files in a different location, adjust the value of DocumentRoot accordingly.
If you want to create more than one virtual host, copy one of the definitions, and edit it accordingly.
Save all the files you have edited, and restart the servers in the MAMP control panel. You should now be able to access the virtual host with the following URL: http://mysite.loc/.
Enjoy..!!
Allow virtual hosts
Go to Applications > MAMP > conf > apache > httpd.conf
Find this line:
# Virtual hosts
#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Uncomment the code by removing the hash symbol.
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Allow SymLink Override
Find this line in that same httpd.conf file.
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
change None to All.
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Add the virtual host path
Go to Applications > MAMP > conf > apache > extra > httpd-vhosts.conf
add the virtual host with servname and document root like the below code
<VirtualHost *:80>
ServerName example.dev
DocumentRoot "/path/to/directory"
</VirtualHost>
Allow your computer to recognize your local domain
Open terminal and type
sudo pico /etc/hosts
then add your domain
127.0.0.1 example.dev
Restart your server.
If the url is showing error in chrome try safari
In my config in MAMP, only the first virtual host was responding.
After hours of search I founded the instruction for solving the problem (before listing virtual hosts definitions) :
NameVirtualHost *:80
Now, my 3 virtual hosts are working !
I followed this post, as recommended by szatti1489, and it worked for me: https://www.taniarascia.com/setting-up-virtual-hosts/
A couple of points are worth mentioning though:
This line didn't already exist in my httpd.conf file, I had to add it: Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
I had to use the .test domain ending, not .dev for my VirtualHost ServerName. The post mentions this, but then continues using.dev. Apparently, Chrome didn't support the .dev domain ending after 2017, although it didn't work in Firefox or Safari for me either.
Recently I changed from XAMP to MAMP on MAC. I tried to set up my last virtual hosts, but MAMP's 8888 port number was avoid the regular work.
Finally I found the solution. You could change the Listen port and the ServerName in httpd.conf as you could find in the following post:
https://www.taniarascia.com/setting-up-virtual-hosts/
Adding to the answer of Ritesh
You probably also want to add a directory configuration in your httpd.conf similar to the one that is already there, but for your the document root of your new server.
For Example:
<Directory "/Users/username/Sites/mysite">
Options All
AllowOverride All
Order allow,deny
Allow from all
XSendFilePath "/Users/username/Sites/mysite"
</Directory>
Building off of Srinivasan's answer. This is what I did in order to have 2 virtual hosts set up
myapp-local.local:8888/
myapp-local2.local:8888/
/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:8888>
DocumentRoot /Applications/MAMP/htdocs/my_app
ServerName myapp-local.local
<Directory "/Applications/MAMP/htdocs/my_app">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:8888>
DocumentRoot /Applications/MAMP/htdocs/instance-2/my_app
ServerName myapp-local2.local
<Directory "/Applications/MAMP/htdocs/instance-2/my_app">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
sudo vi /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost myapp-local.local
127.0.0.1 localhost myapp-local2.local
255.255.255.255 broadcasthost
::1 localhost
Drupal specific:
sites/default/settings.php
$settings['trusted_host_patterns'] = [
'^localhost$',
'^myapp-local.local$'
'^myapp-local2.local$'
];
*/
restart MAMP server