I have read other answers here on this site, but they only answer part of my question. I have XAMPP for Windows 7.2.0-0 on my computer. I have partitioned my hard drive to add an E: drive. My htdocs folder is in C: drive and I have a FQDN pointing to my ip address; say (example.com).
Next I created a directory in E: named 'me'; which contains all the files for a functioning website.
Now, after following all the directions from cmcculloh, I can just type me.example.com in my browser and up pops the website, but this URL does not work from any other computer. Could someone help me to understand how I need to configure The 'httpd-vhosts.conf' & 'hosts' files; along with, what the proper URL address should be to view the website located in 'E:me' from a remote computer.
Here is what I have done in 'httpd-vhosts.conf':
<VirtualHost *:80>
DocumentRoot "E:/me"
ServerName me.example.com
ServerAlias me.localhost
<directory E:/me>
Require all granted
</directory>
ErrorLog "E:/me/logs/error.log"
TransferLog "E:/me/logs/access.log"
</VirtualHost>
I have tried many different variations with the server name and alias but none work any better.
Here is what I have done in 'hosts':
127.0.0.1 me.example.com
Like I said this works in the browser of the computer that the server is on, but trying to view this site from another computer I get "This site can't be reached" "me.example.com's server IP address could not be found".
Am I 'barking up the wrong tree' by approaching it like this, or should I be researching how to add the contents of a separate drive to the htdocs folder. I am at a loss as to how this can be achieved. My hard drive is near full and I need to add more storage space, but have to figure this out before I purchase more hardware.
Solution by OP.
To accomplish my goal of accessing the pages from a remote computer I had to use the command mklink /J. The example below created a directory named 'my' in my 'htdocs' linking to everything on my 'E:' drive.
mklink /J C:\xampp\htdocs\my E:
The only thing I don't like about it is that in order to view the webpage in E:/me, I have to type the URL example.com/my/me instead of example.com/me. I know it's not a big deal having to type the extra directory 'my' in the URL, but I just don't like the look of it. Also this negates the need to add 'VirtualHosts' and 'mapping'; although, I may have to do that anyway with '.htaccess' to keep users from accessing directories other than theirs.
Related
I installed WAMP and followed this guide to set up virtual hosts. In both Google Chrome and Internet Explorer, http://localhost gets me to "WAMPSERVER homepage" with my virtual host listed under "Your Projects."
Clicking that link to http://mysite.local in Chome brings me to my site as expected.
Clicking that link in Internet Explorer displays the following message instead.
This page can’t be displayed
•Make sure the web address http://mysite.local is correct.
•Look for the page with your search engine.
•Refresh the page in a few minutes.
Since I can see the WAMPSERVER homepage as expected in both browsers, I don't think there's a problem with my WAMP installation. Since my virtual host is working in Chrome, I think it must be configured properly in Apache and in my Windows hosts file.
I just don't understand why Internet Explorer isn't working with my virtual host like I expect it to, and the "Page can't be displayed" message doesn't give me anything helpful to work with.
Does anyone have any suggestions for me? I'd greatly appreciate any pointers or links to other guides I can try. Thanks in advance for any replies!
There's several reasons WAMP/MAMP may not work on a local environment, I'll try to list a few reasons here:
Which httpd.conf?
There are sometimes multiple httpd.conf files that can cause things to go a little bit funny. MAMP/WAMP usually tend to keep all their configuration files within a conf/ directory however, that doesn't mean to say some other httpd.conf file is being used...
You can also run this command on Linux based systems to see which one is being used:
apache2ctl -V | grep SERVER_CONFIG_FILE
vhosts definitions not included in httpd.conf
In the httpd.conf file, there's a line to include the vhosts definitions file, it should be uncommented:
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf // remove the #
Incorrect vhosts definitions
Vhosts need to be defined as follows:
<VirtualHost *>
DocumentRoot "C:/path/to/your/local/site"
ServerName mydomain.local
</VirtualHost>
Hosts file
On OS X/Linux systems this can be found at etc/hosts. Edit that to reflect below (note, you'll need to be root)
127.0.0.1 mysite.local
On windows systems, it can be found in %SystemRoot%\System32\drivers\etc\hosts.
Browser caches
Browser caches always cause an issue with local servers/development. It's worth working with incognito mode on, or deleting all browser caches each and every time you open it up. There's a few plugins available for most browsers that should help too.
Other points to note
Whenever you edit anything to do with httpd.conf, vhosts, hosts file - WAMP/MAMP/Apache needs to be restarted. It's a good idea to shut the server down before doing the changes.
You mentioned that there was a hardcoded link in one/some of your files. It's generally regarded as bad practise to do that for this exact reason. Your code is less portable and can 'break' on other systems. I'd suggest using PHP's __FILE__ or similar to achieve what you want.
Alternatively you could set up local configuration files for your app that are only included when they're present. Have a look at this for a good example of such a set up.
Log everything. Check the logs regularly too.
I have been trying this for hours and am getting pretty frustrated. I am trying to use a ReadyNAS Pro as a webserver. It uses Apache for its web interface. I would like to use that interface when I address the device via IP address, but I also have my domain name pointing to it. When I use my domain name I want it to display my website (with wildcards for the website's pages). I have tried using mod-rewrite without much success. It seems to break the ReadyNAS web interface. I have tried adding a named virtual host, but I don't have much experience with that and I don't know what I should use as a default virtual host to address my machine by IP. I have tried moving the ReadyNAS web interface to a sub-folder of the Apache Root, but that seems to break the web interface also.
It should be noted, that while I could create a subdomain for the web interface, I would rather address it by my machine's local IP only so it isn't visible to the outside world. While there are some simple tutorials of setting up a website on the ReadyNAS they use the ReadyNAS share system that appends a folder name to your url i.e. domain.com/www/. This is just no good.
Long story short, I want to host my website using my domain on my ReadyNAS (no sub-folders). I want to continue using the ReadyNAS web interface, but only from my local network. I do NOT want to run a second web server. I do NOT want to wipe the original OS (proprietary hardware/drivers are used for intelligent power management)
For reference it is a ReadyNAS Ultra 4+ with ReadyNAS default OS (Debian Etch).
P.S. Don't tell me this isn't what a NAS is for, I am aware and I don't care nor want to hear you cry about it.
If I did understand correctly you would like to access your own site with address like mydomain.home not mydomain.home/www I have achieved this with following config by using ReadyNas Duo
First modify Virtual.conf file from
<VirtualHost _default_:80>
to
NameVirtualHost *:80
<VirtualHost *:80>
Now you can add new virtual host config file under the addons directory ie. mydomain.conf
<VirtualHost *:80>
ServerName mydomain.home
DocumentRoot /var/www/mydomain.home
<Directory /var/www/mydomain.home>
Options Indexed
Order allow,deny
Allow from all
</Directory>
SSLEngine off
</VirtualHost>
Here is link for the original post that I did follow https://liewdaryl.wordpress.com/page/2/
I did add NameVirtualHost definition so apache would not warn about overlapping virtualhost definitions
I installed WAMP Server on my laptop, which is running Windows 8 Pro.
I created a number of folders in the www folder in the wamp folder. My problem is that whenever I try accessing the folders from the localhost page in my web browser, I am taken to the internet page of the folder i.e. I have two folders named family & prestashop. Whenever I click on them, a tab opens in my browser directing me to http://family/ instead of http://localhost/family/
What could be the problem?
Without seeing your httpd.conf (or httpd-vhosts.conf) it is hard to say where your problem is (or why it is a problem). Usually, to set up multiple sites, you will add virtual hosts to your httpd.conf or httpd-vhosts.conf which will tell WAMP what to do when people try to access that folder. The difference between a web address that looks like http://localhost/family and http://family is probably that you have set up a virtual host which allows you to get at that directory without running through 'localhost'.
Do you have something like this in your http-vhosts.conf in C:\wamp\bin\apache\Apache<version>\conf\extras\ ?
<VirtualHost *:80>
DocumentRoot "C:\wamp/www/family/"
ServerName "family"
</VirtualHost>
I have on my laptop a WAMP server as my local server. On this server i am hosting a webpage just for local use.
I also have registered a free domain name for my server from dyndns.org. I'm using dynamic DNS by running a software from dyndns.org.
When i try to access my server and view the website which i am hosting on it using my browser, by typing localhost or my free domain name, it works just fine.
But the problem is that when a friend of mine sitting right next to me(on the same local network) tries to visit my webpage from his laptop, he gets an error message saying:
"You don't have permissions to access this server" .
I configure the httpd.conf file after i installed the WAMP server and changed only the DocumentRoot and the Directory to a folder of my choice inside the www folder.
Also i changed the ServerName to be my free domain name.
I don't think that the above are the problem. So , anyone has a clue of what might be wrong here ?
Did you try writing this:
<Directory yourdir>
Order Allow,Deny
Allow from all
</Directory>
Nope neither that worked. But after messing around with the httpd.conf file i found the solution. In the
< Directory yourdir >
Order Allow,Deny
Allow from all
# I had to put this line also
Require all granted
< /Directory>
I'm wondering if anyone can help me define a new local VirtualHost using Apache.
The goal is to have a site that is viewable only from the local network (hidden behind a firewall). Right now I have Webmin installed and it runs on transaction:10000. I am trying to get the other site running on transaction:7000.
The following does not work:
DocumentRoot /var/path
Is there a better way to do this? I'm new to Apache and trying to figure this out.
Summary: Need local /var/path directory to run on a port other than 80 for local access only.
I'm assuming that you don't know to Apache Virtual Host Code. I will show you how to use it. If this didn't help you please don't hesitate to reply to me.
You must place code in your HTTPD.CONF which can be found in the conf folder. If your file is called wwwroot instead just change the name in the code below BUT DO NOT CHANGE THE NAME OF THE FOLDER!!!
NameVirtualHost 111.22.33.44
<VirtualHost *:7000>
ServerName www.domain.tld
ServerPath /domain
DocumentRoot /htdocs/domain
</VirtualHost>
What does this mean? It means that a request for any URI beginning with "/domain" will be served from the virtual host www.domain.tld. This means that the pages can be accessed as domain.tld/domain/ for all clients, although clients sending a Host: header can also access it as domain.tld/.
In order to make this work, put a link on your primary virtual host's page to http://www.domain.tld/domain/. Then, in the virtual host's pages, be sure to use either purely relative links (e.g., "file.html" or "../icons/image.gif") or links containing the prefacing /domain/ (e.g., "http://www.domain.tld/domain/misc/file.html" or "/domain/misc/file.html").
So all domains will be pointed to your IP address and based on the domain name if it is "www.domain.tld" it will take you to the folder "/htdocs/domain" or "/wwwroot/domain"
EDIT:
<Directory "/var/path/">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
This lets access to the "/var/path/" folder from only localhost which is where Apache is configured which is on your computer!
Good Luck!!!