Nov 22, 2009

Apache, Subdomains, Indexes And Mail

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Software > Internet & Network Clients/Servers

Apache, Subdomains, Indexes And Mail

Habble
Hi, on my other computer (not connected to the internet) I have an Apache server, just to test out PHP pages and stuff, I'd like to know how to do some stuff in it, like:
Have subdomains, e.g. abc.localhost, do you modify something in the httpd.conf file? How do you edit DNS records?
Indexes, set it up so that http://localhost will take you to http://localhost/index.php. At the moment, it's set up so that it'll take you to localhost/index.html, but if there's no index.html file, it'll take you to a list of files.
Mail, e.g. abc@localhost, how do you set up mail? You probably need some other kind of server, I don't know, but I really need this for testing contact forms, and other things with the mail() function.

Thanks, I have looked in the Apache documentation, but it's a bit complicated, and it's hard to find the thing you're looking for.

Comment/Reply (w/o sign-up)

Sten
As you know, apache wont work all that brilliantly on my computer.
I just get a command prompt with like 100 errors.

Comment/Reply (w/o sign-up)

seec77
Hey Habble,
I think I have a solution for at least one of your problems!
I just wanted to say first that yes, Apache is a powerful application, and naturally that makes it somewhat complicates, and gives it a bit of a learning curve. You will see that once you start "getting the hang" of it, the documentation will seem so much simpler to you, so don't give up! Running your own web-server is a great experience that helps with web-page programming and creation.

So, now for some direct answers! If you want to change the list of index files, that Apache will open when a directory is requested, you just need to find the "DirectoryIndex" directive in the "http.conf" file. Mine looks like this:
CODE
DirectoryIndex index.html index.html.var index.php main.php

As you can probably see, you only need to add another filename to the space-delimited list!

