Installing Apache 1.3.x + PHP4 + PEAR + mod_ssl from source
Sunday, 23 May 2004 @ 5:40Note: I originally wrote this for Gentoo, but if you download the source code, the commands are pretty much the same. I’ll rewrite it to be more cross-distro friendly.
The advantage to compiling everything from source versus packaged ebuilds is basically that you can easily change both the Apache and PHP configuration options.
Notes:
This setup includes PEAR which is optional if you don’t want to use it. PHP installs it by default.
This setup also generates a test certificate for mod_ssl — you’re on your own if you want to integrate an existing one (shouldn’t be hard though)
I have a directory named /src where I store my downloads, so you’ll see my commands running from that directory.
# download apache_1.3.29.tar.gz and mod_ssl
emerge -f mod_ssl
# download php-4.3.6.tar.bz2
# http://www.php.net/get/php-4.3.6.tar.bz2/from/a/mirror
# or
emerge -f php
# create and goto our temp directory
mkdir /src
cd /src
# unpack apache, php and mod_ssl
tar -zxvf /usr/portage/distfiles/apache_1.3.29.tar.gz
tar -jxvf /usr/portage/distfiles/php-4.3.6.tar.bz2
tar -zxvf /usr/portage/distfiles/mod_ssl-2.8.16-1.3.29.tar.gz
# configure mod_ssl
cd mod_ssl-2.8.16-1.3.29
./configure –with-apache=../apache_1.3.29
cd ../apache_1.3.29
# configure apache
# if you have any other configuration options to pass to apache, now’s the time
# run ./configure –help in the apache_1.3.29 directory to see your options
# I’m using –prefix=/www because I think it’s cleaner having everything in one directory,
# plus the php install doc does it too. ;-)
# same with –enable-module=so — required for php installation
./configure –enable-module=ssl –prefix=/www –enable-module=so
# this message should display:
+———————————————————————+
| Before you install the package you now should prepare the SSL |
| certificate system by running the ‘make certificate’ command. |
| For different situations the following variants are provided: |
| |
| % make certificate TYPE=dummy (dummy self-signed Snake Oil cert) |
| % make certificate TYPE=test (test cert signed by Snake Oil CA) |
| % make certificate TYPE=custom (custom cert signed by own CA) |
| % make certificate TYPE=existing (existing cert) |
| CRT=/path/to/your.crt [KEY=/path/to/your.key] |
| |
| Use TYPE=dummy when you’re a vendor package maintainer, |
| the TYPE=test when you’re an admin but want to do tests only, |
| the TYPE=custom when you’re an admin willing to run a real server |
| and TYPE=existing when you’re an admin who upgrades a server. |
| (The default is TYPE=test) |
| |
| Additionally add ALGO=RSA (default) or ALGO=DSA to select |
| the signature algorithm used for the generated certificate. |
| |
| Use ‘make certificate VIEW=1′ to display the generated data. |
| |
| Thanks for using Apache & mod_ssl. Ralf S. Engelschall |
| rse@engelschall.com |
| www.engelschall.com |
+———————————————————————+
# for this instance, we’re making a test certificate
make certificate TYPE=test
# fill out all the answers
# install apache + mod_ssl into /www
make install
# configure php4
cd ../php-4.3.6
# pick your configuration — run ./configure –help to see your options
# base configuration
./configure –with-apxs=/www/bin/apxs
# base config + support for mysql:
./configure –with-apxs=/www/bin/apxs –with-mysql
# base config + support for postgresql:
./configure –with-apxs=/www/bin/apxs –with-pgsql
# for the record, my configuration - mysql, postgres, cracklib, zip and zlib:
# if you want zip support, then emerge zziplib first
# for crack support, emerge cracklib
# zlib is probably already emerged
./configure –with-mysql –with-zip –with-zlib –with-crack –with-pgsql –with-apxs=/www/bin/apxs
# a simple kludge, but running this can show you which things are not supported — comes in handy sometimes:
./configure [configuration options] | grep no
# example: ./configure –with-apxs=/www/bin/apxs –with-mysql | grep no
# compile and install php4
make && make install
# use the default php.ini
cp php.ini-dist /usr/local/lib/php.ini
# make life a bit easier
ln -s /usr/local/lib/php.ini /etc/php.ini
ln -s /www/conf/httpd.conf /etc/httpd.conf
# setup PEAR (a collection of PHP classes http://pear.php.net/ )
# run pear to see your options
# upgrade the current list of packages
pear upgrade-all
# include PEAR’s classes in your default include path
vim /etc/php.ini
# Change ‘include_path = “.:/php/includes”‘ to
include_path = “.:/usr/local/lib/php”
# Setup php4 in your apache conf file
# You can *ignore* the php docs when it says to include AddModule and LoadModule commands — apache already included them in there.
vim /etc/httpd.conf
# Change ‘DirectoryIndex index.html’ to
DirectoryIndex index.php index.html
# Add (I put mine right under ‘LoadModule php4_module libexec/libphp4.so’ )
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
#Add ServerName localhost somewhere (I put mine under ‘ServerRoot “/www”‘ )
ServerName localhost
# Setup apache virtualhosts
# Uncomment (very bottom, right above the mod_ssl section)
NameVirtualHost *:80
# Add to the end of the file:
DocumentRoot /www/htdocs
ServerName localhost
# test your apache config
/www/bin/apachectl configtest
/www/bin/apachectl start
lynx http://localhost/
lynx https://localhost/
# create an init script
vim /etc/init.d/apache
#!/sbin/runscript
depend() {
need net
}
start() {
ebegin “Starting apache”
/www/bin/apachectl start
eend $?
}
stop() {
ebegin “Stopping apache”
/www/bin/apachectl stop
eend $?
}
graceful() {
ebegin “Restarting apache gracefully”
/www/bin/apachectl graceful
eend $?
}
restart() {
svc_stop
svc_start
}
# start apache on boot
rc-update add apache default
# If you don’t want to see the apachectl output when running the script, add > /dev/null to the apachectl commands:
# /www/bin/apachectl start > /dev/null
# /www/bin/apachectl stop > /dev/null
# /www/bin/apachectl graceful > /dev/null
# the only problem with that is you might be supressing some error messages, and not know.
# apachectl graceful - http://httpd.apache.org/docs/stopping.html
# basically it waits for every connection to die before restarting, so anyone who is visiting isn’t suddenly dropped
# test your php setup
cd /www/htdocs
echo “ phpinfo(); ?>” > phpinfo.php
lynx http://localhost/phpinfo.php
# you should see sections for the configuration options you passed
You should be good to go. Good luck! :)
Please lemme know of anything I missed. Thanks guys :D