Posted by: tonyteaching | November 1, 2008

To Configure our Server (Apache)

We have installed the HTTP/Web Server (“Apache”) on our PC because later we need to test any of our web files (php, html,…) before we put them in the real server (e.g. in infoeng server).

Remember: the default location/folder to put all our web files in Apache server system is in /htdocs/ (if the operation system is Windows), or in /var/www/html/ (for Unix)

–> It means when on our web browser we type “http://localhost”….it will access file “index” in this default directory.

————————

However,

1. we can also define a different default directory (e.g. we want to save in ‘F:/webfiles’

–> we need to edit file httpd.conf (in folder “/conf/”)

Find and change text becoming

DocumentRoot “F:/webfiles/”

and also find and change

<Directory “F:/webfiles”>

2. Also we can make an ALIAS location for our web files. For instance: I put my web files all in directory F in folder “tony”

–> we need to edit file httpd.conf (in folder “/conf/”)

just add (for example the folder alias’ name is “smsegov”) :

Alias /smsegov/ “F:/tony/”

<Directory “”F:/tony/”>

Options Indexes FollowSymLinks Includes

AllowOverride All

#Order allow, deny

Allow from all

</Directory>

So..now we can keep our web files in “F:/tony/” and we can access them just using “http://localhost/smsegov/

3. Another configuration We may change is the directory index. This is the file that Apache will show when you request a directory. As an example if you type http://www.php-mysql-tutorial.com/ without specifying any file the index.php file will be automatically shown.

Suppose you want apache to use index.html, index.php or main.php as the directory index you can modify the DirectoryIndex value like this :

DirectoryIndex index.html index.php main.php

Now whenever you request a directory such as http://localhost/ Apache will try to find the index.html file or if it’s not found Apache will use index.php. In case index.php is also not found then main.php will be used.

———–

Don’t forget: always save the file, and restart our Apache server every time we make a change in the configuration.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: