How to Install Apache 2.4.2 from Source on CentOS 6.3 with SSL
yum install gcc
yum install openssl-devel
yum install apr-devel
yum install apr-util-devel
yum install libtool
yum install gcc-c++
# APR
# http://mirrors.axint.net/apache//apr/apr-1.4.6.tar.gz
tar -xvzf apr-1.4.6.tar.gz
cd apr-1.4.6/
./configure
make
make install
cd ..
# APR Utils
# http://mirrors.axint.net/apache//apr/apr-util-1.4.1.tar.gz
tar -xvzf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure –with-apr=/usr/local/apr
make
make install
cd ..
# pcre-8.20
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.20.tar.gz
tar zxvf pcre-8.20.tar.gz
cd pcre-8.20/
./configure
make
make install
# Apache
tar -zxvf apr-1.4.6.tar.gz
tar -zxvf apr-util-1.4.1.tar.gz
mv apr-1.4.6 httpd-2.4.2/srclib/apr
mv apr-util-1.4.1 httpd-2.4.2/srclib/apr-util
tar -xvzf httpd-2.4.2.tar.gz
cd httpd-2.4.2
./configure –prefix=/usr/local/apache2.4 –enable-ssl –enable-cgi –enable-vhost-alias –enable-rewrite –enable-proxy –enable-so –enable-cache –enable-disk-cache –enable-mem-cache –enable-file-cache –enable-deflate –enable-expires –enable-headers –enable-usertrack –enable-rewrite –with-included-apr –with-included-apr-util
make
make install
httpd-2.2.22
./configure –prefix=/usr/local/apache2.22 –enable-ssl –enable-cgi –enable-vhost-alias –enable-rewrite –enable-so –enable-proxy –enable-so –enable-cache –enable-disk-cache –enable-mem-cache –enable-file-cache –enable-deflate –enable-expires –enable-headers –enable-usertrack –enable-rewrite –with-included-apr –with-included-apr-util
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so
cd ..
[root@HVWMOWB01 httpd-2.4.2]# /usr/local/apache2/bin/httpd -k start
[root@HVWMOWB01 httpd-2.4.2]# ps -ef|grep http
root 29757 1 0 15:48 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
daemon 29758 29757 0 15:48 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
daemon 29760 29757 0 15:48 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
daemon 29762 29757 0 15:48 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
root 29844 9441 0 15:48 pts/4 00:00:00 grep http
Openssl setup on the Server
Include conf/extra/httpd-ssl.conf
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
cp server.key server.key.org
openssl rsa -in server.key -out servernopass.key
Compiling PHP and Apache from source
Assuming Apache source and Php source are in /usr/src directory.
To compile Apache
$ cd /usr/src
$ tar -zxvf httpd-2.0.44.tar.gz
$ cd /usr/src/httpd-2.0.44
$ ./configure –prefix=/wwwroot –enable-so ( Dynamic Shared Object (DSO) Support ) this module is used to enable dso.
$ make
$ make install
$ /wwwroot/bin/apachectl start
Now test apache installation by going to http://localhost.
Stop apache for php installation.
$ /wwwroot/bin/apachectl stop
To compile PHP
$ cd /usr/src $ tar -zxvf php-4.3.0.tar.gz
$ cd /usr/src/php-4.3.0
$ ./configure –prefix=/wwwroot/php –with-apxs2=/wwwroot/bin/apxs –with-config-file-path=/wwwroot/php –with-mysql
$ make
$ make install
Now you have to edit Apache configuration file /wwwroot/conf/httpd.conf.
If LoadModule php4_module modules/libphp4.so line hasn’t been added by php install to /wwwroot/conf/httpd.conf, then you have to add it yourself. Add it somewhere below section named “Dynamic Shared Object (DSO) Support”
LoadModule php4_module modules/libphp4.so
Now add this line to /wwwroot/conf/httpd.conf file:
AddType application/x-httpd-php .php
Start Apache now: $/wwwroot/bin/apachectl start
Now create a test PHP file using any text editor and add these lines to it:
<?php
phpinfo();
?>
Save it under /wwwroot/htdocs as info.php
Now test your PHP installation by accessing file info.php:
http://localhost/info.php
DSO
The modules can be statically compiled into the httpd binary when the server is built. Alternatively, modules can be compiled as Dynamic Shared Objects (DSOs) that exist separately from the main httpd binary file. DSO modules may be compiled at the time the server is built, or they may be compiled and added at a later time using the Apache Extension Tool (apxs).
apxs is a tool for building and installing extension modules for the Apache HyperText Transfer Protocol (HTTP) server. This is achieved by building a dynamic shared object (DSO) from one or more source or object files which then can be loaded into the Apache server under runtime via the LoadModule directive from mod_so.
So to use this extension mechanism your platform has to support the DSO feature and your Apache httpd binary has to be built with the mod_so module. The apxs tool automatically complains if this is not the case. You can check this yourself by manually running the command.
$ httpd -l
The module mod_so should be part of the displayed list. If these requirements are fulfilled you can easily extend your Apache server’s functionality by installing your own modules with the DSO mechanism by the help of this apxs tool:
$ apxs -i -a -c mod_foo.c
The arguments files can be any C source file (.c), a object file (.o) or even a library archive (.a). The apxs tool automatically recognizes these extensions and automatically used the C source files for compilation while just using the object and archive files for the linking phase.
DSO helps to add dynamic modules after we install apache.
Recent Comments