October 28, 2010 Leave a comment
Total disclaimer, everything I learned came from the Joomla! online docs. Click here to to see the exact post I followed.
- Solaris 10
- Apache 2 installed prior to adding PHP
- PHP 5.3 (from blastwave) installed to /opt/csw/php53
The sysadmin installed PHP at my request. Of course the install process did not create the libphp5.so library, nor did it update the apache configuration. So with that, there was no way to load PHP as a module. The quickest and least painful option for all was to figure out how to use PHP as a CGI executable.
After a bit of digging around and experimenting, here is what finally worked:
- sudo vi /etc/apache2/httpd.conf
- Add the following line to the ScriptAlias section:
ScriptAlias /php/ “/opt/csw/php53/bin/”
This makes an alias for the directory containing the php-cgi executable. This is the directory, not the executable, so make sure it ends with a ‘/’.
- Search for the AddType section, and add this line:
AddType application /x-httpd-php .php
Now the apache server knows to take an action when it sees anything with a .php extension.
- Now add the following to the Action section:
Action application /x-httpd-php “/php/php-cgi”
This will cause the server to respond to .php files by calling the php-cgi executable from within the directory you aliased earlier with /php/.
- Restart apache:
sudo /usr/apache2/bin/apachectl restart
That will do it. There is no need to add anything special inside your PHP scripts. Just make sure they end with the .php extension. If you need to, you can add additional AddType directives to accommodate other extensions.