Laravel Virtual host doesnt work - apache

Iam trying to make virtual host for laravel 5.2 in apache server, but everytime i tried to access the virtual host it always shows "This site cant be reached", but i can access it through localhost:folder/public
I already setting the httpd-vhost
<VirtualHost *:80>
DocumentRoot "C:/xampp2/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp2/htdocs/belajarlaravel/public"
ServerName belajarlaravel.dev
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp2/htdocs/merchandise3-project/public"
ServerName merchandise.dev
</VirtualHost>
and my host
127.0.0.1 localhost
127.0.0.1 belajarlaravel.dev
127.0.0.1 merchandise.dev
I can access the localhost but for other host they still showing server not found and site cannot be reached. Can u give me some advice ? Thank You for your attention.

maybe the .dev ending is considered unsafe by Chrome, try .com

Related

Apache 2.2 Cent Os Subdomain Virtual Host not working

I am trying to add domain and subdomain in apache virtual host. I already created the subdomain and pointed to my type A record. I dont see any issues over there.
Below is my httpd.conf entry: now only my root domain i am able to access, subdomain I could not access, I have gone through many links, but nothing worked for me.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot "/var/www/html"
</VirtualHost>
<VirtualHost *:80>
ServerName admin.mydomain.com
DocumentRoot "/var/www/admin"
</VirtualHost>
Can someone help me on this please ?

Virtual Host not pointing properly

I have installed Laravel at C:/Apache24/htdocs/lsapp.
It's working fine with localhost/lsapp/public URL.
What I want to do is instead of above URL I want to access it by mak.org on my local machine.
For that I did following changes
Edited C:/Apache24/conf/extra/httpd-vhosts.conf with below lines:
<VirtualHost *:80>
DocumentRoot "C:/Apache24/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/Apache24/htdocs/lsapp/public"
ServerName mak.org
</VirtualHost>
Edited C:/Windows/System32/drivers/etc/hosts with below lines:
127.0.0.1 localhost
127.0.0.1 mak.org
I restarted my apache server.
But when I hit mak.org in browser, instead of accessing "C:/Apache24/htdocs/lsapp/public" it is pointing to "C:/Apache24/htdocs".
I restarted my PC, enabled opcache.enable=0 in php.ini still not getting desired outcome.
Can anybody help me on this?
What or where am I missing?
The issue resolved by enabling below in httpd.conf file of Apache:
Include conf/extra/httpd-vhosts.conf

Apache VHost Intranet Setup

Hi I would like to ask some help on setting up my webserver to access over my network.
Basically I have more projects on the www folder. For example I have 2 website that I want to access on different machine.
Heres my vhost config.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName website1
ServerAlias website1
DocumentRoot "/www/website1"
</VirtualHost>
<VirtualHost my_ip_add:8080>
ServerName website2
ServerAlias website2
DocumentRoot "/www/website2"
</VirtualHost>
And I also configure the /etc/hosts file.
127.0.0.1 localhost
127.0.0.1 website1
my_ip_add website2
What I want to is to access website2 from other machine.
What happen is when I put http://my_ip_add:8080/ on my browser it was "ERR_CONNECTION_REFUSED", but when I use http://my_ip_add/ it render website1.
How can I access the website2 on other machine? Is there is missing on my configuration?
I hope someone can help me on this. Thanks in advance.
Why so complex? Why don't you deliver both sites on the same port? That is what virtual hosts are for. You only have to take care to always request the two sites by their host name as resolved in your local name resolution...
Simplify your virtual hosts definition:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName website1
DocumentRoot "/www/website1"
</VirtualHost>
<VirtualHost *:80>
ServerName website2
DocumentRoot "/www/website2"
</VirtualHost>
Your local name resolution should resolve both host names:
127.0.0.1 localhost
my_ip_add website1
my_ip_add website2
now you can make these requests from all systems with above name resolution:
http://website1
http://website2

Only apply virtual host when the server name is used as host

So I have a project in folder htdocs/project. I need to access this project via domain project.xx to test subdomain mod_rewrite. To do this, I modified my hosts file to map the project.xx to 127.0.0.1.
Then, I have created a virtual host in apache using this code:
<VirtualHost *:80>
ServerName project.xx
ServerAlias www.project.xx
DocumentRoot C:/xampp/htdocs/project/
</VirtualHost>
It works as expected and when navigating to http://project.xx I end up on site running in C:/xampp/htdocs/project/.
I was just editing something else and I have discovered that something is wrong - navigating to 127.0.0.1 will also take me to my project site.
How do I prevent the virtual host setting from affecting whole localhost? I only want to go to my project when browser sends project.xx as the Host header.
As I learned on #httpd IRC chanell, it's required that you also set virtual host for the localhost itself, once you started using localhost.
This means that before matching the domain project.xx, a rule for 127.0.0.1 and localhost muse exist - so that if the domain isn't specified, default behavior will be used:
#Rule for localhost as it normaly behaves
<VirtualHost *:80>
#IP and `localhost` domain name
ServerName 127.0.0.1
ServerAlias localhost
#The normal document root
DocumentRoot C:/xampp/htdocs/
</VirtualHost>
#Rule for your project
<VirtualHost *:80>
ServerName project.xx
ServerAlias www.project.xx
DocumentRoot C:/xampp/htdocs/project/
</VirtualHost>

Configuring two server simultaneously at apache local

I wanna configure two server simutaneoulsy at my apache. one is with name localhost n another is with name shadaab.
What I did was edited C:\xampp\apache\conf\httpd.conf and added these lines at last of files
NameVirtualHost localhost
<VirtualHost localhost>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
NameVirtualHost shadaab
<VirtualHost shadaab>
DocumentRoot "F:/projects/all/"
ServerName shadaab
</VirtualHost>
Restarted apache server. When I browse in url localhost its working fine but when I did for 'shadaab' it doesn't work.
Later on how mysql will be connected with shadaab server pelase help. What other changes do I need to do.
Your config is WAY off. I suggest reading some documentation.
Your config should look something like:
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1:80>
DocumentRoot "F:/projects/all/"
ServerName shadaab
</VirtualHost>
Or replace 127.0.0.1 with * to make apache listen on all IP addresses, not just the loopback.
add
127.0.0.1 shadaab
in your host file
You will be able to connect to your mysql server via shadaab.
shadaab will point to 127.0.0.1