I'm using local server where XAMPP is running on. This local server is in the same network as my own computer. Now I want to access different site's running on that server. I had the following in mind.
My local server IP is 10.0.0.2. In my own hosts file I added the following.
10.0.0.2 www.domain.nl
Now when I enter www.domain.nl in my browser, I will be redirected to the server's localhost.
At the server, I added a VirtualHost to the httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/domain
ServerName localhost
</VirtualHost>
So now I will be redirected to the website running in the folder domain.
The problem
The problem now is, I also have a other website running on the local server. This one is on
the local server located in c:/xampp/htdocs/anotherdomain.
Adding another virtualhost does now only work on the local server itself, but not remote, because from remote I will always have the ServerName localhost.
How will I set this up? Hope you all understand my problem and someone knows how to get this working.
Related
I'm currently working with MAMP and trying to set up a subdomain.
The root of my MAMP site is /Users/conor/Dev and this can be accessed at localhost on the actual machine and on my local network it can be accessed at http://conors-mac-mini.local and this works without any issues.
I have a folder within the folder above MyDojo which I would like to set up as a sub domain.
I have edited /Applications/MAMP/conf/appache/httpd.conf to contain the following
NameVirtualHost *:80
<VirtualHost *:80>
ServerName: localhost
DocumentRoot: /Users/conor/Dev
</VirtualHost>
<VirtualHost *:80>
ServerName: mydojo.localhost
DocumentRoot: /Users/conor/Dev/MyDojo
</VirtualHost>
I have also edited /private/etc/hosts and added the following line
127.0.0.1 mydojo.localhost
After the above changes, when I visit localhost on the local machine it displays the correct content and mydojo.localhost also displays the correct content.
However when I try from another machine on my network http://conors-mac-mini.local works fine but http://mydojo.conors-mac-mini.local gives an error saying it can't reach the page and DNS_PROBE_FINISHED_NXDOMAIN.
I think I may be missing something to be able to access the subdomain using http://mydojo.conors-mac-mini.local on my local network but I can't work out what.
I want to access my virtual hosts (websites) that I've set up in my VirtualBox -> Ubuntu-Server 18. I have apache2 installed and everything is setup.
The host machine (macOS) can presently gain access to the default website of apache2 in the guest (Ubuntu-server) through a Port Forwarding rule I have assigned in the VirtualBox Network Settings:
127.0.0.1:8000 -> 10.0.2.15:80
I've set up a virtual host in my guest machine with the following configuration:
<VirtualHost *:80>
ServerName dropn.taxi
ServerAdmin admin#dropn.taxi
DocumentRoot /var/www/dropn.taxi/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The DocumentRoot directory mentioned above exists and has the files necessary to serve a basic "Hello World" home page. I've tested it with my apache installed in my local machine as well. The website's not the problem.
But everytime I access localhost:8000 from the local machine, I'm greeted with an Ubnutu-Apache greetings page. Whereas when I try localhost:8000/dropn.taxi, I get a 404 page. I've researched quite a bit and the closest I can get to a solution is what is suggested in this page:
Ubuntu Apache2 local virtual hosts url not found
Simply put: How can I access virtual hosts of the guest machine (VM) from the host machine?
Still not specific to my case. Would appreciate any help in this regards.
localhost in the apache2 server is set to point to /var/www/html by default. For the virtual hosts to work properly, the domain name accessing them must be what is defined in the ServerName field.
localhost:8000/dropn.taxi would translate to 127.0.0.1/dropn.taxi in the VM guest. Which means, it is trying to access the /var/www/html/dropn.taxi, which, ultimately does not exist, hence the 404 error.
The solution to this is to add dropn.taxi to the /etc/hosts file in both the Host Machine and the VM. The line would look like:
127.0.0.1 localhost dropn.taxi
While accessing from the Host Machine, we use dropn.taxi:8000 in the browser whereas the port :8000 is not used in the guest machine. This way, whenever accessing the virtual hosts, the domain name accessing them matches the ServerName field and it simply works!
I ve got a laravel app all set up and working when my virtual host is set as follows :
ServerName mylaravelproj.com
<Directory /var/www/mylaravelproj/public>
..rules here
So all i need to do is access mylaravelproj.com/api/whateverRouteHere
However, i wouldnt know how to access the api without a domain name as
DocumentRoot /var/www/mylaravelproj/public
<Directory /var/www/mylaravelproj/public>
..rules here
doesnt work when accessing 192.168.xxx.xxx/mylaravelproj/public/api/whateverRouteHere
Im quite new to configuring apache and a little confused as to why this doesnt work.
If your server is listening for the domain mylaravelproj.com, then why don't you add an entry to your hosts file like this:
192.168.xxx.xxx mylaravelproj.com
And then flush your DNS cache and then visit http://mylaravelproj.com and you should be able to access your app.
On windows, this is how I usually setup laravel apps. I use XAMPP, so I add the following entry to: C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerName mylaravelproj.com
DocumentRoot "C:/xampp/htdocs/mylaravelproj/public"
</VirtualHost>
and then get my LAN ip in windows using ipconfig /all in Command Prompt (say my LAN ip is 192.168.1.122) and then set it on the hosts file: C:\Windows\System32\drivers\etc\hosts
192.168.1.122 mylaravelproj.com
then in Command Prompt, flush the DNS Cache using ipconfig /flushdns
Note* it's not good idea to run your dev env using full domain, you should use something like mylaravelproj.dev or mylaravelproj.local
I have a cakephp web app which I've uploaded and linked to an apache server on an ubuntu Amazon EC2 instance under domain name ec2xxxx.compute.aws.com. The cake app is lying in the root of apache in /var/www/Cakefolder/ and opens directly on opening above link. I have bought a domain www.mywebsite.com I now wish to link the production alpha version of cake app with my domain under a subdomain link like alpha.mywebsite.com and have just a banner on www.mywebsite.com. I wrote the following code in a file I created called mywebsite.com.conf in etc/apache2/sites-available/ :
<VirtualHost alpha.mywebsite.com>
ServerAdmin webmaster#localhost
ServerAlias www.alpha1.mywebsite.com
DocumentRoot /var/www/cakeFolder
#if using awstats
ScriptAlias /awstats/ /usr/lib/cgi-bin/
CustomLog /var/log/apache2/mywebsite.com-access.log combined
</VirtualHost>
and then I added the following to etc/hosts file :
127.0.0.1 localhost.localdomain localhost alpha1.mywebsite.com www.alpha1.mywebsite.com
Right after doing this, my ec2 instance started displaying page unavailable and I cannot connect to the instance using putty or filezilla using ec2.aws.com dns or even elastic IP address. I have not yet linked it to the domain registrar, could that be the problem?
Please help!
This has nothing to do with your virtual host configuration. When you have attached an EIP, the instance would drop the Public DNS name. So that is out of picture.
Now, could you check and ensure that the EIP is still attached to the instance. OR to reconfirm, could you detach the EIP and re-attach it. Also, there is an option called "Get System Log" as shown below. Click on that and see whether you find any suspicious messages:
The SSH connection is independent of your apache configuration and this could be just a coincidence.
I have added a virtual host container in my httpd.conf file.
<VirtualHost *:80>
DocumentRoot /var/www/dev_sites/site
ServerName site.aa.local
</VirtualHost>
In my /etc/hosts file on my server computer it is:
127.0.0.1 site.aa.local
If I go to site.aa.local on my machine I can see my site. However if I go to that same address on another computer on my network it doesn't find the page. However, if I do aa.local it finds that. Any idea why a computer on my network can't see it?
I'm on a centos machine.
site.aa.local points to your loopback interface in your machine. Just in case: it's a virtual interface that is only accessible from your machine by definition.
For that name to work in another computer, site.aa.local should point to your machine's LAN IP address (either via /etc/hosts or DNS) and the Apache server in your computer should be listening in all interfaces (it most likely is).
Try adding YOUR_LAN_IP site.aa.local to the /etc/hosts file in the other computer, or just visit YOUR_LAN_IP if that is the Apache default virtual host (that is, if it's the only one or the first defined).