Results 1 to 1 of 1
-
15th Jun 2014, 02:46 PM #1
Apache 2 and PHP 4 and 5 Installation Guide
This tutorial is designed to help those who would like to install Apache 2 and PHP as mod_php or a DSO module on a UNIX/Linux based system. This tutorial has been tested on Redhat 9 and Redhat 8, as well as FreeBSD. The installation should work fairly similar on each variation of UNIX/Linux. This tutorial will be demonstrated using FreeBSD.
Tip: Don't forget to remove (or at least disable) any rpm or other installed versions of apache.
Since Apache 2.0.42 the API for apache will be kept stable, which means you should be able to upgrade apache without having to upgrade your modules as well.
The following is how to install Apache as a DSO module.
For this tutorial we will be using PHP 4.3.8 and httpd 2.0.51.
TIP: Read the whole tutorial before you start, as some steps make go back or forwards.
1. Download apache from Welcome! - The Apache HTTP Server Project
Code:wget ftp://ftp.planetmirror.com/pub/apache/dist/httpd/httpd-2.0.51.tar.gz
Code:wget http://au2.php.net/get/php-4.3.8.tar.gz/from/www.php.net/mirror
Code:tar zxvf httpd-2.0.51.tar.gz tar zxvf php-4.3.8.tar.gz
Installation Directory Options:
--prefix=PREFIX install architecture-independent files in PREFIX - default is: /usr/local/apache2
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX]
Other Installation Options:
(Where FEATURE is a feature in httpd)
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-layout=LAYOUT
--enable-v4-mapped Allow IPv6 sockets to handle IPv4 connections
--enable-exception-hook Enable fatal exception hook
--enable-maintainer-mode Turn on debugging and compile time warnings
--enable-modules=MODULE-LIST Modules to enable (in a list separated by |)
--enable-mods-shared=MODULE-LIST Shared modules to enable
--disable-access host-based access control
--disable-auth user-based access control
--enable-auth-anon anonymous user access
--enable-auth-dbm DBM-based access databases
--enable-auth-digest RFC2617 Digest authentication
--enable-isapi isapi extension support
--enable-file-cache File cache
--enable-echo ECHO server
--disable-charset-lite character set translation
--enable-charset-lite character set translation
--enable-cache dynamic file caching
--enable-disk-cache disk caching module
--enable-mem-cache memory caching module
--enable-example example and demo module
--enable-case-filter example uppercase conversion filter
--enable-case-filter-in example uppercase conversion input filter
--enable-ldap LDAP caching and connection pooling services
--enable-auth-ldap LDAP based authentication
--enable-ext-filter external filter module
--disable-include Server Side Includes
--enable-deflate Deflate transfer encoding support
--disable-log-config logging configuration
--enable-log-forensic forensic logging
--enable-logio input and output logging
--disable-env clearing/setting of ENV vars
--enable-mime-magic automagically determining MIME type
--enable-cern-meta CERN-type meta files
--enable-expires Expires header control
--enable-headers HTTP header control
--enable-usertrack user-session tracking
--enable-unique-id per-request unique ids
--disable-setenvif basing ENV vars on headers
--enable-proxy Apache proxy module
--enable-proxy-connect Apache proxy CONNECT module
--enable-proxy-ftp Apache proxy FTP module
--enable-proxy-http Apache proxy HTTP module
--enable-ssl SSL/TLS support (mod_ssl)
--enable-optional-hook-export example optional hook exporter
--enable-optional-hook-import example optional hook importer
--enable-optional-fn-import example optional function importer
--enable-optional-fn-export example optional function exporter
--enable-bucketeer buckets manipulation filter
--enable-static-support Build a statically linked version the support binaries
--enable-static-htpasswd Build a statically linked version of htpasswd
--enable-static-htdigest Build a statically linked version of htdigest
--enable-static-rotatelogs Build a statically linked version of rotatelogs
--enable-static-logresolve Build a statically linked version of logresolve
--enable-static-htdbm Build a statically linked version of htdbm
--enable-static-ab Build a statically linked version of ab
--enable-static-checkgid Build a statically linked version of checkgid
--enable-http HTTP protocol handling
--disable-mime mapping of file-extension to MIME
--enable-dav WebDAV protocol handling
--disable-status process/thread monitoring
--disable-autoindex directory listing
--disable-asis as-is filetypes
--enable-info server information
--enable-suexec set uid and gid for spawned processes
--disable-cgid CGI scripts
--enable-cgi CGI scripts
--disable-cgi CGI scripts
--enable-cgid CGI scripts
--enable-dav-fs DAV provider for the filesystem
--enable-vhost-alias mass virtual hosting module
--disable-negotiation content negotiation
--disable-dir directory request handling
--disable-imap server-side imagemaps
--disable-actions Action triggering on requests
--enable-speling correct common URL misspellings
--disable-userdir mapping of requests to user-specific directories
--disable-alias mapping of requests to different filesystem parts
--enable-rewrite rule based URL manipulation
--enable-so DSO capability
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-apr=DIR|FILE prefix for installed APR, path to APR build tree, or the full path to apr-config
--with-apr-util=DIR prefix for installed APU, or path to APU build tree
--with-port=PORT Port on which to listen (default is 80)
--with-z=DIR use a specific zlib library
--with-ssl=DIR SSL/TLS toolkit (OpenSSL)
--with-mpm=MPM Choose the process model for Apache to use. MPM={beos|worker|prefork|mpmt_os2|perchild|leader| threadpool}
--with-module=module-type:module-file Enable module-file in the modules/<module-type> directory.
--with-program-name alternate executable name
--with-suexec-bin Path to suexec binary
--with-suexec-caller User allowed to call SuExec
--with-suexec-userdir User subdirectory
--with-suexec-docroot SuExec root directory
--with-suexec-uidmin Minimal allowed UID
--with-suexec-gidmin Minimal allowed GID
--with-suexec-logfile Set the logfile
--with-suexec-safepath Set the safepath
--with-suexec-umask umask for suexec'd process
Here is the command we are running:
./configure \
--prefix=/usr/local/apache2 \
--enable-cgi \
--enable-ssl \
--enable-so \
--enable-rewrite \
--enable-mime-magic \
--enable-suexec \
--enable-static-rotatelogs \
--enable-speling
For the most part you should not have any problems, you will get the script checking to see if your system is compatible and has all the requirements to run.
5. The following command will compile the source into binaries based on the configuration you created in step 4. You can go back to step 4 if you did something wrong and redo the configuration.
Code:make
6. The following command will move the binaries from the build directory into the locations they need to go on your system.
Code:make install
Code:/usr/local/apache2/bin/apachectl start
Code:/usr/local/apache2/bin/apachectl restart
Code:/usr/local/apache2/bin/apachectl stop
Code:telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
echo
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>
<h1>Method Not Implemented</h1>
<p>echo to /index.html.en not supported.<br />
</p>
<hr />
<address>Apache/2.0.51 (Unix) mod_ssl/2.0.51 OpenSSL/0.9.7c Server at server7.crucialdns.com Port 80</address>
</body></html>
9. Have apache 2 start up automatically:
For FreeBSD add the following line to /etc/rc.local
Code:/usr/local/apache2/bin/apachectl start
Copy the apache startup script (apachectl) from the apache directory to the startup directory.
Code:cp /usr/local/apache2/bin/apachectl /etc/init.d/
Code:# chkconfig: - 85 15 # description: Apache is a Web server used to serve HTML files and CGI.
Code:/sbin/chkconfig --add apachectl
Installing PHP 4.3.8 or 5.0.1 with Apache2
1. Change directory into the PHP source directory (php-4.3.8).
2. Configure PHP using the ./configure command, options are as follows:
Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[same as prefix]
--bindir=DIR user executables in DIR [EPREFIX/bin]
--sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
--libexecdir=DIR program executables in DIR [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data in DIR
[PREFIX/share]
--sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data in DIR
[PREFIX/com]
--localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
--libdir=DIR object code libraries in DIR [EPREFIX/lib]
--includedir=DIR C header files in DIR [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
--infodir=DIR info documentation in DIR [PREFIX/info]
--mandir=DIR man documentation in DIR [PREFIX/man]
--srcdir=DIR find the sources in DIR [configure dir or ..]
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM
run sed PROGRAM on installed program names
--with-aolserver=DIR Specify path to the installed AOLserver
--with-apxs[=FILE] Build shared Apache 1.x module. FILE is the optional
pathname to the Apache apxs tool; defaults to apxs.
--with-apache[=DIR] Build Apache 1.x module. DIR is the top-level Apache
build directory, defaults to /usr/local/apache.
--with-mod_charset Enable transfer tables for mod_charset (Rus Apache).
--with-apxs2filter[=FILE]
EXPERIMENTAL: Build shared Apache 2.0 module. FILE is the optional
pathname to the Apache apxs tool; defaults to apxs.
--with-apxs2[=FILE] EXPERIMENTAL: Build shared Apache 2.0 module. FILE is the optional
pathname to the Apache apxs tool; defaults to apxs.
--with-caudium[=DIR] Build PHP as a Pike module for use with Caudium
DIR is the Caudium server dir, with the default value
/usr/local/caudium/server.
--disable-cli Disable building CLI version of PHP
(this forces --without-pear).
--enable-embed[=TYPE] EXPERIMENTAL: Enable building of embedded SAPI library
TYPE is either 'shared' or 'static'. [TYPE=shared]
--with-isapi[=DIR] Build PHP as an ISAPI module for use with Zeus.
--with-nsapi=DIR Build PHP as NSAPI module for Netscape/iPlanet/SunONE
--with-phttpd=DIR Build PHP as phttpd module
--with-pi3web[=DIR] Build PHP as Pi3Web module
--with-roxen=DIR Build PHP as a Pike module. DIR is the base Roxen
directory, normally /usr/local/roxen/server.
--enable-roxen-zts Build the Roxen module using Zend Thread Safety.
--with-servlet[=DIR] Include servlet support. DIR is the base install
directory for the JSDK. This SAPI prereqs the
java extension must be built as a shared dl.
--with-thttpd=SRCDIR Build PHP as thttpd module
--with-tux=MODULEDIR Build PHP as a TUX module (Linux only)
--with-webjames=SRCDIR Build PHP as a WebJames module (RISC OS only)
--disable-cgi Disable building CGI version of PHP
--enable-force-cgi-redirect
Enable the security check for internal server
redirects. You should use this if you are
running the CGI version with Apache.
--enable-discard-path If this is enabled, the PHP CGI binary
can safely be placed outside of the
web tree and people will not be able
to circumvent .htaccess security.
--enable-fastcgi If this is enabled, the cgi module will
be built with support for fastcgi also.
--disable-path-info-check
If this is disabled, paths such as
/info.php/test?a=b will fail to work.
--enable-debug Compile with debugging symbols.
--with-layout=TYPE Sets how installed files will be laid out. Type is
one of PHP (default) or GNU
--with-config-file-path=PATH
Sets the path in which to look for php.ini,
defaults to PREFIX/lib
--with-config-file-scan-dir=PATH
--enable-safe-mode Enable safe mode by default.
--with-exec-dir[=DIR] Only allow executables in DIR when in safe mode
defaults to /usr/local/php/bin
--enable-sigchild Enable PHP's own SIGCHLD handler.
--enable-magic-quotes Enable magic quotes by default.
--disable-rpath Disable passing additional runtime library
search paths
--enable-libgcc Enable explicitly linking against libgcc
--disable-short-tags Disable the short-form <? start tag by default.
--enable-dmalloc Enable dmalloc
--disable-ipv6 Disable IPv6 support
--enable-versioning Export only required symbols.
See INSTALL for more information
--with-pear=DIR Install PEAR in DIR (default PREFIX/lib/php)
--without-pear Do not install PEAR
--enable-experimental-zts
This will most likely break your build
--disable-inline-optimization
If building zend_execute.lo fails, try this switch.
--enable-memory-limit Compile with memory limit support.
--enable-zend-multibyte Compile with zend multibyte support.
--with-tsrm-pth[=pth-config]
Use GNU Pth.
--with-tsrm-st Use SGI's State Threads
--with-tsrm-pthreads Use POSIX threads (default)
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS] optimize for fast installation [default=yes]
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--disable-libtool-lock avoid locking (might break parallel builds)
--with-pic try to use only PIC/non-PIC objects [default=use both]
To compile PHP in with the apache2 use the following settings.
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --prefix=/usr/local/apache2/php --with-config-file-path=/usr/local/apache2/php --enable-force-cgi-redirect --disable-cgi
--with-apxs2 - this compiles the PHP module for apache 2
--with-mysql - this enables mysql connectivity for PHP 4
--prefix - defines the location PHP will be installed in
--with-config-file-path - defines where the PHP 4.3.8 config files will be stored
---enable-force-cgi-redirect - enables security check for internal server redirects
--disable-cgi - makes sure php does not run under CGI
Code:make
Code:make install
Code:cp -p .libs/libphp4.so /usr/local/apache2/modules
cp -p php.ini-recommended /usr/local/apache2/php/php.ini
7. Open the apache2 logfile and make sure that the following lines exist:
Code:LoadModule php4_module modules/libphp4.so DirectoryIndex index.html index.php AddType application/x-httpd-php php AddType application/x-httpd-php-source phps
If these do not exist in your apache config files (/usr/local/apache2/conf/httpd.conf) then add then so as to allow PHP to function correctly.
8. Restart apache:
Code:/usr/local/apache2/bin/apachectl restart
info.php
Code:<?php echo phpinfo(); ?>
PHP 5 and Apache 2 installation coming soon!
1. Download PHP5.0.1:Code:wget http://www.php.net/get/php-5.0.1.tar.gz/from/www.php.net/mirror
2. Untar and un gzip: tar zxvf php-5.0.1.tar.gz
3. cd php-5.0.1/
4. check out the install options using ./configure --help
The next step was the configuration we used to install apache on a standard FreeBSD installation.
5.Code:./configure --prefix=/usr/local/apache2/php5 --with-apxs2=/usr/local/apache2bin/apxs --disable-cgi --enable-force-cgi-redirect --disable-libxml --libexecdir=/usr/local/apache2/modules --exec-prefix=/usr/local/apache2/php5 --with-config-file-path=/usr/local/apache2/php5
5. make
6. make install
7. Open up your apache config file
Code:vi /usr/local/apache2/conf/httpd.conf
Code:LoadModule php5_module modules/libphp5.so AddType application/x-httpd-php php AddType application/x-httpd-php-source phps
Code:/usr/local/apache2/bin/apachectl restart
Code:vi /usr/local/apache2/htdocs/phpinfo.php <?php phpinfo(); ?>
Code:http://yoursite/phpinfo.php
If you have problems during your Apache 2 and PHP 5 or 4 installation. Try removing the source directory, untaring it again, and trying a different set of configuration options.Areon Reviewed by Areon on . Apache 2 and PHP 4 and 5 Installation Guide This tutorial is designed to help those who would like to install Apache 2 and PHP as mod_php or a DSO module on a UNIX/Linux based system. This tutorial has been tested on Redhat 9 and Redhat 8, as well as FreeBSD. The installation should work fairly similar on each variation of UNIX/Linux. This tutorial will be demonstrated using FreeBSD. Tip: Don't forget to remove (or at least disable) any rpm or other installed versions of apache. Since Apache 2.0.42 the API for apache will be kept Rating: 5
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Need help regarding Apache Linux PHP and Perl?
By Mind Trainer in forum Web Application/Script SupportReplies: 0Last Post: 11th Apr 2012, 02:28 AM -
How To Install Apache with MySQL and PHP on Linux CentOS
By enetcloud in forum Tutorials and GuidesReplies: 3Last Post: 21st Aug 2011, 01:11 PM -
Installing Apache, MySQL and PHP using Yum on a Linux Server
By JacksonWeb in forum Tutorials and GuidesReplies: 6Last Post: 11th Feb 2011, 06:43 AM -
Install Apache and PHP
By VAHID in forum Server ManagementReplies: 3Last Post: 10th Jan 2011, 08:46 AM -
Apache and PHP under windows
By The Coon in forum Technical Help Desk SupportReplies: 9Last Post: 30th Oct 2009, 01:43 PM
themaManager - edit and manage...
Version 4.04 released. Open older version (or...