|
This step-by-step guide explains how to set up PHP in the standalone mode.
- Log into the target (e.g. web) server as root.
- Download PHP sources (any), extract the archive, and enter the directory.
- Compile and install standalone PHP:
./configure --prefix=/hsphere/shared/apache/php \
--with-zlib-dir \
--with-jpeg-dir \
--with-png-dir \
--with-gd \
--with-mysql=/usr \
--with-gettext \
--disable-debug \
--enable-versioning \
--enable-sockets \
--enable-track-vars \
--with-pgsql=/usr \
--enable-ftp \
--localstatedir=/var/hsphere/php && make && make install
You can add other options, too.
Notes:
- Create directory for PHP binary code and set the following ownership and permissions for it:
mkdir /hsphere/local/bin
chown -R root:root /hsphere/local/bin
chmod -R 755 /hsphere/local/bin
- Copy PHP binary code into this directory:
cp /hsphere/shared/apache/php/bin /hsphere/local/bin/php
- Add the following lines to /hsphere/local/config/httpd/httpd.conf :
AddType application/x-httpd-php-external .php4 .phpext
Action application/x-httpd-php-external "/hsphere/local/bin/php"
#.php4, .phpext - extensions for scripts executed with external php as a user
<Directory /hsphere/local/bin>
Options +ExecCGI
</Directory>
ScriptAlias /php/bin/ /hsphere/local/bin/
- Create directory cgi-php inside domain's home directory for php scripts to work through CGI
and set the following ownership and permissions for it:
mkdir cgi-php
chown user:user cgi-php
chmod 755 cgi-php
* Make sure all php scripts in this directory have permissions 755 and domain owner's ownership.
- Include new CGI directory into domain's VirtualHost config:
ScriptAlias /cgi-php "/hsphere/local/home/user/domain/cgi-php"
where <user> and <domain> are the user's and name and domain's home directory.
* Note, that when an end user clicks the Apply changes link on the Web Options page,
php scipts will stop working through CGI for their account.
- All php scripts in this directory must call binary php.
For example:
#!/hsphere/local/bin/php
<?php
echo ("Test string");
?>
- Set the following permissions for /hsphere/local/var/httpd/logs/suexec_log:
chmod 666 /hsphere/local/var/httpd/logs/suexec_log
* This is quite insecure. We are in process of solution to it.
- Execute apache config test and ensure there are no errors in the config file:
/hsphere/shared/apache/bin/apachectl configtest
- Restart apache:
/hsphere/shared/apache/bin/apachectl stop
/hsphere/shared/apache/bin/apachectl start
|