Xampp vhost cannot load the virtualhost without port number - apache

I am not sure if this is a repost but I couldn't find a solution.
I have an application setup in my local environment which the name I added in my hosts file (C:\Windows\System32\drivers\etc) as follows,
127.0.0.1 skeletonpage.lk
Also I added a record in httpd-vhosts.conf as below.
<VirtualHost *>
DocumentRoot "C:/xampp/htdocs/skeleton/public"
ServerName skeletonpage.lk
<Directory "C:/xampp/htdocs/skeleton/public">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I run the application on browser I can only load the homepage with the port number tagged with the site name. Ex: http://skeletonpage.lk:83/
I have both XAMPP and WAMP in my machine and my site runs in XAMPP for which the port 83 is given, If I remove :83 it loads the homepage of wamp server which has port 80.
I tried removing and modifying above code snippet but still cant get rid of port 83. I know this is something simple, but would be glad if someone can help.
I modified as <VirtualHost *:83> also <VirtualHost 127.0.0.1:83> and restarted XAMPP also modified NameVirtualHost *:83 but no use.

Related

Managing multiple sites on XAMPP

I have multiple sites deployed on xampp. For now, all of the sites are using one port i.e. 80. For this reason, whenever I am logged into one of the sites, I am automatically logged out from the other and vice versa. I have looked at this article to How to run multiple websites on XAMPP on Windows. And tried to follow it but I am unable to do the needful.
I have added one more port to listen
Listen 80
Listen 8080
In my httpd-vhosts.conf I have done the following
NameVirtualHost *:8080
<VirtualHost *:8000>
DocumentRoot "F:\xampp\htdocs\mdc"
ServerName localhost:8080
<\VirtualHost>
After doing this I have turned off my xampp and then tried to restart apache and mysql. But apache is not starting
My URL is http://localhost:8080/mdc/backend/web
Note: Without doing any virtual host setting the above URL is accessible on both 80 and 8080 ports
Update 1
Herer is my httpd.conf file
This is not a fix for your issue, Here i will explain how i manage multiple websites on xampp.
First i assumes that your using windows
i always use the same port with different server names.
on : E:\xampp\apache\conf\extra\httpd-vhosts.conf (In my case i installed xampp on E drive)
i added this code
<VirtualHost *:80>
DocumentRoot "e:/xampp/htdocs/mysite1"
ServerName mysite1.flames.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "e:/xampp/htdocs/mysite2"
ServerName mysite2.flames-team.com
</VirtualHost>
And on ( C:\Windows\System32\drivers\etc\hosts) my windows host file i added this lines
127.0.0.1 mysite1.flames.com
127.0.0.1 mysite2.flames-team.com
With this approach you can access the site with a clean readable URLs
In this case if you want to see the first site just enter this URL mysite1.flames.com on browser.
Cheers
Write the closing tag </VirtualHost> instead of <\VirtualHost> in the file httpd-vhosts.conf. I did it and it worked for me.

Virtual Host different port in wamp or xampp

I am familiar with using virtual host with default port. Just now default port 80 was taken by another program. So, Would that be possible to create virtual host with custom port like 81 or 83 something like that.
Just now, I have to call phpmyadmin, using http://localhost:81/phpmyadmin but I can't create another project like http://test.local Below are the codes that I use in some files. Before I ask here, I google it, but no solution worked!
httpd-vhosts.conf file
NameVirtualHost *:81
<VirtualHost *:81>
DocumentRoot "D:\wamp\www\test"
ServerName test.local
<Directory "D:\wamp\www\test">
Allow from all
</Directory>
</VirtualHost>
hosts file
127.0.0.1:81 car.local
httpd.conf file
Listen 81
So, How do I need to do to get http://test.local like that url. I have installed wamp and xampp in my computer.

creating Subdomain in Xampp doesn't work

