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
Related
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 ?
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
Is it possible to configure my URL which has my IP address on it- like: "http://192.168.xx.yy/index.php". The situation is when I run Apache server in my PC, and load localhost in it. I know it is possible after hosting with external server, but is there any way we can configure within our localhost?
How to configure the Apache files to make this happen? I tried in my localhost, editing the "httpd.conf" by adding this inside like this - please tell me where I am getting the issue!
ServerName localhost:80
HostnameLookups Off
<VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.example.com
ServerAlias example.com
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName other.example.com
DocumentRoot /www/otherdomain
</VirtualHost>
DocumentRoot "c:/wamp/www/"
Yes, you can play with multiple IP addresses on your machine. Configuration depends on your OS. Article Create Multiple IP Addresses to One Single Network Interface is for linux.
But, better way is to use VirtualHosts based on host names or (simplest) on ports. So you can get http://siteA.mycoputer.localhost, http://siteB.mycomputer.localhost in the first case and http://192.168.x.y:8000, http://192.168.x.y:9000 in the second case
Here is Apache Server config example from Apache Server 2.2 documentation
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example.org
# Other directives here
</VirtualHost>
I want to have several sites on my local machine, associated to specific port in my apache configuration. I don't even know if what I want is possible to do, or if I have the good way of thinking. May be I need other tools, so please, can you explain me ?
I have my dev machine with several site working on it, in my hosts file I put:
127.0.0.1 local.site1.com
127.0.0.1 local.site2.com
In appache configuration, I have these virtual hosts:
Listen 8081
Listen 8082
<VirtualHost *:8081>
ServerName local.site1.com
ServerAlias local.site1.com
DocumentRoot "C:/site1"
</VirtualHost>
<VirtualHost *:8082>
ServerName local.site2.com
ServerAlias local.site2.com
DocumentRoot "C:/site2"
</VirtualHost>
Do you know what should I do to have ?
http://local.site1.com that goes automatically and only to port 8081
http://local.site2.com that goes automatically and only to port 8082
Now, my configuration looks useless, because http://local.site1.com opens port 80, and http://local.site2.com:8081 goes to site1.
Why do you want them running on different ports? You don't need to do that to get what you want.
You can use NameVirtualHosts and run both sites on the same port, and the server will serve the correct site based on the domain name used in your browser.
http://httpd.apache.org/docs/2.2/vhosts/name-based.html
Example
NameVirtualHost *:80
<VirtualHost *:80>
ServerName local.site1.com
ServerAlias local.site1.com
DocumentRoot "C:/site1"
</VirtualHost>
<VirtualHost *:80>
ServerName local.site2.com
ServerAlias local.site2.com
DocumentRoot "C:/site2"
</VirtualHost>
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