I'm trying to setup laravel but its proving to be a right mere! I've cloned it from github and also used composer to clone laravel and I've got both of these techniques working which is good because its something I really wanted to learn. Simpler than I thought.
However when I try to navigate to my laravel directory which is called iProject so I type into my browser localhost/iProject I get a list of directories which is not what I expected, I expected to be directed to at least the hello.php page.
I've tired another technique as described in a Net-tuts tutorial which is setting up a listening port and there I am then going through localhost:8888, but when using this technique the following error message appears:
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'public/' include_path='.;C:\xampp\php\PEAR') in Unknown on line 0
Setting up Virtual Host (as per responses received)
When I setup the virtual host I am redirected to xampp the url goes to iproject.dev/xampp
I've setup a virtual host as so:
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 iproject.dev
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/iProject/public"
ServerName iproject.dev
ServerAlias iproject.dev
ErrorLog "logs/iProject.liog"
CustomLog "logs/custom.iProject.log" combined
<Directory "C:/xampp/htdocs/iProject/public">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
You can simply use (I've same setup for all of my projects) in httpd-vhosts.conf file
<VirtualHost iproject.dev>
DocumentRoot "C:/xampp/htdocs/iProject/public"
ServerName iproject.dev
</VirtualHost>
Also, add the following line in you C:\Windows\System32\drivers\etc\hosts file
127.0.0.2 iproject.dev # 127.0.0.2 could be 127.0.0.3 or ...4/...5
For example, this is a part of my hosts file in win-7
127.0.0.1 localhost
127.0.0.1 127.0.0.1
127.0.0.2 alimsearch.dev # alimsearch.co.uk
127.0.0.3 laravel4.dev
# ...
And part of my httpd-vhosts.conf file
<VirtualHost alimsearch.dev>
DocumentRoot "D:/xampp/htdocs/alimsearch/public"
ServerName alimsearch.dev
</VirtualHost>
<VirtualHost laravel4.dev>
DocumentRoot "D:/xampp/htdocs/laravel4/public"
ServerName laravel4.dev
</VirtualHost>
Related
I am following a laravel tutorial, where tutor sets up a virtual host to run their app. The app is located in /opt/lampp/htdocs/first-app. My port for running apache is 8000. So if I visit localhost:8000/first-app/public, I can view my laravel app.
My httpd-vhosts.conf file looks like this:
<VirtualHost *:8000>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
ServerAlias www.localhost
</VirtualHost>
<VirtualHost *:8000>
DocumentRoot "/opt/lampp/htdocs/first-app/public"
ServerName app.test
ServerAlias www.app.test
<Directory "/opt/lampp/htdocs/first-app">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
My /etc/hosts file looks like this:
127.0.0.1 localhost app.test
::1 localhost app.test
127.0.1.1 pop-os.localdomain pop-os
127.0.0.1 app.test
I have uncommented httpd.conf like so
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
But I am getting this when I visit app.test
Browser output when app.test is visited
What am I doing wrong?
Edit: I have discovered, if I visit www.app.test:8000, it works fine
Just found out that the browser automatically adds port 80. So since I am running apache on port 8000, I need to specify it.
Thus, the settings above actually worked. All I had to do was go to http://localhost:8000 or http://127.0.0.1:8000
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 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
Im trying to set up a virtual host using my local xampp stack but after following many tutorials i simply can't work out where im going wrong.
Here is what i added to my httpd-vhost.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot E:\Programs\xampp\htdocs
</VirtualHost>
<VirtualHost *:80>
DocumentRoot E:\Programs\xampp\htdocs\CVCMS
ServerName cvcms.dev
<Directory "E:\Programs\xampp\htdocs\CVCMS">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And here is my hosts file
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 lmlicenses.wip4.adobe.com
127.0.0.1 lm.licenses.adobe.com
127.0.0.1 cvcms.dev
I have restarted apache after every change, i have made sure http.conf is linked to the httpd-vhosts file.
The issue is when i type in the domain cvcms.dev it shows the xampp splash page instead of the index.php in my cvcms folder.
Any ideas why?
Thanks
please remember to add the quotes to your virtual host document root path. At the same time what you need to to do enable them is to find httpd.conf , in this version it should be in your etc folder within your XAMPP's root folder.
Look out for :
# Virtual hosts
#Include etc/extra/httpd-vhosts.conf
Since '#' is a comment prefix, you have to uncomment "#Include etc/extra/httpd-vhosts.conf"
See if this works. Remember to restart your XAMPP's apache server to read the new settings you've just set. Cheers !
You can read more on this here.
How can I set up virtualhost for multiple domain name on Windows?
I will use it for my own test projects. I have three projects that I need to set up and at the moment I'm using xampplite for the portable Apache.
www.foo-bar.com --> direct to c:\xampplite\htdocs\foo-bar\
www.abcdef.com --> directo to c:\xampplite\htdocs\abcdef\
www.qwerty.com --> direct to c:\xampplite\htdocs\qwerty\web\
I also need to access on another project, but it just like typing
http://localhost/my-project/
How can I write the vhost configuration for that?
You need to do several steps in order to make this work.
Update the hosts file. On Windows XP, you can find it under c:\WINDOWS\system32\drivers\etc\. You should already see the first line from below. It takes care of your mentioned other project. Add the additional ones to make any requests to the mentioned virtual hosts routed back to your own machine.
127.0.0.1 localhost
127.0.0.1 foo-bar.com
127.0.0.1 abcdef.com
127.0.0.1 qwerty.com
Update the vhosts file in Apache configuration. Under your XAMPP folder, add the following to apache\conf\extra\httpd-vhosts.conf and if needed change the ports (i.e., if you use 8080 instead of port 80).
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/foo-bar/
ServerName www.foo-bar.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/abcdef/
ServerName www.abcdef.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/qwerty/web/
ServerName www.qwerty.com
</VirtualHost>
Do a quick configuration check. Open {XAMPP-folder}\apache\conf\httpd.conf your file and make sure that the following part is not commented out by a preceding # character:
Include conf/extra/httpd-vhosts.conf
Restart XAMPP.
... and you should be all setup now. Your other project should be accessible at the URI you mentioned if you just put it under C:/xampplite/htdocs/my-project/.
To get C:/xampp/htdocs/my-project/ working, I had to add the following (default?) VirtualHost to apache\conf\extra\httpd-vhosts.conf (in step 2 of MicE's tutorial).
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
127.0.0.5 abcd.com
< VirtualHost 127.0.0.5 >
ServerName abcd.com
DocumentRoot "C:\xampp\htdocs\laravel\public"
<Directory "C:\xampp\htdocs\laravel\public">
DirectoryIndex index.php
AllowOverride All
Order allow, deny
Allow from all
</Directory>
< / VirtualHost >