I made a subdomain on Localhost over Xampp with following code in httpd-vhosts.conf (guide from different sources)
NameVirtualHost *:80 (uncommented by removing #)
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/sub
ServerName sub.localhost.com
</VirtualHost>
and following code into hosts of Windows/System32/drivers/etc/
127.0.0.1 localhost
127.0.0.1 sub.localhost
now the problem is subdomains are not working. One more thing I just noticed that when I start apache service in Xampp Control Panel, it has set the port as 80,443 for Apache which is good but as soon as I hit localhost in browser it changes port to different ports like 52352 etc. I also tried to setting up code in hosts file as
127.0.0.1:80 localhost
127.0.0.1:80 sub.localhost
but not working. I tried many other things but all in vein. While a month before I created successfully in the same Xampp Installation. off course i have created sub directory in htdocs.
Make sure you have this line uncommented in httpd.conf
#Include conf/extra/httpd-vhosts.conf
Remove this line in httpd-vhosts.conf (or comment it out):
NameVirtualHost *:80
Make sure you have a blank line at the end of both httpd-vhosts.conf and hosts, and make sure you're using tabs to separate IPs with their associated domains in the hosts file.
Make sure another application is not using ports 80, 443 (Skype for example).
Ultimately, restart your Apache server.
If you want to create sub directory, *emphasized text*127.0.0.1:80 localhost*emphasized text*
the settings back to original and change only *emphasized text*DocumentRoot C:/xampp/htdocs/sub*emphasized text*

XAMPP apache server not using the ports I desire, not certain why

So, I've been setting up this HTTP server for a school project that has to be able to maintain multiple domains through virtual hosts. Using XAMPP I have my server set up, I thought I'd done it properly but perhaps not.
I had heaps of issues with not being able to listen to a port, to solve this I used (in httpd.conf under apache/conf/)
Listen 0.0.0.0:8080
ServerName localhost:8080
If I used 80/81/8080/321/any combination that did not have the prefix 0.0.0.0 it told me the port could not be listened or whatever (sorry, a little rusty with my syntax).
I set up my first virtual host up like so (under apache/conf/extra/httpd-vhosts.conf):
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "H:/xampp2/xampp/htdocs"
ServerName localhost:8080
<Directory "H:/xampp2/xampp/htdocs">
Option Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I thought this seemed all good and well and I don't believe I've modified anything else. To me, I would expect that this means my Apache server would use port 8080 for the server? However, when I start Apache in XAMPP it states quite clearly
Apache started [Port 80]
Why would this be port 80?
In conjunction, localhost:8080 doesn't navigate me to the documents, but localhost:80 or localhost do. I presume that this just means it's still on port 80. I've tried resetting my computer and XAMPP.
If you need any more information, please let me know. I tried following guides such as this one: http://ailoo.net/2008/07/set-up-multiple-virtual-hosts-on-xampp-for-windows/
Cheers.
Oh, I also edited my Windows HOSTS file; it looks like so:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 localhost:8080
Edit: New error... Now getting this when I init, doesn't seem to be affecting it though:
ERROR: Status Check Failure [3]
This program must be run from your XAMPP root directory.
It is being run from teh root directory as far as I can tell.
Ok Im not advanced in this area either. However after much playing around with XAMPP and following a few different guides I got mine working.
The Host under drivers seems abit weird. I declared mine as:
127.0.0.1:8080 test.localhost.com
127.0.0.1:8080 test2.localhost.com
Back up you Xampp, then extract a clean install to C: - Just because that Status check failure sounds like bad news.
!Remember to run setup_xampp.bat from the xampp directory and install the apache service!
Then under you httpd.conf add:
ServerRoot C:\xampp\apache
Listen 7070
Listen 8080
Listen 9090
Apache might not like that at first but meh.
The ServerRoot may already be declared above the Listen spot so just double check.
After that head to C:\xampp\apache\conf\extra.
Edit the httpd-vhosts.conf.
Under the section Name-based virtual hosting add:
NameVirtualHost *:7070
NameVirtualHost *:8080
NameVirtualHost *:9090
There will be a couple of examples of virtual hosts below that. Add:
<VirtualHost *:7070>
DocumentRoot "C:/xampp/www/YOURWEBSITEDIR1"
ServerName test.localhost.com
<Directory "C://xampp/www/YOURWEBSITEDIR1">
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:9090>
DocumentRoot "C:/xampp/www/YOURWEBSITEDIR2"
ServerName test2.localhost.com
<Directory "C://xampp/www/YOURWEBSITEDIR2">
Allow from all
</Directory>
</VirtualHost>
Not the double slash in the Directory tag. Now ensure there is an index.html under each of those directories. Restart the apache (Stop, start).
I cant navigate to the test.localhost.com URLs, probably due to the fact they are terribly wrong in the HOSTs config. Though I can connect to 127.0.0.1:7070, 127.0.0.1:9090 and access the webpages from there.
Also 127.0.0.1:8080 connects me to the xampp welcome panel that localhost used to connect you too.
Hope this helps and good luck!
I'm pretty sure that saying 'listening on port 80' is hard-coded into XAMPP, regardless of the port you use. Thus, your code should work fine.
In my .conf file, it just says "listen 80" instead of Listen 0.0.0.0:8080
Cheers.

How to I point multiple URLs to the right directory?

I have a VPS running CentOS 5. I want to point multiple domains at the same VPS (point them at the same IP), but serve up distinct websites for each domain.
So, the setup I want is like this:
site1.com ----> 127.0.0.1 ----> /var/www/html/site1.com/
site2.com ----> 127.0.0.1 ----> /var/www/html/site2.com/
I've tried setting up virtual hosts through the CentOS GUI for Apache, but they don't seem to be working. Only the first virtual host added will work (i.e. If I add site1.com first, both domains direct to that site. If I add site2.com first, both domains direct to that site.)
What might I be doing wrong? Is there an effective step-by-step tutorial for newcomers to get me started?
Update
Please remember, I have little to no experience working with CentOS and Linux ... but I'm learning.
To those who asked to see the directives I'm using, here's what CentOS added to the bottom of /etc/httpd/conf/httpd.conf when I used the built-in Apache GUI:
<VirtualHost skylarkapp.com:80>
DocumentRoot /var/www/html/skylarkapp.com
<Directory "/var/www/html/skylarkapp.com">
allow from all
Options +Indexes
</Directory>
ServerName skylarkapp.com
</VirtualHost>
<VirtualHost eamann.com:80>
DocumentRoot /var/www/html/eamann
<Directory "/var/www/html/eamann">
allow from all
Options +Indexes
</Directory>
ServerName eamann.com
</VirtualHost>
At the moment, all traffic to both skylarkapp.com and eamann.com on this system direct to the content of /var/www/html/skylarkapp.com.
Also, I'm using my Windows hosts file to manually point eamann.com to this server (204.92.23.6) because I'm in the process of migrating a live site. I want to get things working on the server before I actually move things from one box to another.
Name-based virtual hosts must be turned on explicitly with NameVirtualHost *:80. See http://httpd.apache.org/docs/2.2/vhosts/name-based.html
This line:
<VirtualHost eamann.com:80>
won't work since eamann.com won't resolve to your CentOS server's IP address (only your Windows machine resolves eamann.com to 204.92.23.6). Try making apache listed on any IP by replacing with:
<VirtualHost *:80>
You probably also want:
ServerAlias www.eamann.com
to allow visitors to www.eamann.com to see the site as well. Restart apache after making these changes:
service httpd restart