How to install Apache+PHP using Source code (32bit and 64bit) ?
Apache Installation
Download Apache source code from www.apache.org, suppose httpd-2.2.8.tar.bz2
Run following commands
tar jxvf httpd-2.2.8.tar.bz2
cd httpd-2.2.8
32 Bit Installation
./configure --prefix=/usr/local/apache2 --enable-ssl --enable-rewrite --enable-module-so --enable-cache --enable-diskcache --enable-expires --enable-file-cache --enable-mem-cache --enable-mime-magic --enable-vhost-alias --enable-usertrack --enable-deflate --enable-headers --enable-proxy
If all goes well run
make && make install
64 Bit Installation
./configure --prefix=/usr/local/apache2 --enable-ssl --enable-rewrite --enable-module-so --enable-cache --enable-diskcache --enable-expires --enable-file-cache --enable-mem-cache --enable-mime-magic --enable-vhost-alias --enable-usertrack --enable-deflate --enable-headers --enable-lib64
--enable-proxy
If all goes well run
make && make install
PHP Installation
Download PHP from www.php.net, suppose php.5.2.6.tar.bz2
tar jxvf php.5.2.6.tar.bz2
cd php.5.2.6
32Bit Installation
./configure --prefix=/usr/local --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2/bin/apxs --enable-xml --enable-bcmath --enable-calendar --with-curl --enable-dom --enable-exif --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr/local/lib --with-xpm-dir=/usr/X11R6 --enable-magic-quotes --with-openssl --enable-discard-path --with-pear --enable-sockets --with-xmlrpc --enable-zip --with-zlib-dir=/usr/local/lib --enable-soap --with-xsl --with-ldap --enable-json --with-mysqli=/usr/bin/mysql_config --enable-mcrypt --enable-mbstring --with-config-file-path=/usr/local/lib
if all goes well run
make && make install
64Bit Installation
./configure --prefix=/usr/local --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2/bin/apxs --enable-xml --enable-bcmath --enable-calendar --with-curl=/usr/lib --enable-dom --enable-exif --enable-ftp --with-gd --with-jpeg-dir=/usr/lib64 --with-png-dir=/usr/lib64 --with-xpm-dir=/usr/X11R6 --enable-magic-quotes --with-openssl --enable-discard-path --with-pear --enable-sockets --with-xmlrpc --enable-zip --with-zlib-dir=/usr/local/lib --enable-soap --with-xsl --with-ldap --enable-json --with-libdir=lib64 --enable-mcrypt --enable-mbstring --with-config-file-path=/usr/local/lib
if all goes well run
make && make install
After installation add following lines in /usr/local/apache2/httpd.conf to compile php scripts
AddType application/x-httpd-php .php
then restart apache
/usr/local/apache2/bin/apachectl restart/start/stop.
-----------------------------------------------------------------------------------------------------------
Apache Caching and compression using mod_deflate, mod_expires and mod_headers
Deflate Settings in httpd.conf file
Apache Installation
Download Apache source code from www.apache.org, suppose httpd-2.2.8.tar.bz2
Run following commands
tar jxvf httpd-2.2.8.tar.bz2
cd httpd-2.2.8
32 Bit Installation
./configure --prefix=/usr/local/apache2 --enable-ssl --enable-rewrite --enable-module-so --enable-cache --enable-diskcache --enable-expires --enable-file-cache --enable-mem-cache --enable-mime-magic --enable-vhost-alias --enable-usertrack --enable-deflate --enable-headers --enable-proxy
If all goes well run
make && make install
64 Bit Installation
./configure --prefix=/usr/local/apache2 --enable-ssl --enable-rewrite --enable-module-so --enable-cache --enable-diskcache --enable-expires --enable-file-cache --enable-mem-cache --enable-mime-magic --enable-vhost-alias --enable-usertrack --enable-deflate --enable-headers --enable-lib64
--enable-proxy
If all goes well run
make && make install
PHP Installation
Download PHP from www.php.net, suppose php.5.2.6.tar.bz2
tar jxvf php.5.2.6.tar.bz2
cd php.5.2.6
32Bit Installation
./configure --prefix=/usr/local --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2/bin/apxs --enable-xml --enable-bcmath --enable-calendar --with-curl --enable-dom --enable-exif --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr/local/lib --with-xpm-dir=/usr/X11R6 --enable-magic-quotes --with-openssl --enable-discard-path --with-pear --enable-sockets --with-xmlrpc --enable-zip --with-zlib-dir=/usr/local/lib --enable-soap --with-xsl --with-ldap --enable-json --with-mysqli=/usr/bin/mysql_config --enable-mcrypt --enable-mbstring --with-config-file-path=/usr/local/lib
if all goes well run
make && make install
64Bit Installation
./configure --prefix=/usr/local --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2/bin/apxs --enable-xml --enable-bcmath --enable-calendar --with-curl=/usr/lib --enable-dom --enable-exif --enable-ftp --with-gd --with-jpeg-dir=/usr/lib64 --with-png-dir=/usr/lib64 --with-xpm-dir=/usr/X11R6 --enable-magic-quotes --with-openssl --enable-discard-path --with-pear --enable-sockets --with-xmlrpc --enable-zip --with-zlib-dir=/usr/local/lib --enable-soap --with-xsl --with-ldap --enable-json --with-libdir=lib64 --enable-mcrypt --enable-mbstring --with-config-file-path=/usr/local/lib
if all goes well run
make && make install
After installation add following lines in /usr/local/apache2/httpd.conf to compile php scripts
AddType application/x-httpd-php .php
then restart apache
/usr/local/apache2/bin/apachectl restart/start/stop.
-----------------------------------------------------------------------------------------------------------
Apache Caching and compression using mod_deflate, mod_expires and mod_headers
Adding deflate module in apache
At the time of compile use --enable-deflate
or after installation of apache do the following
goto the source code directory -> then goto the modules/filter directory
/usr/local/apache2/bin/apxs -c mod_deflate.c
/usr/local/apache2/bin/apxs -i -a mod_deflate.la
then add the following in httpd.conf
LoadModule deflate_module modules/mod_deflate.so
Deflate Settings in httpd.conf file
#compress content with type html, text, and css
AddOutputFilterByType DEFLATE text/html text/plain text/css text/* text/javascript application/x-javascript
There are issues with compressing other types of files such as mp3 or images. If you don't want to compress images or mp3 files, add following to your configuration:
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.avi$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mov$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp4$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.rm$ no-gzip dont-vary
##########Deflate Log
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%h %l %r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
#######Setting up access logs as per deflate
CustomLog logs/test_deflate deflate
Save and restart apache.
For virtual host: entry in virtual host file
####Write the following line Virtual Host
SetOutputFilter DEFLATE
For mod_expires & mod_headers
################mod_expires#######################
ExpiresActive on
#ExpiresDefault A600
ExpiresByType text/css "access plus 2 day"
ExpiresByType application/x-javascript "access plus 2 day"
ExpiresByType text/javascript "access plus 2 day"
ExpiresByType image/gif "access plus 7 day"
ExpiresByType image/jpeg "access plus 7 day"
ExpiresByType image/jpg "access plus 7 day"
ExpiresByType image/png "access plus 7 day"
ExpiresByType image/x-icon "access plus 1 day"
#################################################
#
# Header set Cache-Control "max-age=29030400, public"
#
Header set Cache-Control "max-age=604800, public"
# # 2 DAYS
Header set Cache-Control "max-age=172800, public, must-revalidate"
# 2 hours
Header set Cache-Control "max-age=7200, must-revalidate"
No comments:
Post a Comment