Linux apache installation


Published on

  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Linux apache installation

  1. 1. Prepared by: Dima Gomaa
  2. 2.  Apache is a web server package that works under Linux as well asunder other operating systems The name Apache comes from the concept of extensive patching ofexisting code The primary advantage of Apache is that it is generally free oravailable at modest costs
  3. 3.  Download newest version of Apache◦ May be installed from a CD-ROM as well Unzip downloaded file Untar the tar file Create the MAKE files Make Install Edit httpd.conf file Start Apache Server
  4. 4.  If your CD-ROM has Apache and you want to use RPM to install thepackage, issue this command◦ rpm –i apache_1_3_4.rpm(substitute the full name of the Apache package)
  5. 5.  First, in Linux, create a folder to hold the Apache file you will download. The newest version of Apache Server and Documentation can be foundat The Apache Software Foundation To download the newest version of Apache go to and click on httpd-2.4.4.tar.gz Download this file into your newly created directory. NOTE: apache 2.4.4 is the latest version at the time of this writing. Youmay want to check for newer releases.
  6. 6.  After you have downloaded your Apache file go into the folder you havedownloaded it into by typing cd /path to folder/name of folder/ Next, to unzip the .gz file at the prompt type: gunzip httpd-2.4.4.tar.gzand press the enter key. This will unzip the file into the current directory.
  7. 7.  After unzipping the .gz file the resulting file will be a .tar file. (Whichstands for tape archival) You will need to untar this file by typing at the prompt:◦ tar –xvf httpd-2.4.4.tar This will un-tar the file to a new directory named httpd-2.4.4
  8. 8.  Go into the folder that now contains the untarred apache files. To changeinto that folder, at the prompt type:◦ cd /<path to folder>/httpd-2.4.4 Once you are in the httpd-2.4.4 folder you will need to create the apachemake files To do this, at the prompt type:◦ ./configure --prefix=/usr/local/apache and press the enter key. This will install apache inthe folder /usr/local/apache. You may chose to install in another directory.
  9. 9.  After running the configure command you will need to compilethe make files. To compile the make file, from inside in the httpd-2.4.4directory, at the prompt, simply type:◦ make
  10. 10.  Next you must run the make install. While still in the directory httpd-2.4.4, at the prompt, type:◦ make install This will install the apache server to the directory defined in theconfigure command.
  11. 11.  In order to get the apache server started you must edit the httpd.conf file.The file is located in whatever directory you installed apache in. Once in your apache install directory find the folder named conf. Change into the conf folder and locate the file named httpd.conf. Open the httpd.conf file with any file editor. Next locate the line # ServerName <Name> and uncomment out this line bydeleting the # symbol preceding ServerName. Save the file and close it.
  12. 12.  To start your Apache server you must either put the location of thedirectory, where your Apache server is installed, in you PATHenvironment variable or you must change into your Apache directoryand at the prompt type:◦ ./apachectl start If the path to your Apache install directory is already in your PATHenvironment variable, then you can type:◦ apachectl start
  13. 13.  To stop your Apache Server, from inside the directory where yourApache is installed, type:◦ ./apachectl stop To restart your Apache Server, from the directory where your Apacheis installed, type:◦ apachectl restart
  14. 14.  After you have installed and started your Apache server you can testto if everything is running OK by doing the following… Start a browser application. If you installed Apache as root, type in the address bar of yourbrowser the name of your computer and press enter.
  15. 15.  If everything has gone as it should have you should see a page withthe apache logo at the top explaining why you are seeing this page.This page gives you links to all the apache documentation which youshould read. If you would like to customize this index page it is calledindex.html.en in the htdocs directory located in the directory yourApache server is installed.(source: http://
  16. 16.  Create the home directory for the website, we will use/usr/www/mywebsite Create 3 subdirectories under the site directory◦ conf◦ htdocs◦ logs
  17. 17.  You will find a subdirectory called conf under the directory whereyou installed Apache◦ Copy 3 files (srm.conf-didst, access.conf-dist, http.conf-dist) fromthis directory into /usr/www/mywebsite/conf◦ If you cannot find the 3 files, use the find command to find them
  18. 18.  Rename the 3 files you just copied to drop the “-dist” portion of thename Edit the httpd.conf file to specify◦ the port number on which your web server responds◦ the user running the httpd daemon, etc… Specify the server name◦ ServerName
  19. 19.  Add a line that specifies the root directory for your website◦ DocumentRoot /usr/www/mywebsite/htdocs Edit the srm.conf file to set up the web home directory and anyspecial internal command usage Edit the access.conf file to set a basic set of access permissions
  20. 20.  In the htdocs directory create an HTML file for the server to readwhen it starts◦ This can be any HTML file◦ The filename should be default.html Start the httpd daemon◦ httpd –f /usr/www/mywebsite/conf
  21. 21.  Test the web server by starting a browser and specify the URLhttp:// If the system is working properly, you will see a screen with a list offiles in the htdocs directory
  22. 22.  Make sure the ServerType directive is set to “standalone” Check the Port device to make sure it is set to the TCP/IP port towhich your Apache server listens Set the User directive to either the user ID (UID) or the user nameused for all web visitors
  23. 23.  Set the Group directive to either the group ID (GID) or the groupname assigned to all web users Modify the ServerAdmin directive to include the e-mail address ofthe administrator Set the ServerRoot directive to the absolute path to the directorywhere all Apache resource and configuration files are stored◦ /usr/apache/conf or /etc/httpd
  24. 24.  Set the ServerName directive to the fully qualified domain name ofyour server
  25. 25.  If you are running Apache as a standalone server, you need to startand stop Apache manually◦ Start with httpd –d rootdir –f configs◦ To stop Apache use ps to detect the httpd daemon’s PID and usethe kill command to terminate the process
  26. 26.  A virtual host is a web server that resides on one domain but actsas if it was on another. For example, suppose you and Instead of setting up 2 servers, youcan set up a single machine that serves both domains. Virtual hosting saves on machinery and allows for a lot of flexibilityin setting up web servers
  27. 27.  If your network uses a name server for DNS, modify it so that thedomain name points to your web server for each domain you’ll host Use the ifconfig command to set up the IP address for each domainon your server◦ ifconfig eth0:1
  28. 28.  Add the route to the network configuration using the route command◦ route add –host dev eth0:1 Edit the Apache httpd.conf file to set up virtual hosting◦ <VirtualHost>DocumentRoot /usr/www/test/htdocsTransferLog /usr/www/test/logs/accessErrorLog /usr/www/test/logs/errors</VirtualHost>
  29. 29.  The previous step defines the virtual host for and specifiesits DocumentRoot, since each virtual host will have different webdirectories If more than one virtual host is defined, the entries are to berepeated for each