PHP DSO
DSO – Dynamically Shared Objects
Apache with PHP can be installed in two different ways.
- Statically embed the PHP binary into the Apache binary. This is probably the fastest and best way to run PHP
- Install Apache and PHP is by using Apaches DSO module
Why DSO?
Apache supports adding modules on instead of embedding them in the httpd binary. This works well when you dont want to re-compile Apache each time a module is updated, or if you want to add on numerous modules for development purposes
System Administrators Dream: Allows developers to upgrade PHP without having to recompile Apache
Understanding DSO
- Slower when compared to CGI
- Multiple versions will not support. ie php4 and php5 cannot be installed together as DSO. Either one shoulf be compiled as CGI or both as CGI
- Since module is loaded inside apache, all the codes will be executed as apache user. This is a big security issue. The overcome is php-safemode
- DSO can give direct access to apache specified calls (in http level)
- mod_security has no impact on DSO, since its seprate apache module
Installing Apache and PHP Using Apaches DSO Module
Compile Apache with DSO support
In Apache src directory
# ./configure prefix=/usr/local/apache \
enable-module=so
enable-module=rewrite
# make
# make install
Install PHP as a Module
In PHP src directory
# ./configure with-mysql \
with-xml \
enable-track-vars \
with-apxs=/usr/local/apache/bin/apxs
# make
# make install
- This will install Apache and then install the PHP module into the appropriate Apache directories.
- To add a module in Apache add a line in the httpd.conf file (if it is not already there, sometimes the install script adds it for you)
For php4
LoadModule php4_module libexec/libphp4.so
For php5
LoadModule php5_module libexec/libphp5.so
If you decide to change your configure options after installation, you only need to repeat the last three steps. You only need to restart apache for the new module to take effect. A recompile of Apache is not needed.# ./configure options
# make
# make install
Article Authored by Anoop Kiran V
Author, Anoop Kiran V, is a Systems Engineer with SupportPRO. Anoop specializes in Level 2 and Level 3 Linux / Windows Administration. SupportPRO offers 24X7 technical support services to Web hosting companies and service providers.
If you require help, contact SupportPRO Server Admin