60 likes | 243 Views
Installing Apache. There are several ways to install the Apache web server in CIT 370, you probably installed it from the CentOS CD-ROM although in fact, in many versions of Linux, the software is already installed
E N D
Installing Apache • There are several ways to install the Apache web server • in CIT 370, you probably installed it from the CentOS CD-ROM although in fact, in many versions of Linux, the software is already installed • once the software is installed, its just a matter of configuring the server using the httpd.conf file and starting/restarting the service (httpd) • There are other ways to install Apache • download and install from the binary using yum or rpm (or other package managers like dpkg or apt-get) • download the source code and run the make utility • we will use this last approach for 436 for a couple of reasons • to tailor Apache’s directories and modules • to get more experience handling source distributions in Linux
Using ./configure • Recall from 370 the make utility • runs a file called makefile to compile a source distribution into executable files • The makefile file is written by some programmer • in some packages, there is no makefile file, instead you can generate it running the configure script • this also allows you to change default directories, add or remove modules to the compilation, and other changes to the default set up of the software • in Apache, you can see what options are available by using ./configure –help • other Apache options include • --prefix – change the default location for all of Apache • --bindir – change the location to store the apache binary directory • --datadir – change the location to store DocumentRoot • --logfiledir – change the location to store Apache log files • --sysconfdir – change the location for the conf files (httpd.conf and others) • --enable-module, --add-module, --disable-module – to specify which module(s) should be compiled • NOTE: Apache 2.2 has changed from what is published in the textbook, one major change is that most modules are automatically compiled for us
What are Modules? • The main apache configuration directives go in the main configuration file (httpd.conf) • But there are many other directives that are available only if you load a particular module • more recent versions of apache tend to most of the meaningful modules, we will see as we go through the semester that a few are not available • for these “add on” modules, we may have to compile them and then load them using a load directive in the httpd.conf file • you can compile all modules using --enable-module=all when you configure the makefile (./configure --enable-module=all) • we will explore modules in chapters 4 & 5 and beyond, but for a sneak peak, you can see the list of modules that are automatically compiled when you compile apache on pages 61-62
Running Apache • As stated earlier, to start apache, you start the service • we will do this by invoking the binary file apachectl • if this file has been placed in /usr/local/bin, then the command would be /usr/local/bin/apachectl start • apachectl can be sent any of these messages/commands: • start, stop, restart, graceful, status, fullstatus, configtest • as with any other Linux process, apache can be sent signals such as kill but can also include the following (see the full list on page 63) • SIGHUP – re-configure by re-reading the conf file • SIGTERM – terminate the process (better than using kill) • SIGKILL – have the OS kill the process rather than send this to the process to kill itself , this might be used if SIGTERM had no effect • There are a number of programmer-definable signals such as SIGUSR1 – these are only useful if Apache has had these defined (in Apache, SIGUSR1 is a graceful restart)
Apache Windows Installation • Although apache is most commonly run in Unix/Linux, there is a version that can run in Windows • we will explore throughout the semester some of the differences between a Unix/Linux installation and a Windows installation, and perhaps surprisingly, there are several functions unavailable in Windows • To install apache in Windows, similar to the Linux/Unix installation, you start by downloading the installation package • in this case, you run the installation program, which ends with the extension msi • this approach means that you are installing already compiled code, you could also download the source code and compile it but the C compiler is not a standard part of the Windows OS, unlike Linux/Unix • unlike using configure in Linux/Unix, most of the specifications are pre-established and you will only be able to modify them afterward by editing the conf files
More • You configure and modify apache in much the same way as in Linux/Unix • by manipulating conf files (there is a conf directory much like in Linux/Unix) • in addition to httpd.conf, there are older configuration files that are not used often today, access.conf and srm.conf • There are several different directives for the Windows version • unlike the Linux/Unix version which spawns child processes to handle requests, Windows runs just two copies of apache, a parent and a child that handles all requests, therefore many of the directives (which we examine in chapters 4 & 5) are different (e.g., MaxRequestsPerChild) or do not exist with new directives being added (e.g., ThreadsPerChild) • Once installed, you have the choice of running apache as a service (as with Linux/Unix) or out of a console window, which then remains open until you kill the process