Linux Server How ToHow To Setup, Configure, Manage and Secure a Linux Server |
|
Home Which Linux Distribution? Linux Server Hardware Linux Server Security Linux Web Server - Apache Introduction to Apache2 Install Apache with Apt-get Install Apache From Source Compile Options Configuring Apache Linux DNS Server - Bind Linux DHCP Server - DHCPD Linux Mail Server - Sendmail LDP How To's About This Site |
Linux Server How To - Install the Apache2 Web Server From SourceInstalling the Apache2 Web Server From SourceCompiling the Apache2 web server from source is not anywhere near as hard as it may first sound. We will assume that the reader has no prior knowledge of compiling from source but has root privileges and the basic skills required to operate their Linux server. There are several reasons why you may want to compile Apache2 from source, your chosen distribution may not have support for apt or rpm packages or you may simply require a higher level of control over the level of functionality is needed and where things are installed.Get the Latest Apache2 Source CodeTo compile your Apache2 http server you will require the latest source distribution from The Apache Software Foundation Website. The easiest way to get the source distribution onto your Linux server is by using wget but alternately you may prefer to download the source elsewhere and FTP it to your server or copy it to disk or USB drive. Once you have the source distribution you should unpack it using tar and gzip into a directory on your machine so that you can start working with it. Apache2 must be installed as root but you can compile it as an ordinary user. This is what the process of downloading and unpacking Apache 2.2.14 looked like on our Slackware Linux server. Please note that the $ and # simply indicate that there is a prompt and what type of prompt it is, they should not be typed in.
Your freshly compiled install of Apache2 will now be found in /usr/local/apache2 in this example. Your web pages can be placed in the /usr/local/apache/htdocs directory and the web server started by issuing-
Compile PHP as a DSO for Apache2Now we have Apache2 installed on our Linux server we can consider adding support for additional features using dynamic shared objects, which are loadable modules that can allow additional functionality to be added to your webserver with a minimum of fuss. We shall use PHP as an example module, lets start by downloading and uncompressing it much the same as we did with Apache2. The latest source code for PHP can be found at www.php.net.
The above three commands will download and uncompress the PHP source distribution into the /home/john/apache2 directory. From there we must change to the PHP source directory and compile it much the same as we compiled Apache2.
To explain the configure options a little bit more thoroughly lets take a look at each one.
We now just have a few more steps to perform before our PHP enabled Apache2 web server is ready to run. Although we have specified the location of the PHP configuration file php.ini the file is not actually installed by the make program. In the top level of the source directory where we initially compiled PHP there are two files, php.ini-production and php.ini-development. Either of these two files will get our PHP installation up and running, with the production file having safer options which we can adjust down the track if necessary. We can copy this file into /usr/local/php and rename it to php.ini.
We must also make sure that the Apache2 webserver is aware of the PHP module and can load it as required. This is accomplished by adding LoadModule php5_module modules/libphp5.so to Apache2's main configuration file, httpd.conf. In our sample installation this file is located in the /usr/local/apache2/conf directory. There will likely be a section set aside for loading modules as shown below, if there isnt you should be able to add it to the end of httpd.conf without any issues. It is quite possible that this line was added when we installed PHP.
And the final step is to make sure that Apache2 invokes the PHP parser whenever it encounters a file with a .php extension. This is done by adding AddType application/x-httpd-php .php into httpd.conf in the same section as you see other applications added using the AddType directive. Once again, if you cant find this section add it to the end of httpd.conf.
|
| © 2009 www.linuxserverhowto.com |