lau
2005-12-11, 11:31 PM
Compiling your own custom PHP
If you need to use PHP modules we do not support, you can (if you're lion-mettled) compile PHP in your home directory and tell PHP scripts to use this binary instead of the default system PHP binary.
http://php.net has good instructions for compiling, and once that's completed, you can make it work like this.
Let's assume that you installed PHP into /home/username/php/. The binary is /home/username/php/bin/php. Your domain is hosted from /home/username/domain.com.
Copy that binary into some location accessible from your domain (cgi-bin/ is a good idea). So:
cp /home/username/php/bin/php /home/username/domain.com/cgi-bin/php
For the sake of maximum ease, rename the PHP binary to end in .cgi:
mv /home/username/domain.com/cgi-bin/php /home/username/domain.com/cgi-bin/php.cgi
Now create an .htaccess file to redirect all PHP requests to this PHP binary intead of going through the default system PHP binary. Put this inside:
AddHandler custom-php .php .pcgi
Action custom-php /cgi-bin/php.cgi
Note: You can use whatever extension(s) in the AddHandler line. Separate multiple entries with spaces.
Make sure that the Action line points to a useful URL. In the example above, it points to http://domain.com/cgi-bin/php.cgi. If your PHP binary is in a different location, use a different URL. And keep in mind that it's a URL (sans domain name), NOT a path for the filesystem. Don't forget that first slash!
Good luck!
请熟悉这方面的大大指点一下,小弟不知如何下手 :bow
If you need to use PHP modules we do not support, you can (if you're lion-mettled) compile PHP in your home directory and tell PHP scripts to use this binary instead of the default system PHP binary.
http://php.net has good instructions for compiling, and once that's completed, you can make it work like this.
Let's assume that you installed PHP into /home/username/php/. The binary is /home/username/php/bin/php. Your domain is hosted from /home/username/domain.com.
Copy that binary into some location accessible from your domain (cgi-bin/ is a good idea). So:
cp /home/username/php/bin/php /home/username/domain.com/cgi-bin/php
For the sake of maximum ease, rename the PHP binary to end in .cgi:
mv /home/username/domain.com/cgi-bin/php /home/username/domain.com/cgi-bin/php.cgi
Now create an .htaccess file to redirect all PHP requests to this PHP binary intead of going through the default system PHP binary. Put this inside:
AddHandler custom-php .php .pcgi
Action custom-php /cgi-bin/php.cgi
Note: You can use whatever extension(s) in the AddHandler line. Separate multiple entries with spaces.
Make sure that the Action line points to a useful URL. In the example above, it points to http://domain.com/cgi-bin/php.cgi. If your PHP binary is in a different location, use a different URL. And keep in mind that it's a URL (sans domain name), NOT a path for the filesystem. Don't forget that first slash!
Good luck!
请熟悉这方面的大大指点一下,小弟不知如何下手 :bow