Now for subdomains. The way Apache (and the HTTP protocol) works is that a server may have only 1 IP, but when a web browser requests the subdomain of the server, while still going to the same server, it passes a "Host: subdomain.example.com" in the HTTP request, and thus the server knows it needs to server the subdomain. So basically you can (if you're using Windows) go to "c:\windows\system32\drivers\etc\" (you may have a different Windows directory from me), and edit the Hosts file. For each subdomain you want, add a line to the file that looks something like this:
CODE
127.0.0.1       subdomain.localhost

Now each time you visit "subdomain.localhost" in your browser, you will be redirected to 127.0.0.1 by Windows. That IP is an IP that tells the computer to access itself. Because the Apache server is running on your computer, 127.0.0.1 will redirect you to your web-site. When you visit the subdomain, Apache will get the information from the browser that tells it that we're looking at a subdomain. To configure Apache to recognize and respond correctly to multiple subdomain, you need to you "virtual hosts." I've never done this before, so I can't help you from my memory, but two articles that might really help you are this one and this one.
I hope you manage to get it working, and if not, just write back!

As for configuring an email? This one requires a totally different server than Apache. You can find some very nice result by googling "email server" or "smtp server." I'll try to look for some things that might be of help to you, but I've never run an email server, so I might not be of much help. Sorry! sad.gif

I hope I've managed to assist you in some way!

 

 

 


Comment/Reply (w/o sign-up)

Mark420
The easiest way to get Apache, mail, FTP, MySQL, PHP etc running on your machine is to use something like XAMMP - it runs on windows, linux, osx and solaris.
I use it myself and must say it is so easy to configure, just follow the onscreen prompts and you are all set.
Here is what the basic package contains - Apache HTTPD 2.2.4, MySQL 5.0.41, PHP 5.2.2, PHPMyAdmin 2.10.1, Mercury Mail Transport System v4.01a, FileZilla FTP Server 0.9.23 and also has the zend optimiser installed.Also I think its got SSL as well but I have never used it.
One other great thing about Xammp is the way you can install it all "ON" or "OFF" what I mean by that is that you dont have to install it and activate the services at startup of the mahine.There is a Xammp control panel application that you start then click on the servers you want to start, for instance I tend to only start Apache and MySql and turn off Mail and FTP.
I do this so that I dont have all these services running all day long on my pc and also giving a hacker more open ports to have a look at wink.gif
All in all Xammp is a perfect way to test out any site locally before hosting it here, I do this and it takes much less bandwidth off my astahsot account, I get a site 100% working an no bugs before transferring it to Gamma.

Comment/Reply (w/o sign-up)

Habble
Thanks seec77 and Mark420, I'll try out those things later today when I go onto my other computer, and I'll have a look at XAMPP.

I've seen Virtual Hosts in the Apache Docs before, but I didn't really understand what they were. I'll have a look round for some Mail programs. Thanks!

Comment/Reply (w/o sign-up)

Habble
QUOTE(seec77 @ Jun 28 2007, 10:12 AM) *
Hey Habble,
I think I have a solution for at least one of your problems!
I just wanted to say first that yes, Apache is a powerful application, and naturally that makes it somewhat complicates, and gives it a bit of a learning curve. You will see that once you start "getting the hang" of it, the documentation will seem so much simpler to you, so don't give up! Running your own web-server is a great experience that helps with web-page programming and creation.

So, now for some direct answers! If you want to change the list of index files, that Apache will open when a directory is requested, you just need to find the "DirectoryIndex" directive in the "http.conf" file. Mine looks like this:
CODE
DirectoryIndex index.html index.html.var index.php main.php

As you can probably see, you only need to add another filename to the space-delimited list!

Now for subdomains. The way Apache (and the HTTP protocol) works is that a server may have only 1 IP, but when a web browser requests the subdomain of the server, while still going to the same server, it passes a "Host: subdomain.example.com" in the HTTP request, and thus the server knows it needs to server the subdomain. So basically you can (if you're using Windows) go to "c:\windows\system32\drivers\etc\" (you may have a different Windows directory from me), and edit the Hosts file. For each subdomain you want, add a line to the file that looks something like this:
CODE
127.0.0.1       subdomain.localhost

Now each time you visit "subdomain.localhost" in your browser, you will be redirected to 127.0.0.1 by Windows. That IP is an IP that tells the computer to access itself. Because the Apache server is running on your computer, 127.0.0.1 will redirect you to your web-site. When you visit the subdomain, Apache will get the information from the browser that tells it that we're looking at a subdomain. To configure Apache to recognize and respond correctly to multiple subdomain, you need to you "virtual hosts." I've never done this before, so I can't help you from my memory, but two articles that might really help you are this one and this one.
I hope you manage to get it working, and if not, just write back!

As for configuring an email? This one requires a totally different server than Apache. You can find some very nice result by googling "email server" or "smtp server." I'll try to look for some things that might be of help to you, but I've never run an email server, so I might not be of much help. Sorry! sad.gif

I hope I've managed to assist you in some way!


I tried what you said, and I changed the hosts file, and then I added a VirtualHost. The hosts I added were test.localhost and www.jays-server.com
This worked fine, and when I went to these addresses, it took me to localhost. But when I tried using virtualhosts, it wouldn't work. It completely ignored them. I did restart apache once I changed them, but they still took me to the localhost index. Do you know what the problem is?

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : apache, subdomains, indexes, mail

  1. Apache Bug
    Slowing down (0)
  2. Installing Apache, Php And Mysql On Win Xp
    (8)
    Hi, i develop a web application that runs perfectly on my development machine -Win 2kPro- where i
    have Apache, Php and MySql installed. A few days ago i went to my client to install it in a Win XP
    machine that will act as the webserver, so i proceed to install the Apache 2.0.59 webserver, Php
    5.1.x and MySql 5.x and my web application and everything installs and works fine without a problem.
    Then, i proceed to run my web application to test it and also to know if something gone bad, happily
    everything is fine and works perfectly /smile.gif" style="vertical-align:middle....
  3. Problem With Apache In Xampp
    (2)
    I use XAMPP as the development server on my laptop but recently the Apache version bundled
    hasn't been working saying that there are "no listening sockets available". It is currently set
    to the default port of 80 but even when I cahnge it to something unused it still doesn't work.
    I can't find a version of XAMPP with Apache 1 installed as I heard that downgrading it might
    work. I can't thinkof anything that would cause it to stop working but even when I close all the
    programs and stop running all the background services except explorer it still doesn'....
  4. Please Help: Problem In Enabling Mod_rewrite Module In Apache 1.3.27
    (1)
    Hi everybody, I am new to PHP sub-forum and this is my first post in this sub-forum. I have a
    problem and I need your assistance. I want to mod_rewrite my new website (yet to be hosted).
    However, before hosting it, I want to test my .htaccess file in my local server ( Server version
    : Apache 1.3.27 ). Although I have made the following modifications in my Apache Configuration File
    (httpd.conf) to enable mod_rewrite module: QUOTE LoadModule rewrite_module
    modules/mod_rewrite.so AddModule mod_rewrite.c But, it is still not working for me. I tried out
    p....
  5. Apache Rewrite
    (0)
    Hi, i run Apache 2.0(i think) on a Windows XP system and now i want to use
    mod_rewrite(modules\mod_rewrite.so). But...it doesn't work so fine*hehe*(soo far). I have
    uncommented this line: #LoadModule rewrite_module modules/mod_rewrite.so And now(what i have
    readed)i should uncomment this line: #AddModule mod_rewrite.c But i don't find it anywhere, in
    httpd.conf? What is wrong? Sorry the /wacko.gif' border='0' style='vertical-align:middle'
    alt='wacko.gif' /> Englisch!....
  6. Apache, Vsftpd Problems - Resolution Error
    FTP as well (1)
    (if this topic is in the wrong spot, I apologize. please just move it as I wasn't sure *exactly*
    where this belonged... linux or here but because the name is Internet & Network client/servers, I
    figured it fit here more than Linux) I noticed this after I re-installed Apache (SUSE Linux
    Enterprise Server 9, has both Apache2 and Apache 1.3.X but the test page for the server says:
    QUOTE     Webserver version: ) but everytime I go to http://192.168.0.105/~tnewton , the
    browser starts looking for "linux.site" but if I go to http://192.168.0.105/~tnewton/ , it l....
  7. Apache And Merlin
    local host server (12)
    I downloaded both but I think I only need one but not sure, and can I start using them before I have
    a website?....

    1. Looking for apache, subdomains, indexes, mail

See Also,

*SIMILAR VIDEOS*
Searching Video's for apache, subdomains, indexes, mail
advertisement



Apache, Subdomains, Indexes And Mail

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com