Installing Apache: Apache Download Apache Apache in Windows
Installing Apache: Apache Download Apache Apache in Windows
This tutorial covers its installation and and configuration in Red Hat Linu !." and #.". The $%&R'( distribution includes an Apache pac)age* but you can also do+nload Apache for free. There is another tutorial for Apache in Windo+s.
Installing Apache (ount the $%&R'( , and install the pac)age for apache. The pac)age +ill automatically create all the directories for you besides installing the soft+are. The document root +ill be placed in /home/httpd in !." and in /var/www in #.". The server root +ill be located in /etc/httpd. The path to the apache program +ill be /usr/sbin/httpd. In the document root three directories are created- cgi&bin* html and icons. In the html directory you +ill store the Web pages for your server. In the cgi-bin directory you +ill store your $.I programs. In the server root three directories are created- conf* logs and modules. In the /etc/httpd/conf directory you +ill find the three basic Apache configuration fileshttpd.conf* access.conf and srm.conf. In the /etc/httpd/logs directory you +ill find the access and error logs. The /etc/httpd/modules directory is +here the Apache modules are resident.
Configuring Apache in 6.0 Apache comes +ith the three configuration files mentioned above already +ith basic configuration information. /our 0ob +ill be to tailor these configuration files to your needs. In this tutorial +e +ill only deal +ith some basic features you need or may be interested in adding to your Web server. ,. httpd.conf- this is the configuration file related to the server in itself. 'pen the file httpd.conf in 1edit or any other te t editor li)e 2ico or 3macs. /ou are supposed to find the line ServerName and enter the 45%6 of your machine* and also find the line ServerAdmin and enter your e&mail address. The server comes configured to run in standalone mode* to listen in port 7"* +ith user and group nobody privileges 8lo+ level of permissions for security reasons9* and you don:t need to change these options. ;. access.conf- this is the configuration file related to access to directories and services in the Web server. Again* open the file access.conf in a te t editor. Loo) for the section that starts +ith <Directory /home/httpd/html> and loo) for the ptions line and change it to allo+ Server Side Includes* but disabling scripts to be run from a Web page* as follo+s- ptions !nde"es !ncludes #ollowSym$in%s !ncludesN &'&(. This +ill allo+ the dynamic dating of your changes* the dynamic display of time and date in your pages* but +ill prevent scripts to be run outside of your cgi&bin directory. 4or e ample* the HT(L code <)--*config timefmt+,-A -. -d/ -0 -- -!1-2 -p , --><)--*echo var+,DA3&4$ (A$,->
+ill be displayed as Thursday <anuary ;=* ;",> && ,;-", A( As an additional security measure you may also change the section starting +ith <Directory /home/httpd/cgi-bin> so that the 'ptions line be commented out as follo+s- * ptions &"ec(5!. This +ill not prevent you to run $.I programs in cgi&bin* but rather it +ill prevent the command e"ec to be used even in the cgi&bin directory.
3. srm.conf- this is the configuration file related to the location of the document
root* directory infornation formatting* user directories* etc. 'nce more* open the file srm.conf in a te t editor. If you +ant to change the location of the document root* loo) for the line Document6oot /home/httpd/html and change it to a ne+ location* but do not forget to move its three sub&directories 8html* cgi&bin and icons9 to the ne+ location* but there is no need for it. /ou may +ish* ho+ever* to change the default user Web directory to +++ . Loo) for the line 7serDir and change it to 7serDir www . 4iles placed in the user accounts in this directory are displayed in the +eb +hen /8username is used after the server name 8e.g. ubmail.ubalt.edu?@abento9. /ou may also +ant to add inde .htm to the list of files that may be inde files to a Web directory. In order to do so* loo) for the line Directory!nde" and change it to Directory!nde" inde".html inde".shtml inde".htm $hec) that your cgi&bin directory is properly identified as follo+s- ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/ . If you moved your document root path change this line accordingly. If you +ant your $.I script files to be identified +ith .cgi be sure that the line Add9andler cgi-script .cgi is not commented out 8mar)et +ith in A in front9. To complete the installation of server side includes be sure that the follo+ing t+o lines are presentAdd3ype te"t/html .shtml Add9andler server-parsed .shtml 4inally* to ma)e your Web server support image maps be sure that the follo+ing line e ists- Add9andler imap-file map
Configuring Apache in 7.0 Apache in #." comes +ith the same three configuration files* but only httpd.conf needs to be configured* changed* by you. The other t+o are considered obsolete and should not be changed. o httpd.conf- this is the overall configuration file. 'pen the file httpd.conf in 1edit or any other te t editor li)e 2ico or 3macs. 4ind first the line *.indAddress : and delete the B 8uncomment it9 to ma)e it active. 4ind the line ServerAdmin and enter your e&mail address* and loo) for the line ServerName and enter the 45%6* or I2 number of your machine* or yet localhost. The server comes configured to run in standalone mode* to
listen in port 7"* +ith user and group apache 8 +ith lo+ level of permissions for security reasons9* and you don:t need to change these options. The document root directory is by default in the line %ocumentRoot C?var?+++?htmlC Loo) for the section that starts +ith <Directory ,/var/www/html,> and loo) for the ptions line and change it to allo+ Server Side Includes* but disabling scripts to be run from a Web page* as follo+s- ptions !nde"es !ncludes #ollowSym$in%s !ncludesN &'&(. This +ill allo+ the dynamic dating of your changes* the dynamic display of time and date in your pages* but +ill prevent scripts to be run outside of your cgi&bin directory. 4or e ample* the HT(L code <)--*config timefmt+,-A -. -d/ -0 -- -!1-2 -p , --><)--*echo var+,DA3&4$ (A$,--> +ill be displayed as Thursday <anuary ;=* ;",> && ,;-", A( Loo) for the line 7serDir and I suggest you replace publicDhtml 8the default9 by +++ a more familiar directory name. This +ill allo+ users to place files in their +++ directory and be seen on the Web using the server address follo+ed by the tilde 8@9 and the username* li)e my ERL in EF(ail- http-??home.ubalt.edu?@abento . If you do this* also change the line G%irectory ?home?A?publicDhtmlH replacing publicDhtml +ith +++. /ou may +ant to change the order of your inde files* ma)ing inde .shtml 8the SSI version9 to be the first to be displayed by the bro+sers. In order to do so* loo) for the line Directory!nde" and change it to Directory!nde" inde".shtml inde".html inde".htm $hec) that your cgi&bin directory is properly identified as follo+s- ScriptAlias /cgi-bin/ /var/www/cgi-bin/ . If you moved your document root path change this line accordingly. As an additional security measure you may also change the section starting +ith <Directory /var/www/cgi-bin> so that the 'ptions line be commented out as follo+s- * ptions &"ec(5!. This +ill not prevent you to run $.I programs in cgi&bin* but rather it +ill prevent the command e"ec to be used even in the cgi&bin directory. Loo) for the line starting +ith * Add9andler. If you +ant your $.I script files to be identified +ith .cgi be sure that the line Add9andler cgi-script .cgi is not commented out 8mar)et +ith in A in front9. To complete the installation of server side includes be sure that the follo+ing t+o lines are presentAdd3ype te"t/html .shtml Add9andler server-parsed .shtml 4inally* to ma)e your Web server support image maps be sure that the follo+ing line e ists- Add9andler imap-file map
Starting Apache /ou can start* stop and restart the Apache Web server by using scripts created for this purpose in Red Hat Linu . Type in a shell prompt as root- /etc/rc.d/init.d/httpd start to start the server. To
stop or restart use the same script but replacing start +ith stop or restart. /ou must start the server as root* in order to run the server in port 7"* as defined in httpd.conf. The server +ill run as the user nobody 8not root9 +ith lo+ level privileges* as discussed before. I suggest you create in the ?root?bin directory three files +ith the file names startap 8start apache9* stopap 8stop apache9* and restartap 8restart apache9 +ith the command line above adapted to each case 8e.g. for restart- /etc/rc.d/init.d/httpd restart9. Then change the permissions of each file using- chmod u;" . This +ay +hen you type startap the Apache server +ill be started* +ithout you having to remember the +hole script command line.
for testing purpose +e are +riting site name in its inde& page save file and e&it no+ open 'etc'hosts file in the end of file bind system ip +ith www.vinita.com
no+ open 'etc'httpd'conf'httpd.conf main configuration file of apache server locate virtual host tag
6o+ go in the end of file and copy last seven line I virtual host tag J and paste them in the end of file. change these seven lines as shown in image
no+ save this file and e it from it you have done necessary configuration no+ restart the httpd service and test this configuration run lin*s command
if lin*s command retrieve your home page means you have successfully configured the virtual host no+ test it +ith site name In output of lin*s command you should see the inde& page of site
for testing purpose +e are +riting site name in its inde& page
save file and e it no+ open 'etc'hosts file and bind s+stem ip +ith www.ni*ita.com
no+ open 'etc'httpd'conf'httpd.conf main configuration file of apache server 6o+ go in the end of file and copy last seven line I virtual host tag J and paste them in the end of file. change these seven lines as shown in image
no+ save this file and e it from it you have done necessary configuration no+ restart the httpd service
test this configuration run lin*s command In output of lin*s command you should see the inde& page of site
6o+ +e +ill host multiple sites +ith multiple ip address. $reate a virtual lan card on server and assign its an ip address of !". 6#.0."$,. +e +ill create a testing site www.nidhi.com and +ill bind it +ith ip address of !". 6#.0."$, create a documents root directory for www.nidhi.com +ebsite and a inde page
for testing purpose +e are +riting site name in its inde& page save file and e it no+ open 'etc'hosts file and bind s+stem ip +ith www.nidhi.com
no+ open 'etc'httpd'conf'httpd.conf main configuration file of apache server 6o+ go in the end of file and copy last seven line I virtual host tag J and paste them in the end of file. change these seven lines as shown in image
you have done necessary configuration no+ restart the httpd service
In output of lin*s command you should see the inde& page of site
6o+ open main apache configuration 'etc'httpd'conf'httpd.conf 6o+ go in the end of file and copy last seven line I virtual host tag J and paste them in the end of file. change these seven lines as shown in image
no+ save this file and e it from it you have done necessary configuration no+ restart the httpd service and test this configuration run lin*s command
In output of lin*s command you should see the inde& page of site